Skip to content

Commit

Permalink
[CBRD-25128] In STRING_CAT '||' operation, incorrect handling of null…
Browse files Browse the repository at this point in the history
… when setting oracle_style_empty_string (#4842)

http://jira.cubrid.org/browse/CBRD-25128
  • Loading branch information
beyondykk9 authored and mhoh3963 committed Aug 6, 2024
1 parent 71dc541 commit f1ea0e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/executables/csql_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ get_current_result (int **lengths, const CUR_RESULT_INFO * result_info, bool pla
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 @@ -6062,6 +6062,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 @@ -19396,9 +19397,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 @@ -19408,7 +19410,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

0 comments on commit f1ea0e4

Please sign in to comment.