Files
impala/testdata/workloads/functional-query/queries/QueryTest/alloc-fail-init.test
Vincent Tran 3ff4cde772 IMPALA-6844: Fix possible NULL dereference in to_date() builtin
If result.ptr allocation fails for some reason inside the StringVal
constructor, we still overwrite result.len and continue.

This change checks that the StringVal pointer is not NULL before
dereferencing it, and returns NULL if it is.

Testing: Added a test case of the to_date() function to
alloc-fail-init.test to leverage the fault injector
 --stress_fn_ctx_alloc.

Change-Id: I14cfb29a592885bb2f39958c8644f93db5220a68
Reviewed-on: http://gerrit.cloudera.org:8080/11286
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
2018-08-21 22:06:02 +00:00

68 lines
2.0 KiB
Plaintext

====
---- QUERY
# TODO: IMPALA-3350: Add 'group by' to these tests to exercise different code paths.
select min(string_col) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 1 bytes.
====
---- QUERY
select max(string_col) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 1 bytes.
====
---- QUERY
select sample(timestamp_col) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 248 bytes.
====
---- QUERY
select group_concat(string_col) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 4 bytes.
====
---- QUERY
select extract(year from timestamp_col) from functional.alltypes limit 10
---- CATCH
FunctionContextImpl::AllocateForResults() failed to allocate 4 bytes.
====
---- QUERY
select trunc(timestamp_col, 'YEAR') from functional.alltypes limit 10
---- CATCH
FunctionContextImpl::AllocateForResults() failed to allocate 4 bytes.
====
---- QUERY
select first_value(string_col) over (partition by month order by year) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 1 bytes.
====
---- QUERY
select last_value(string_col) over (partition by month order by year) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 1 bytes.
====
---- QUERY
select rand() from functional.alltypes;
---- CATCH
FunctionContext::Allocate() failed to allocate 16 bytes.
====
---- QUERY
select case when min(int_col) = 0 then 0 end from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 16 bytes.
====
---- QUERY
select cast(string_col as char(120)) from functional.alltypes
---- CATCH
FunctionContextImpl::AllocateForResults() failed to allocate 120 bytes.
====
---- QUERY
select appx_median(int_col) from functional.alltypes
---- CATCH
FunctionContext::Allocate() failed to allocate 248 bytes.
====
---- QUERY
select to_date(now())
---- CATCH
FunctionContextImpl::AllocateForResults() failed to allocate 10 bytes.
====