From 53f18ba5fc8b4e37e78707e3b351bfe4b433c9a9 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sun, 4 Jan 2009 18:41:36 +0000 Subject: [PATCH] Fixed CORE-2265 - Grouping by function doesn't work properly (This is related to CORE-1246 changes) --- src/dsql/make.cpp | 3 ++- src/dsql/make_proto.h | 2 +- src/dsql/node.h | 4 +++- src/dsql/parse.y | 48 +++++++++++++++++++++---------------------- src/dsql/pass1.cpp | 3 +++ 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/dsql/make.cpp b/src/dsql/make.cpp index 43eaad64eab..8cc5d6c4672 100644 --- a/src/dsql/make.cpp +++ b/src/dsql/make.cpp @@ -93,12 +93,13 @@ static void make_parameter_names(dsql_par*, const dsql_nod*); static const char* DB_KEY_NAME = "DB_KEY"; -dsql_nod* MAKE_const_slong(SLONG value) +dsql_nod* MAKE_const_slong(SLONG value, bool special) { thread_db* tdbb = JRD_get_thread_data(); dsql_nod* node = FB_NEW_RPT(*tdbb->getDefaultPool(), 1) dsql_nod; node->nod_type = nod_constant; + node->nod_flags = special ? NOD_CONST_SPECIAL : 0; node->nod_desc.dsc_dtype = dtype_long; node->nod_desc.dsc_length = sizeof(SLONG); node->nod_desc.dsc_scale = 0; diff --git a/src/dsql/make_proto.h b/src/dsql/make_proto.h index fb9039dfd41..334ca648107 100644 --- a/src/dsql/make_proto.h +++ b/src/dsql/make_proto.h @@ -56,7 +56,7 @@ namespace Jrd { } -Jrd::dsql_nod* MAKE_const_slong(SLONG); +Jrd::dsql_nod* MAKE_const_slong(SLONG, bool special = false); Jrd::dsql_nod* MAKE_constant(Jrd::dsql_str*, Jrd::dsql_constant_type); Jrd::dsql_nod* MAKE_str_constant(Jrd::dsql_str*, SSHORT); Jrd::dsql_str* MAKE_cstring(const char*); diff --git a/src/dsql/node.h b/src/dsql/node.h index bf59db96750..4e1c26d6e70 100644 --- a/src/dsql/node.h +++ b/src/dsql/node.h @@ -1105,7 +1105,9 @@ enum nod_flags_vals { NOD_TRAN_AUTONOMOUS = 1, // nod_exec_stmt NOD_TRAN_COMMON = 2, NOD_TRAN_2PC = 3, - NOD_TRAN_DEFAULT = NOD_TRAN_COMMON + NOD_TRAN_DEFAULT = NOD_TRAN_COMMON, + + NOD_CONST_SPECIAL = 1 // nod_constant }; } // namespace diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 52ebc78f9c3..fbb24ccd98b 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -4384,19 +4384,19 @@ current_role : CURRENT_ROLE internal_info : CURRENT_CONNECTION { $$ = make_node (nod_internal_info, (int) e_internal_info_count, - MAKE_const_slong (internal_connection_id)); } + MAKE_const_slong (internal_connection_id, true)); } | CURRENT_TRANSACTION { $$ = make_node (nod_internal_info, (int) e_internal_info_count, - MAKE_const_slong (internal_transaction_id)); } + MAKE_const_slong (internal_transaction_id, true)); } | GDSCODE { $$ = make_node (nod_internal_info, (int) e_internal_info_count, - MAKE_const_slong (internal_gdscode)); } + MAKE_const_slong (internal_gdscode, true)); } | SQLCODE { $$ = make_node (nod_internal_info, (int) e_internal_info_count, - MAKE_const_slong (internal_sqlcode)); } + MAKE_const_slong (internal_sqlcode, true)); } | ROW_COUNT { $$ = make_node (nod_internal_info, (int) e_internal_info_count, - MAKE_const_slong (internal_rows_affected)); } + MAKE_const_slong (internal_rows_affected, true)); } ; sql_string : STRING /* string in current charset */ @@ -4538,20 +4538,20 @@ length_expression : bit_length_expression bit_length_expression : BIT_LENGTH '(' value ')' { $$ = make_node(nod_strlen, (int) e_strlen_count, - MAKE_const_slong(blr_strlen_bit), $3); } + MAKE_const_slong(blr_strlen_bit, true), $3); } ; char_length_expression : CHAR_LENGTH '(' value ')' { $$ = make_node(nod_strlen, (int) e_strlen_count, - MAKE_const_slong(blr_strlen_char), $3); } + MAKE_const_slong(blr_strlen_char, true), $3); } | CHARACTER_LENGTH '(' value ')' { $$ = make_node(nod_strlen, (int) e_strlen_count, - MAKE_const_slong(blr_strlen_char), $3); } + MAKE_const_slong(blr_strlen_char, true), $3); } ; octet_length_expression : OCTET_LENGTH '(' value ')' { $$ = make_node(nod_strlen, (int) e_strlen_count, - MAKE_const_slong(blr_strlen_octet), $3); } + MAKE_const_slong(blr_strlen_octet, true), $3); } ; system_function_expression @@ -4675,20 +4675,20 @@ trim_function : TRIM '(' trim_specification value FROM value ')' { $$ = make_node (nod_trim, (int) e_trim_count, $3, $4, $6); } | TRIM '(' value FROM value ')' { $$ = make_node (nod_trim, (int) e_trim_count, - MAKE_const_slong (blr_trim_both), $3, $5); } + MAKE_const_slong (blr_trim_both, true), $3, $5); } | TRIM '(' trim_specification FROM value ')' { $$ = make_node (nod_trim, (int) e_trim_count, $3, NULL, $5); } | TRIM '(' value ')' { $$ = make_node (nod_trim, (int) e_trim_count, - MAKE_const_slong (blr_trim_both), NULL, $3); } + MAKE_const_slong (blr_trim_both, true), NULL, $3); } ; trim_specification : BOTH - { $$ = MAKE_const_slong (blr_trim_both); } + { $$ = MAKE_const_slong (blr_trim_both, true); } | TRAILING - { $$ = MAKE_const_slong (blr_trim_trailing); } + { $$ = MAKE_const_slong (blr_trim_trailing, true); } | LEADING - { $$ = MAKE_const_slong (blr_trim_leading); } + { $$ = MAKE_const_slong (blr_trim_leading, true); } ; udf : symbol_UDF_call_name '(' value_list ')' @@ -4788,25 +4788,25 @@ next_value_expression : NEXT KW_VALUE FOR symbol_generator_name timestamp_part : YEAR - { $$ = MAKE_const_slong (blr_extract_year); } + { $$ = MAKE_const_slong (blr_extract_year, true); } | MONTH - { $$ = MAKE_const_slong (blr_extract_month); } + { $$ = MAKE_const_slong (blr_extract_month, true); } | DAY - { $$ = MAKE_const_slong (blr_extract_day); } + { $$ = MAKE_const_slong (blr_extract_day, true); } | HOUR - { $$ = MAKE_const_slong (blr_extract_hour); } + { $$ = MAKE_const_slong (blr_extract_hour, true); } | MINUTE - { $$ = MAKE_const_slong (blr_extract_minute); } + { $$ = MAKE_const_slong (blr_extract_minute, true); } | SECOND - { $$ = MAKE_const_slong (blr_extract_second); } + { $$ = MAKE_const_slong (blr_extract_second, true); } | MILLISECOND - { $$ = MAKE_const_slong (blr_extract_millisecond); } + { $$ = MAKE_const_slong (blr_extract_millisecond, true); } | WEEK - { $$ = MAKE_const_slong (blr_extract_week); } + { $$ = MAKE_const_slong (blr_extract_week, true); } | WEEKDAY - { $$ = MAKE_const_slong (blr_extract_weekday); } + { $$ = MAKE_const_slong (blr_extract_weekday, true); } | YEARDAY - { $$ = MAKE_const_slong (blr_extract_yearday); } + { $$ = MAKE_const_slong (blr_extract_yearday, true); } ; all_noise : ALL diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 278f0bfbcea..16236c856f5 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -10100,6 +10100,9 @@ static dsql_nod* remap_field(CompiledStatement* statement, dsql_nod* field, return field; case nod_constant: + // ASF: Do not remap non-user constants - CORE-2265. + return (field->nod_flags & NOD_CONST_SPECIAL) ? field : post_map(field, context); + case nod_dbkey: return post_map(field, context);