From: Michael Meskes Date: Thu, 13 Feb 2003 20:37:28 +0000 (+0000) Subject: Just intermediate results for backup reasons. X-Git-Tag: REL9_0_0~15782 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=53c15ceda0e84d3d592d653fda29af03ef5ffc77;p=pg-rex%2Fsyncrep.git Just intermediate results for backup reasons. --- diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 0ff7900c68..44e22f5cc0 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.102 2003/02/13 13:11:52 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.103 2003/02/13 20:37:28 meskes Exp $ * *------------------------------------------------------------------------- */ @@ -831,7 +831,16 @@ cppline {space}*#(.*\\{space})*.* i > 0 && isspace((unsigned char) yytext[i]); i-- ) {} - yytext[i+1] = '\0'; + + /* Remove trailing '"' if it exists */ + if (yytext[i] == '"') + yytext[i] = '\0'; + else + yytext[i+1] = '\0'; + + /* also remove starting '"' */ + if (yytext[0] == '"') + memmove(yytext, yytext+1, strlen(yytext)); yyin = NULL; for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next) diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index e1e374cd69..3d407f1cac 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.206 2003/01/21 20:01:12 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.207 2003/02/13 20:37:28 meskes Exp $ */ /* Copyright comment */ %{ @@ -376,7 +376,7 @@ make_name(void) %type storage_clause opt_initializer c_anything %type variable_list variable c_thing c_term %type opt_pointer ECPGDisconnect dis_name storage_modifier -%type stmt ECPGRelease execstring server_name +%type ECPGRelease execstring server_name ECPGVarDeclaration %type connection_object opt_server opt_port c_stuff c_stuff_item %type user_name opt_user char_variable ora_user ident opt_reference %type var_type_declarations quoted_ident_stringvar @@ -385,13 +385,13 @@ make_name(void) %type enum_type civar civarind ECPGCursorStmt ECPGDeallocate %type ECPGFree ECPGDeclare ECPGVar opt_at enum_definition %type struct_type s_struct vt_declarations variable_declarations -%type var_declaration type_declaration +%type var_declaration type_declaration single_vt_declaration %type s_union union_type ECPGSetAutocommit on_off %type ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol -%type ECPGGetDescriptorHeader ECPGColLabel +%type ECPGGetDescriptorHeader ECPGColLabel single_var_declaration %type reserved_keyword unreserved_keyword %type col_name_keyword func_name_keyword -%type ECPGTypeName variablelist +%type ECPGTypeName variablelist ECPGColLabelCommon %type ECPGGetDescriptor @@ -399,7 +399,7 @@ make_name(void) %type descriptor_item desc_header_item -%type type +%type type common_type single_vt_type %type action @@ -652,6 +652,12 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } output_simple_statement($1); } + | ECPGVarDeclaration + { + fprintf(yyout, "%s", $1); + free($1); + output_line_number(); + } | ECPGWhenever { if (connection) @@ -4125,8 +4131,89 @@ ECPGDeallocate: DEALLOCATE PREPARE ident { $$ = cat_str(2, make_str("ECPGdeallocate(__LINE__, \""), $2, make_str("\");")); } ; +/* + * variable decalartion outside exec sql declare block + */ +ECPGVarDeclaration: single_vt_declaration; + +single_vt_declaration: type_declaration { $$ = $1; } + | single_var_declaration { $$ = $1; } + ; + +single_var_declaration: storage_clause storage_modifier + { + actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2)); + actual_startline[struct_level] = hashline_number(); + } + single_vt_type + { + actual_type[struct_level].type_enum = $4.type_enum; + actual_type[struct_level].type_dimension = $4.type_dimension; + actual_type[struct_level].type_index = $4.type_index; + actual_type[struct_level].type_sizeof = $4.type_sizeof; + + /* we do not need the string "varchar" for output */ + /* so replace it with an empty string */ + if ($4.type_enum == ECPGt_varchar) + { + free($4.type_str); + $4.type_str=EMPTY; + } + } + variable_list + { + $$ = cat_str(6, actual_startline[struct_level], $1, $2, $4.type_str, $6, make_str(";\n")); + } + ; + +single_vt_type: common_type + | ECPGColLabelCommon + { + /* + * Check for type names that the SQL grammar treats as + * unreserved keywords + */ + if (strcmp($1, "varchar") == 0) + { + $$.type_enum = ECPGt_varchar; + $$.type_str = make_str("varchar"); + $$.type_dimension = -1; + $$.type_index = -1; + $$.type_sizeof = NULL; + } + else if (strcmp($1, "float") == 0) + { + $$.type_enum = ECPGt_float; + $$.type_str = make_str("float"); + $$.type_dimension = -1; + $$.type_index = -1; + $$.type_sizeof = NULL; + } + else if (strcmp($1, "double") == 0) + { + $$.type_enum = ECPGt_double; + $$.type_str = make_str("double"); + $$.type_dimension = -1; + $$.type_index = -1; + $$.type_sizeof = NULL; + } + else + { + /* this is for typedef'ed types */ + struct typedefs *this = get_typedef($1); + + $$.type_str = (this->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this->name); + $$.type_enum = this->type->type_enum; + $$.type_dimension = this->type->type_dimension; + $$.type_index = this->type->type_index; + $$.type_sizeof = this->type->type_sizeof; + struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list); + } + } + ; + /* - * variable declaration inside the exec sql declare block + * variable declaration inside exec sql declare block */ ECPGDeclaration: sql_startdeclare { fputs("/* exec sql begin declare section */", yyout); } @@ -4256,7 +4343,7 @@ storage_modifier : S_CONST { $$ = make_str("const"); } | /*EMPTY*/ { $$ = EMPTY; } ; -type: simple_type +common_type: simple_type { $$.type_enum = $1; $$.type_str = mm_strdup(ECPGtype_name($1)); @@ -4288,6 +4375,9 @@ type: simple_type $$.type_index = -1; $$.type_sizeof = NULL; } + ; + +type: common_type | ECPGColLabel { /* @@ -5108,15 +5198,17 @@ ColLabel: ECPGColLabel { $$ = $1; } | UNION { $$ = make_str("union"); } ; -ECPGColLabel: ident { $$ = $1; } +ECPGColLabelCommon: ident { $$ = $1; } + | col_name_keyword { $$ = $1; } + | func_name_keyword { $$ = $1; } + ; + +ECPGColLabel: ECPGColLabelCommon { $$ = $1; } | unreserved_keyword { $$ = $1; } - | col_name_keyword { $$ = $1; } - | func_name_keyword { $$ = $1; } - | reserved_keyword { $$ = $1; } - | ECPGKeywords { $$ = $1; } + | reserved_keyword { $$ = $1; } + | ECPGKeywords { $$ = $1; } ; - /* * Keyword classification lists. Generally, every keyword present in * the Postgres grammar should appear in exactly one of these lists.