From: Frank Schlottmann-G. <fs...@us...> - 2000-11-16 15:54:33
|
Update of /cvsroot/firebird/interbase/gpre In directory slayer.i.sourceforge.net:/tmp/cvs-serv12665/interbase/gpre Modified Files: gpre.c gpre.h gpreswi.h sqe.c Log Message: Added new switch -verbose to gpre that will dump parsed lines to stderr Fixed gpre bug in handling row names in WHERE clauses that are reserved words now (DATE etc) (this caused gpre to dump core when parsing tan.e) Fixed gpre bug in handling lower case table aliases in WHERE clauses for sql dialect 2 and 3. (cause a core dump in a test case from C.R. Zamana) Index: gpre.c =================================================================== RCS file: /cvsroot/firebird/interbase/gpre/gpre.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** gpre.c 2000/08/03 20:44:04 1.1.1.1 --- gpre.c 2000/11/16 15:54:29 1.2 *************** *** 20,23 **** --- 20,36 ---- * All Rights Reserved. * Contributor(s): ______________________________________. + * $Log$ + * Revision 1.2 2000/11/16 15:54:29 fsg + * Added new switch -verbose to gpre that will dump + * parsed lines to stderr + * + * Fixed gpre bug in handling row names in WHERE clauses + * that are reserved words now (DATE etc) + * (this caused gpre to dump core when parsing tan.e) + * + * Fixed gpre bug in handling lower case table aliases + * in WHERE clauses for sql dialect 2 and 3. + * (cause a core dump in a test case from C.R. Zamana) + * */ *************** *** 318,322 **** sw_know_interp = FALSE; sw_interp = 0; ! sw_sql_dialect = compiletime_db_dialect = SQL_DIALECT_V5; --- 331,336 ---- sw_know_interp = FALSE; sw_interp = 0; ! /* FSG 14.Nov.2000 */ ! sw_verbose = FALSE; sw_sql_dialect = compiletime_db_dialect = SQL_DIALECT_V5; *************** *** 650,654 **** sw_trace = TRUE; break; ! default: break; --- 664,671 ---- sw_trace = TRUE; break; ! /* FSG 14.Nov.2000 */ ! case IN_SW_GPRE_VERBOSE : ! sw_verbose = TRUE; ! break; default: break; *************** *** 1762,1770 **** * **************************************/ if (input_char != input_buffer) return (int) *--input_char; else ! return ib_getc (file); } --- 1779,1805 ---- * **************************************/ + USHORT pc; + if (input_char != input_buffer) + { return (int) *--input_char; + + } else ! { ! ! pc=ib_getc (file); ! ! /* Dump this char to stderr, so we can see ! what input line will cause this ugly ! core dump. ! FSG 14.Nov.2000 */ ! if (sw_verbose) ! ib_fprintf (ib_stderr, "%c",pc); ! return pc; ! } ! ! } *************** *** 2515,2518 **** --- 2550,2557 ---- SLONG start; + /* FSG 14.Nov.2000 */ + if (sw_verbose) + ib_fprintf (ib_stderr, "*********************** PASS 1 ***************************\n"); + while (CPR_token()) while (token.tok_symbol) *************** *** 2595,2598 **** --- 2634,2641 ---- c = 0; + /* FSG 14.Nov.2000 */ + if (sw_verbose) + ib_fprintf (ib_stderr, "*********************** PASS 2 ***************************\n"); + suppress_output = FALSE; sw_block_comments = sw_language == lan_c || Index: gpre.h =================================================================== RCS file: /cvsroot/firebird/interbase/gpre/gpre.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** gpre.h 2000/08/03 20:44:04 1.1.1.1 --- gpre.h 2000/11/16 15:54:29 1.2 *************** *** 20,23 **** --- 20,36 ---- * All Rights Reserved. * Contributor(s): ______________________________________. + * $Log$ + * Revision 1.2 2000/11/16 15:54:29 fsg + * Added new switch -verbose to gpre that will dump + * parsed lines to stderr + * + * Fixed gpre bug in handling row names in WHERE clauses + * that are reserved words now (DATE etc) + * (this caused gpre to dump core when parsing tan.e) + * + * Fixed gpre bug in handling lower case table aliases + * in WHERE clauses for sql dialect 2 and 3. + * (cause a core dump in a test case from C.R. Zamana) + * */ *************** *** 1406,1411 **** #define EXTERN extern #endif ! EXTERN USHORT sw_auto, sw_sql, sw_gen_sql, sw_raw, sw_cstring, sw_dsql, sw_dyn_using, sw_ada, sw_standard_out, sw_ansi, sw_lines, sw_ids, sw_trace, sw_case, sw_external, sw_pyxis, --- 1419,1427 ---- #define EXTERN extern #endif + + /* Added sw_verbose + FSG 14.Nov.2000 */ ! EXTERN USHORT sw_verbose,sw_auto, sw_sql, sw_gen_sql, sw_raw, sw_cstring, sw_dsql, sw_dyn_using, sw_ada, sw_standard_out, sw_ansi, sw_lines, sw_ids, sw_trace, sw_case, sw_external, sw_pyxis, Index: gpreswi.h =================================================================== RCS file: /cvsroot/firebird/interbase/gpre/gpreswi.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** gpreswi.h 2000/08/03 20:44:04 1.1.1.1 --- gpreswi.h 2000/11/16 15:54:29 1.2 *************** *** 20,23 **** --- 20,36 ---- * All Rights Reserved. * Contributor(s): ______________________________________. + * $Log$ + * Revision 1.2 2000/11/16 15:54:29 fsg + * Added new switch -verbose to gpre that will dump + * parsed lines to stderr + * + * Fixed gpre bug in handling row names in WHERE clauses + * that are reserved words now (DATE etc) + * (this caused gpre to dump core when parsing tan.e) + * + * Fixed gpre bug in handling lower case table aliases + * in WHERE clauses for sql dialect 2 and 3. + * (cause a core dump in a test case from C.R. Zamana) + * */ *************** *** 71,78 **** #define IN_SW_GPRE_INTERP 29 /* default character set/collation */ ! #define IN_SW_GPRE_COUNT 30 /* number of IN_SW values */ ! #define IN_SW_GPRE_CPLUSPLUS 31 /* source is platform dependant C++ */ ! #define IN_SW_GPRE_SQLDIALECT 32 /* SQL dialect passed */ static struct in_sw_tab_t gpre_in_sw_table [] = { #ifdef ADA --- 84,102 ---- #define IN_SW_GPRE_INTERP 29 /* default character set/collation */ ! #define IN_SW_GPRE_CPLUSPLUS 30 /* source is platform dependant C++ */ ! #define IN_SW_GPRE_SQLDIALECT 31 /* SQL dialect passed */ + /* Added this to let gpre dump the lines that it is parsing to stderr + FSG 14.Nov.2000 + */ + #define IN_SW_GPRE_VERBOSE 32 + + /* As mentioned above: This should always be one larger than the largest + switch value. + FSG 14.Nov.2000 + */ + + #define IN_SW_GPRE_COUNT 33 /* number of IN_SW values */ + static struct in_sw_tab_t gpre_in_sw_table [] = { #ifdef ADA *************** *** 111,114 **** --- 135,140 ---- IN_SW_GPRE_T, 0, "TRACE", 0, 0, 0, FALSE, 0, 0, NULL, IN_SW_GPRE_USER, 0, "USER", 0, 0, 0, FALSE, 0, 0, "\t\tdefault user name", + /* FSG 14.Nov.2000 */ + IN_SW_GPRE_VERBOSE, 0, "VERBOSE", 0, 0, 0, FALSE, 0, 0, "\t\tVerbose Output to stderr", #ifdef VMS IN_SW_GPRE_X, 0, "EXTERNAL", 0, 0, 0, FALSE, 0, 0, "\t\tEXTERNAL database (used with /DATABASE)", Index: sqe.c =================================================================== RCS file: /cvsroot/firebird/interbase/gpre/sqe.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sqe.c 2000/08/26 08:06:46 1.2 --- sqe.c 2000/11/16 15:54:29 1.3 *************** *** 20,25 **** * All Rights Reserved. * Contributor(s): ______________________________________. */ ! #include <string.h> #include "../gpre/gpre.h" --- 20,38 ---- * All Rights Reserved. * Contributor(s): ______________________________________. + * $Log$ + * Revision 1.3 2000/11/16 15:54:29 fsg + * Added new switch -verbose to gpre that will dump + * parsed lines to stderr + * + * Fixed gpre bug in handling row names in WHERE clauses + * that are reserved words now (DATE etc) + * (this caused gpre to dump core when parsing tan.e) + * + * Fixed gpre bug in handling lower case table aliases + * in WHERE clauses for sql dialect 2 and 3. + * (cause a core dump in a test case from C.R. Zamana) + * */ ! #include <stdio.h> #include <string.h> #include "../gpre/gpre.h" *************** *** 1219,1223 **** MATCH (KW_PLUS); node = par_multiply (request, aster_ok, paren_count, bool_flag); ! if (node->nod_type == nod_asterisk) { --- 1232,1236 ---- MATCH (KW_PLUS); node = par_multiply (request, aster_ok, paren_count, bool_flag); ! assert_IS_NOD (node); if (node->nod_type == nod_asterisk) { *************** *** 2262,2285 **** assert_IS_REQ (request); - node = par_primitive_value (request, aster_ok, paren_count, bool_flag); ! ! if (node->nod_type == nod_asterisk) ! return node; ! if (KEYWORD (KW_COLLATE)) ! return par_collate (request, node); ! while (TRUE) ! { ! if (MATCH (KW_ASTERISK)) ! operator = nod_times; ! else if (MATCH (KW_SLASH)) ! operator = nod_divide; ! else ! return node; ! arg = node; ! node = MSC_binary (operator, arg, par_primitive_value (request, FALSE, paren_count, bool_flag)); ! } } --- 2275,2296 ---- assert_IS_REQ (request); node = par_primitive_value (request, aster_ok, paren_count, bool_flag); ! if (node->nod_type == nod_asterisk) ! return node; ! if (KEYWORD (KW_COLLATE)) ! return par_collate (request, node); ! while (TRUE) ! { ! if (MATCH (KW_ASTERISK)) ! operator = nod_times; ! else if (MATCH (KW_SLASH)) ! operator = nod_divide; ! else ! return node; ! arg = node; ! node = MSC_binary (operator, arg, par_primitive_value (request, FALSE, paren_count, bool_flag)); ! } } *************** *** 2641,2644 **** --- 2652,2657 ---- assert_IS_REQ (request); + node = FALSE; + if (!paren_count) { *************** *** 2753,2765 **** } ! /** Begin date/time/timestamp support **/ ! kw_word = token.tok_keyword; ! if (MATCH(KW_DATE) || MATCH(KW_TIME) || MATCH(KW_TIMESTAMP)) ! { ! token.tok_keyword = kw_word; ! node = EXP_literal(); ! return node; ! } ! /** End date/time/timestamp support **/ /* If the next token is a colon, it is a variable reference */ --- 2766,2774 ---- } ! /* moved this timestamp support down some lines, because it caused ! gpre to segfault when it was done here. ! FSG 15.Nov.2000 ! */ ! /* If the next token is a colon, it is a variable reference */ *************** *** 2783,2789 **** } - /* Must be a field or a udf. If there is a map, post the field to it. */ ! node = par_udf_or_field (request, aster_ok); /* --- 2792,2799 ---- } ! ! /* Must be a field or a udf. If there is a map, post the field to it. */ ! node= par_udf_or_field (request, aster_ok); /* *************** *** 2792,2795 **** --- 2802,2823 ---- */ + if (!node) + /* I don't know what it's good for, but let's try it anyway if we haven't found + anything that makes sense until now */ + { + /** Begin date/time/timestamp support **/ + kw_word = token.tok_keyword; + + if (MATCH(KW_DATE) || MATCH(KW_TIME) || MATCH(KW_TIMESTAMP)) + { + token.tok_keyword = kw_word; + node = EXP_literal(); + return node; + } + + /** End date/time/timestamp support **/ + + } + return node; } *************** *** 3729,3735 **** symbol = HSH_lookup (q_token->tok_string); ! if ( (symbol == NULL) && (sw_case || sw_sql_dialect == SQL_DIALECT_V5)) symbol = HSH_lookup2 (q_token->tok_string); ! for (temp_symbol = symbol; temp_symbol; temp_symbol = temp_symbol->sym_homonym) { --- 3757,3776 ---- symbol = HSH_lookup (q_token->tok_string); ! ! /* This caused gpre to dump core if there are lower case ! table aliases in a where clause used with dialect 2 or 3 ! ! if ( (symbol == NULL)&& (sw_case || sw_sql_dialect == SQL_DIALECT_V5)) symbol = HSH_lookup2 (q_token->tok_string); ! */ ! ! /* So I replaced it with the following, don't know ! why we don't do a HSH_lookup2 in any case, but so it may be. ! FSG 16.Nov.2000 ! */ ! if ( (symbol == NULL)) ! symbol = HSH_lookup2 (q_token->tok_string); ! ! for (temp_symbol = symbol; temp_symbol; temp_symbol = temp_symbol->sym_homonym) { |