Skip to content

Commit

Permalink
[CBRD-23600] Unexpected rounding up a numeric value when the case exp…
Browse files Browse the repository at this point in the history
…ressions are used recursively (#2180)

http://jira.cubrid.org/browse/CBRD-23600

When the CASE expressions are used recursively and values specified in the THEN clause are numeric and integer type of order repeatedly, one of the numeric values is rounded up unexpectedly. It causes because the arg1 pointer variable for PT_NODE is incorrectly re-used at the part of checking PT_NODE of the next case clause. This commit fixes to keep the arg1 from being re-used incorrectly.
  • Loading branch information
hgryoo authored Jan 31, 2020
1 parent ef16697 commit 781302c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser/type_checking.c
Original file line number Diff line number Diff line change
Expand Up @@ -10186,24 +10186,24 @@ pt_eval_expr_type (PARSER_CONTEXT * parser, PT_NODE * node)
&& (nextcase->info.expr.op == PT_CASE || nextcase->info.expr.op == PT_DECODE))
{
/* cast nextcase->arg1 to common type */
arg1 = nextcase->info.expr.arg1;
arg1_type = arg1->type_enum;
if (arg1_type != common_type && arg1_type != PT_TYPE_NULL)
PT_NODE *next_arg1 = nextcase->info.expr.arg1;
PT_TYPE_ENUM next_arg1_type = next_arg1->type_enum;
if (next_arg1_type != common_type && next_arg1_type != PT_TYPE_NULL)
{
if (pt_coerce_expression_argument (parser, nextcase, &arg1, common_type, NULL) != NO_ERROR)
if (pt_coerce_expression_argument (parser, nextcase, &next_arg1, common_type, NULL) != NO_ERROR)
{
/* abandon implicit casting and return error */
node->type_enum = PT_TYPE_NONE;
goto error;
}
nextcase->info.expr.arg1 = arg1;
nextcase->info.expr.arg1 = next_arg1;
/* nextcase was already evaluated and may have a data_type set. We need to replace it with the
* cast data_type */
nextcase->type_enum = common_type;
if (nextcase->data_type)
{
parser_free_tree (parser, nextcase->data_type);
nextcase->data_type = parser_copy_tree_list (parser, arg1->data_type);
nextcase->data_type = parser_copy_tree_list (parser, next_arg1->data_type);
}
}
/* set nextcase to nextcase->arg2 and continue */
Expand Down

0 comments on commit 781302c

Please sign in to comment.