Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-25128] In STRING_CAT '||' operation, incorrect handling of null when setting oracle_style_empty_string #4842

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/executables/csql_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ get_current_result (int **lengths, const CUR_RESULT_INFO * result_info, const CS
assert (value_type == DB_TYPE_NULL
/* UNKNOWN, maybe host variable */
|| result_info->attr_types[i] == DB_TYPE_NULL || result_info->attr_types[i] == DB_TYPE_VARIABLE
|| value_type == result_info->attr_types[i]);
|| value_type == result_info->attr_types[i]
|| (TP_IS_CHAR_TYPE (value_type) && TP_IS_CHAR_TYPE (result_info->attr_types[i])));

switch (value_type)
{
Expand Down
8 changes: 5 additions & 3 deletions src/parser/type_checking.c
Original file line number Diff line number Diff line change
Expand Up @@ -6066,6 +6066,7 @@ does_op_specially_treat_null_arg (PT_OP_TYPE op)
case PT_TO_CHAR:
return true;
case PT_REPLACE:
case PT_STRCAT:
return prm_get_bool_value (PRM_ID_ORACLE_STYLE_EMPTY_STRING);
default:
return false;
Expand Down Expand Up @@ -18243,9 +18244,10 @@ pt_fold_const_expr (PARSER_CONTEXT * parser, PT_NODE * expr, void *arg)
/* use the caching variant of this function ! */
domain = pt_xasl_node_to_domain (parser, expr);

if (domain && QSTR_IS_ANY_CHAR_OR_BIT (TP_DOMAIN_TYPE (domain)))
if (domain
&& (QSTR_IS_ANY_CHAR_OR_BIT (TP_DOMAIN_TYPE (domain)) || type1 == PT_TYPE_NULL || type2 == PT_TYPE_NULL))
{
if (opd1 && opd1->node_type == PT_VALUE && type1 == PT_TYPE_NULL && PT_IS_STRING_TYPE (type2))
if (opd1 && opd1->node_type == PT_VALUE && type1 == PT_TYPE_NULL)
{
/* fold 'null || char_opnd' expr to 'char_opnd' */
result = parser_copy_tree (parser, opd2);
Expand All @@ -18255,7 +18257,7 @@ pt_fold_const_expr (PARSER_CONTEXT * parser, PT_NODE * expr, void *arg)
goto end;
}
}
else if (opd2 && opd2->node_type == PT_VALUE && type2 == PT_TYPE_NULL && PT_IS_STRING_TYPE (type1))
else if (opd2 && opd2->node_type == PT_VALUE && type2 == PT_TYPE_NULL)
{
/* fold 'char_opnd || null' expr to 'char_opnd' */
result = parser_copy_tree (parser, opd1);
Expand Down