From 6fb3c3f78fbb2296894424f6e3183d339915eac7 Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Fri, 15 Oct 1999 19:02:08 +0000 Subject: [PATCH] *** empty log message *** --- src/interfaces/ecpg/ChangeLog | 11 +++ src/interfaces/ecpg/TODO | 7 +- src/interfaces/ecpg/preproc/Makefile | 2 +- src/interfaces/ecpg/preproc/keywords.c | 3 +- src/interfaces/ecpg/preproc/pgc.l | 32 ++++++--- src/interfaces/ecpg/preproc/preproc.y | 99 +++++++++++++++----------- 6 files changed, 99 insertions(+), 55 deletions(-) diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index f0043ed9bd..bd2a6f9e15 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -674,3 +674,14 @@ Thu Oct 7 15:12:58 CEST 1999 - Set ecpg version to 2.6.6 - Set library version to 3.0.4 +Tue Oct 12 07:26:50 CEST 1999 + + - Simplified C part of parser. + +Fri Oct 15 17:05:25 CEST 1999 + + - Synced preproc.y with gram.y. + - Synced pgc.l with scan.l. + - Synced keyword.c. + - Finished C parser changes, so initializers are correctly parsed. + - Set ecpg version to 2.6.7 diff --git a/src/interfaces/ecpg/TODO b/src/interfaces/ecpg/TODO index 36d929ea0b..9e9f94b157 100644 --- a/src/interfaces/ecpg/TODO +++ b/src/interfaces/ecpg/TODO @@ -13,8 +13,13 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS The line numbering is not exact. +What happens to the output variable during read if there was an +indicator-error? + +Add a semantic check level, e.g. check if a table really exists. + Missing statements: - - exec slq ifdef + - exec sql ifdef - exec sql allocate - exec sql deallocate - SQLSTATE diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index 337e094419..ac0015cbd2 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global MAJOR_VERSION=2 MINOR_VERSION=6 -PATCHLEVEL=6 +PATCHLEVEL=7 CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ diff --git a/src/interfaces/ecpg/preproc/keywords.c b/src/interfaces/ecpg/preproc/keywords.c index 3c65d99fb0..398d8c7a3d 100644 --- a/src/interfaces/ecpg/preproc/keywords.c +++ b/src/interfaces/ecpg/preproc/keywords.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.18 1999/10/08 11:05:02 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.19 1999/10/15 19:02:08 meskes Exp $ * *------------------------------------------------------------------------- */ @@ -61,6 +61,7 @@ static ScanKeyword ScanKeywords[] = { {"coalesce", COALESCE}, {"collate", COLLATE}, {"column", COLUMN}, + {"comment", COMMENT}, {"commit", COMMIT}, {"committed", COMMITTED}, {"constraint", CONSTRAINT}, diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 80a8547ed6..498fe689e5 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -1,3 +1,4 @@ + /* This is a modified version of src/backend/parser/scan.l */ %{ #include @@ -90,6 +91,10 @@ xhstop {quote} xhinside [^']* xhcat {quote}{space}*\n{space}*{quote} +/* C version of hex number + */ +xch 0[xX][0-9A-Fa-f]* + /* Extended quote * xqdouble implements SQL92 embedded quote * xqcat allows strings to cross input lines @@ -150,10 +155,10 @@ real (((({digit}*\.{digit}+)|({digit}+\.{digit}*))([Ee][-+]?{digit}+)?)|({digi param \${integer} -comment ("--"|"//").*\n +comment ("--"|"//").* ccomment "//".*\n -space [ \t\n\f] +space [ \t\n\r\f] other . /* some stuff needed for ecpg */ @@ -242,7 +247,6 @@ cppline {space}*#.*(\\{space}*\n)*\n* } {xqstop} { BEGIN(SQL); - /* yylval.str = mm_strdup(scanstr(literal));*/ yylval.str = mm_strdup(literal); return SCONST; } @@ -319,13 +323,6 @@ cppline {space}*#.*(\\{space}*\n)*\n* if (*endptr != '\0' || errno == ERANGE) { errno = 0; -#if 0 - yylval.dval = strtod(((char *)yytext),&endptr); - if (*endptr != '\0' || errno == ERANGE) - yyerror("ERROR: Bad integer input"); - yyerror("WARNING: Integer input is out of range; promoted to float"); - return FCONST; -#endif yylval.str = mm_strdup((char*)yytext); return SCONST; } @@ -414,6 +411,19 @@ cppline {space}*#.*(\\{space}*\n)*\n* {other} { return yytext[0]; } {exec}{space}*{sql} { BEGIN SQL; return SQL_START; } {ccomment} { /* ignore */ } +{xch} { + char* endptr; + + errno = 0; + yylval.ival = strtol((char *)yytext,&endptr,16); + if (*endptr != '\0' || errno == ERANGE) + { + errno = 0; + yylval.str = mm_strdup((char*)yytext); + return SCONST; + } + return ICONST; + } {cppline} { yylval.str = mm_strdup((char*)yytext); return(CPP_LINE); @@ -470,7 +480,7 @@ cppline {space}*#.*(\\{space}*\n)*\n* \[ { return('['); } \] { return(']'); } \= { return('='); } -{other} { return S_ANYTHING; } +{other} { return S_ANYTHING; } {exec}{space}{sql}{space}{define} {BEGIN(def_ident);} {space} {} {identifier} { diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index 5f4bd2a364..06895e1979 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -724,7 +724,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim */ %token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE, BACKWARD, BEFORE, BINARY, - CACHE, CLUSTER, COPY, CREATEDB, CREATEUSER, CYCLE, + CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE, DATABASE, DELIMITERS, DO, EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND, FORWARD, FUNCTION, HANDLER, @@ -785,7 +785,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim %type update_target_el opt_id relation_name database_name %type access_method attr_name class index_name name func_name %type file_name AexprConst ParamNo TypeId -%type in_expr_nodes a_expr b_expr TruncateStmt +%type in_expr_nodes a_expr b_expr TruncateStmt CommentStmt %type opt_indirection expr_list extract_list extract_arg %type position_list substr_list substr_from %type trim_list in_expr substr_for attr attrs @@ -839,15 +839,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim %type constraints_set_mode %type ECPGWhenever ECPGConnect connection_target ECPGOpen opt_using -%type indicator ECPGExecute ecpg_expr dotext ECPGPrepare -%type storage_clause opt_initializer vartext c_anything blockstart -%type blockend variable_list variable var_anything do_anything +%type indicator ECPGExecute ecpg_expr ECPGPrepare +%type storage_clause opt_initializer c_anything blockstart +%type blockend variable_list variable c_thing c_term %type opt_pointer cvariable ECPGDisconnect dis_name %type stmt symbol opt_symbol ECPGRelease execstring server_name -%type connection_object opt_server opt_port c_thing opt_reference +%type connection_object opt_server opt_port c_stuff opt_reference %type user_name opt_user char_variable ora_user ident -%type db_prefix server opt_options opt_connection_name -%type ECPGSetConnection c_line cpp_line s_enum ECPGTypedef +%type db_prefix server opt_options opt_connection_name c_list +%type ECPGSetConnection cpp_line s_enum ECPGTypedef c_args %type enum_type civariableonly ECPGCursorStmt ECPGDeallocate %type ECPGFree ECPGDeclare ECPGVar sql_variable_declarations %type sql_declaration sql_variable_list sql_variable opt_at @@ -882,6 +882,7 @@ opt_at: SQL_AT connection_target { connection = $2; } stmt: AddAttrStmt { output_statement($1, 0); } | AlterUserStmt { output_statement($1, 0); } | ClosePortalStmt { output_statement($1, 0); } + | CommentStmt { output_statement($1, 0); } | CopyStmt { output_statement($1, 0); } | CreateStmt { output_statement($1, 0); } | CreateAsStmt { output_statement($1, 0); } @@ -1892,7 +1893,23 @@ opt_portal_name: IN name { $$ = cat2_str(make1_str("in"), $2); } | /*EMPTY*/ { $$ = make1_str(""); } ; - +/***************************************************************************** + * + * QUERY: + * comment on [ table | column .struct_member_list); } -enum_type: s_enum '{' c_line '}' +enum_type: s_enum '{' c_list '}' { $$ = cat4_str($1, make1_str("{"), $3, make1_str("}")); } @@ -4828,7 +4846,7 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer } opt_initializer: /* empty */ { $$ = make1_str(""); } - | '=' vartext { $$ = make2_str(make1_str("="), $2); } + | '=' c_term { $$ = make2_str(make1_str("="), $2); } opt_pointer: /* empty */ { $$ = make1_str(""); } | '*' { $$ = make1_str("*"); } @@ -5367,7 +5385,7 @@ action : SQL_CONTINUE { $$.command = strdup($3); $$.str = cat2_str(make1_str("goto "), $3); } - | DO name '(' dotext ')' { + | DO name '(' c_args ')' { $$.code = W_DO; $$.command = make4_str($2, make1_str("("), $4, make1_str(")")); $$.str = cat2_str(make1_str("do"), mm_strdup($$.command)); @@ -5377,7 +5395,7 @@ action : SQL_CONTINUE { $$.command = NULL; $$.str = make1_str("break"); } - | SQL_CALL name '(' dotext ')' { + | SQL_CALL name '(' c_args ')' { $$.code = W_DO; $$.command = make4_str($2, make1_str("("), $4, make1_str(")")); $$.str = cat2_str(make1_str("call"), mm_strdup($$.command)); @@ -5726,11 +5744,8 @@ into_list : coutputvariable | into_list ',' coutputvariable; ecpgstart: SQL_START { reset_variables();} -dotext: /* empty */ { $$ = make1_str(""); } - | dotext do_anything { $$ = make2_str($1, $2); } - -vartext: var_anything { $$ = $1; } - | vartext var_anything { $$ = make2_str($1, $2); } +c_args: /* empty */ { $$ = make1_str(""); } + | c_list { $$ = $1; } coutputvariable : cvariable indicator { add_variable(&argsresult, find_variable($1), ($2 == NULL) ? &no_indicator : find_variable($2)); @@ -5754,6 +5769,7 @@ indicator: /* empty */ { $$ = NULL; } ident: IDENT { $$ = $1; } | CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }; + /* * C stuff */ @@ -5762,13 +5778,27 @@ symbol: IDENT { $$ = $1; } cpp_line: CPP_LINE { $$ = $1; } -c_line: c_anything { $$ = $1; } - | c_line c_anything - { - $$ = make2_str($1, $2); - } +c_stuff: c_anything { $$ = $1; } + | c_stuff c_anything + { + $$ = cat2_str($1, $2); + } + | c_stuff '(' c_stuff ')' + { + $$ = cat4_str($1, make1_str("("), $3, make1_str(")")); + } + +c_list: c_term { $$ = $1; } + | c_term ',' c_list { $$ = make3_str($1, make1_str(","), $3); } + +c_term: c_stuff { $$ = $1; } + | '{' c_list '}' { $$ = make3_str(make1_str("{"), $2, make1_str("}")); } -c_thing: c_anything | ';' { $$ = make1_str(";"); } +c_thing: c_anything { $$ = $1; } + | '(' { $$ = make1_str("("); } + | ')' { $$ = make1_str(")"); } + | ',' { $$ = make1_str(","); } + | ';' { $$ = make1_str(";"); } c_anything: IDENT { $$ = $1; } | CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); } @@ -5800,22 +5830,9 @@ c_anything: IDENT { $$ = $1; } | S_ANYTHING { $$ = make_name(); } | '[' { $$ = make1_str("["); } | ']' { $$ = make1_str("]"); } - | '(' { $$ = make1_str("("); } - | ')' { $$ = make1_str(")"); } +/* | '(' { $$ = make1_str("("); } + | ')' { $$ = make1_str(")"); }*/ | '=' { $$ = make1_str("="); } - | ',' { $$ = make1_str(","); } - -do_anything: IDENT { $$ = $1; } - | CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\""));} - | Iconst { $$ = $1; } - | Fconst { $$ = $1; } - | ',' { $$ = make1_str(","); } - -var_anything: IDENT { $$ = $1; } - | CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); } - | Iconst { $$ = $1; } - | Fconst { $$ = $1; } - | '{' c_line '}' { $$ = make3_str(make1_str("{"), $2, make1_str("}")); } blockstart : '{' { braces_open++; -- 2.40.0