Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 65058fc

Browse files
author
Michael Meskes
committed
Fixed some bugs.
1 parent 412893b commit 65058fc

File tree

3 files changed

+110
-74
lines changed

3 files changed

+110
-74
lines changed

src/interfaces/ecpg/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,10 @@ Fri May 30 15:19:39 CEST 2003
14731473
Mon Jun 2 17:36:03 CEST 2003
14741474

14751475
- Fixed segfault in forward definition parsing.
1476+
1477+
Tue Jun 10 19:43:49 CEST 2003
1478+
1479+
- Fixed several small bugs.
14761480
- Set ecpg version to 2.12.0.
14771481
- Set ecpg library to 3.4.2.
14781482
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/preproc/c_keywords.c

+6
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@ static ScanKeyword ScanKeywords[] = {
2828
{"enum", SQL_ENUM},
2929
{"extern", S_EXTERN},
3030
{"float", FLOAT_P},
31+
{"hour", HOUR_P},
3132
{"int", INT_P},
3233
{"long", SQL_LONG},
34+
{"minute", MINUTE_P},
35+
{"month", MONTH_P},
3336
{"register", S_REGISTER},
37+
{"second", SECOND_P},
3438
{"short", SQL_SHORT},
3539
{"signed", SQL_SIGNED},
3640
{"static", S_STATIC},
3741
{"struct", SQL_STRUCT},
42+
{"to", TO},
3843
{"typedef", S_TYPEDEF},
3944
{"union", UNION},
4045
{"unsigned", SQL_UNSIGNED},
4146
{"varchar", VARCHAR},
4247
{"volatile", S_VOLATILE},
48+
{"year", YEAR_P},
4349
};
4450

4551
ScanKeyword *

src/interfaces/ecpg/preproc/preproc.y

+100-74
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.228 2003/06/02 15:38:02 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.229 2003/06/10 17:46:43 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -47,7 +47,15 @@ static struct inf_compat_val
4747
char *val;
4848
struct inf_compat_val *next;
4949
} *informix_val;
50-
50+
51+
void mm(void)
52+
{
53+
int i,j;
54+
55+
i=1;
56+
j=i+1;
57+
}
58+
5159
/*
5260
* Handle parsing errors and warnings
5361
*/
@@ -367,7 +375,7 @@ create_questionmarks(char *name, bool array)
367375
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
368376
%type <str> FetchStmt from_in CreateOpClassStmt
369377
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
370-
%type <str> opt_full func_arg OptWithOids opt_freeze opt_ecpg_into
378+
%type <str> opt_full func_arg OptWithOids opt_freeze
371379
%type <str> analyze_keyword opt_name_list ExplainStmt index_params
372380
%type <str> index_elem opt_class access_method_clause
373381
%type <str> index_opt_unique IndexStmt func_return ConstInterval
@@ -424,7 +432,7 @@ create_questionmarks(char *name, bool array)
424432
%type <str> opt_sort_clause transaction_access_mode
425433

426434
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
427-
%type <str> indicator ECPGExecute ECPGPrepare opt_ecpg_using ecpg_into
435+
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using ecpg_into
428436
%type <str> storage_declaration storage_clause opt_initializer c_anything
429437
%type <str> variable_list variable c_thing c_term ECPGKeywords_vanames
430438
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
@@ -433,18 +441,19 @@ create_questionmarks(char *name, bool array)
433441
%type <str> user_name opt_user char_variable ora_user ident opt_reference
434442
%type <str> var_type_declarations quoted_ident_stringvar ECPGKeywords_rest
435443
%type <str> db_prefix server opt_options opt_connection_name c_list
436-
%type <str> ECPGSetConnection ECPGTypedef c_args ECPGKeywords
444+
%type <str> ECPGSetConnection ECPGTypedef c_args ECPGKeywords
437445
%type <str> enum_type civar civarind ECPGCursorStmt ECPGDeallocate
438446
%type <str> ECPGFree ECPGDeclare ECPGVar opt_at enum_definition
439-
%type <str> struct_union_type s_struct_union vt_declarations
447+
%type <str> struct_union_type s_struct_union vt_declarations execute_rest
440448
%type <str> var_declaration type_declaration single_vt_declaration
441449
%type <str> ECPGSetAutocommit on_off variable_declarations ECPGDescribe
442450
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_output
443451
%type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration
444-
%type <str> reserved_keyword unreserved_keyword ecpg_interval
452+
%type <str> reserved_keyword unreserved_keyword ecpg_interval opt_ecpg_using
445453
%type <str> col_name_keyword func_name_keyword precision opt_scale
446-
%type <str> ECPGTypeName variablelist ECPGColLabelCommon c_variable
454+
%type <str> ECPGTypeName using_list ECPGColLabelCommon
447455
%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
456+
%type <str> ecpg_into_using
448457

449458
%type <struct_union> s_struct_union_symbol
450459

@@ -664,6 +673,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
664673
struct cursor *ptr;
665674
struct arguments *p;
666675

676+
mm();
667677
for (ptr = cur; ptr != NULL; ptr=ptr->next)
668678
{
669679
if (strcmp(ptr->name, $1) == 0)
@@ -1729,9 +1739,9 @@ TruncateStmt: TRUNCATE opt_table qualified_name
17291739
*
17301740
*****************************************************************************/
17311741

1732-
FetchStmt: FETCH fetch_direction from_in name ecpg_into
1742+
FetchStmt: FETCH fetch_direction from_in name ecpg_into_using
17331743
{ $$ = cat_str(4, make_str("fetch"), $2, $3, $4); }
1734-
| FETCH name ecpg_into
1744+
| FETCH name ecpg_into_using
17351745
{ $$ = cat2_str(make_str("fetch"), $2); }
17361746
| MOVE fetch_direction from_in name
17371747
{ $$ = cat_str(4, make_str("move"), $2, $3, $4); }
@@ -2622,6 +2632,7 @@ DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
26222632
this = (struct cursor *) mm_alloc(sizeof(struct cursor));
26232633

26242634
/* initial definition */
2635+
mm();
26252636
this->next = cur;
26262637
this->name = $2;
26272638
this->connection = connection;
@@ -2698,7 +2709,7 @@ into_clause: INTO OptTempTableName
26982709
FoundInto = 1;
26992710
$$= cat2_str(make_str("into"), $2);
27002711
}
2701-
| ecpg_into { $$ = EMPTY; }
2712+
| ecpg_into_using { $$ = EMPTY; }
27022713
| /*EMPTY*/ { $$ = EMPTY; }
27032714
;
27042715

@@ -4333,6 +4344,7 @@ opt_scale: ',' NumConst { $$ = $2; }
43334344

43344345
ecpg_interval: opt_interval { $$ = $1; }
43354346
| YEAR_P TO MINUTE_P { $$ = make_str("year to minute"); }
4347+
| YEAR_P TO SECOND_P { $$ = make_str("year to second"); }
43364348
| DAY_P TO DAY_P { $$ = make_str("day to day"); }
43374349
| MONTH_P TO MONTH_P { $$ = make_str("month to month"); }
43384350
;
@@ -5116,12 +5128,19 @@ ECPGExecute : EXECUTE IMMEDIATE execstring
51165128

51175129
add_variable(&argsinsert, thisquery, &no_indicator);
51185130
}
5119-
opt_ecpg_using opt_ecpg_into
5131+
execute_rest
51205132
{
51215133
$$ = make_str("?");
51225134
}
51235135
;
51245136

5137+
execute_rest: ecpg_using ecpg_into { $$ = EMPTY; }
5138+
| ecpg_into ecpg_using { $$ = EMPTY; }
5139+
| ecpg_using { $$ = EMPTY; }
5140+
| ecpg_into { $$ = EMPTY; }
5141+
| /* EMPTY */ { $$ = EMPTY; }
5142+
;
5143+
51255144
execstring: char_variable
51265145
{ $$ = $1; }
51275146
| CSTRING
@@ -5140,7 +5159,10 @@ ECPGFree: SQL_FREE name { $$ = $2; };
51405159
ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; };
51415160

51425161
opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
5143-
| USING variablelist { $$ = EMPTY; }
5162+
| ecpg_using { $$ = $1; }
5163+
;
5164+
5165+
ecpg_using: USING using_list { $$ = EMPTY; }
51445166
;
51455167

51465168
using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
@@ -5159,19 +5181,15 @@ into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
51595181

51605182
opt_sql: /*EMPTY*/ | SQL_SQL;
51615183

5162-
ecpg_into: INTO into_list { $$ = EMPTY; }
5163-
| into_descriptor { $$ = $1; }
5184+
ecpg_into_using: ecpg_into { $$ = EMPTY; }
51645185
| using_descriptor { $$ = $1; }
51655186
;
51665187

5167-
opt_ecpg_into: /*EMPTY*/ { $$ = EMPTY; }
5168-
| INTO into_list { $$ = EMPTY; }
5188+
ecpg_into: INTO into_list { $$ = EMPTY; }
51695189
| into_descriptor { $$ = $1; }
51705190
;
5171-
5172-
c_variable: civarind | civar;
5173-
5174-
variablelist: c_variable | c_variable ',' variablelist;
5191+
5192+
using_list: civar | civar ',' using_list;
51755193

51765194
/*
51775195
* As long as the prepare statement is not supported by the backend, we will
@@ -5186,19 +5204,22 @@ ECPGPrepare: PREPARE name FROM execstring
51865204
* We accept descibe but do nothing with it so far.
51875205
*/
51885206
ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
5189-
{
5207+
{
51905208
mmerror(PARSE_ERROR, ET_WARNING, "using unsupported describe statement.\n");
5191-
$$ = cat_str(3, make_str("1, ECPGprepared_statement(\""), $3, make_str("\")"));
5209+
$$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(\"\")") + strlen($3));
5210+
sprintf($$, "1, ECPGprepared_statement(\"%s\")", $3);
51925211
}
51935212
| SQL_DESCRIBE opt_output name using_descriptor
51945213
{
51955214
mmerror(PARSE_ERROR, ET_WARNING, "using unsupported describe statement.\n");
5196-
$$ = cat_str(3, make_str("0, ECPGprepared_statement(\""), $3, make_str("\")"));
5215+
$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(\"\")") + strlen($3));
5216+
sprintf($$, "0, ECPGprepared_statement(\"%s\")", $3);
51975217
}
51985218
| SQL_DESCRIBE opt_output name into_descriptor
51995219
{
52005220
mmerror(PARSE_ERROR, ET_WARNING, "using unsupported describe statement.\n");
5201-
$$ = cat_str(3, make_str("0, ECPGprepared_statement(\""), $3, make_str("\")"));
5221+
$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(\"\")") + strlen($3));
5222+
sprintf($$, "0, ECPGprepared_statement(\"%s\")", $3);
52025223
}
52035224
;
52045225

@@ -6076,55 +6097,60 @@ c_thing: c_anything { $$ = $1; }
60766097
| ';' { $$ = make_str(";"); }
60776098
;
60786099

6079-
c_anything: IDENT { $$ = $1; }
6080-
| CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
6081-
| Iconst { $$ = $1; }
6082-
| Fconst { $$ = $1; }
6083-
| Sconst { $$ = $1; }
6084-
| '*' { $$ = make_str("*"); }
6085-
| '+' { $$ = make_str("+"); }
6086-
| '-' { $$ = make_str("-"); }
6087-
| '/' { $$ = make_str("/"); }
6088-
| '%' { $$ = make_str("%"); }
6089-
| NULL_P { $$ = make_str("NULL"); }
6090-
| S_ADD { $$ = make_str("+="); }
6091-
| S_AND { $$ = make_str("&&"); }
6092-
| S_ANYTHING { $$ = make_name(); }
6093-
| S_AUTO { $$ = make_str("auto"); }
6094-
| S_CONST { $$ = make_str("const"); }
6095-
| S_DEC { $$ = make_str("--"); }
6096-
| S_DIV { $$ = make_str("/="); }
6097-
| S_DOTPOINT { $$ = make_str(".*"); }
6098-
| S_EQUAL { $$ = make_str("=="); }
6099-
| S_EXTERN { $$ = make_str("extern"); }
6100-
| S_INC { $$ = make_str("++"); }
6101-
| S_LSHIFT { $$ = make_str("<<"); }
6102-
| S_MEMBER { $$ = make_str("->"); }
6103-
| S_MEMPOINT { $$ = make_str("->*"); }
6104-
| S_MOD { $$ = make_str("%="); }
6105-
| S_MUL { $$ = make_str("*="); }
6106-
| S_NEQUAL { $$ = make_str("!="); }
6107-
| S_OR { $$ = make_str("||"); }
6108-
| S_REGISTER { $$ = make_str("register"); }
6109-
| S_RSHIFT { $$ = make_str(">>"); }
6110-
| S_STATIC { $$ = make_str("static"); }
6111-
| S_SUB { $$ = make_str("-="); }
6112-
| S_TYPEDEF { $$ = make_str("typedef"); }
6113-
| SQL_BOOL { $$ = make_str("bool"); }
6114-
| SQL_ENUM { $$ = make_str("enum"); }
6115-
| INT_P { $$ = make_str("int"); }
6116-
| SQL_LONG { $$ = make_str("long"); }
6117-
| SQL_SHORT { $$ = make_str("short"); }
6118-
| SQL_SIGNED { $$ = make_str("signed"); }
6119-
| SQL_STRUCT { $$ = make_str("struct"); }
6120-
| SQL_UNSIGNED { $$ = make_str("unsigned"); }
6121-
| CHAR_P { $$ = make_str("char"); }
6122-
| FLOAT_P { $$ = make_str("float"); }
6123-
| UNION { $$ = make_str("union"); }
6124-
| VARCHAR { $$ = make_str("varchar"); }
6125-
| '[' { $$ = make_str("["); }
6126-
| ']' { $$ = make_str("]"); }
6127-
| '=' { $$ = make_str("="); }
6100+
c_anything: IDENT { $$ = $1; }
6101+
| CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
6102+
| Iconst { $$ = $1; }
6103+
| Fconst { $$ = $1; }
6104+
| Sconst { $$ = $1; }
6105+
| '*' { $$ = make_str("*"); }
6106+
| '+' { $$ = make_str("+"); }
6107+
| '-' { $$ = make_str("-"); }
6108+
| '/' { $$ = make_str("/"); }
6109+
| '%' { $$ = make_str("%"); }
6110+
| NULL_P { $$ = make_str("NULL"); }
6111+
| S_ADD { $$ = make_str("+="); }
6112+
| S_AND { $$ = make_str("&&"); }
6113+
| S_ANYTHING { $$ = make_name(); }
6114+
| S_AUTO { $$ = make_str("auto"); }
6115+
| S_CONST { $$ = make_str("const"); }
6116+
| S_DEC { $$ = make_str("--"); }
6117+
| S_DIV { $$ = make_str("/="); }
6118+
| S_DOTPOINT { $$ = make_str(".*"); }
6119+
| S_EQUAL { $$ = make_str("=="); }
6120+
| S_EXTERN { $$ = make_str("extern"); }
6121+
| S_INC { $$ = make_str("++"); }
6122+
| S_LSHIFT { $$ = make_str("<<"); }
6123+
| S_MEMBER { $$ = make_str("->"); }
6124+
| S_MEMPOINT { $$ = make_str("->*"); }
6125+
| S_MOD { $$ = make_str("%="); }
6126+
| S_MUL { $$ = make_str("*="); }
6127+
| S_NEQUAL { $$ = make_str("!="); }
6128+
| S_OR { $$ = make_str("||"); }
6129+
| S_REGISTER { $$ = make_str("register"); }
6130+
| S_RSHIFT { $$ = make_str(">>"); }
6131+
| S_STATIC { $$ = make_str("static"); }
6132+
| S_SUB { $$ = make_str("-="); }
6133+
| S_TYPEDEF { $$ = make_str("typedef"); }
6134+
| SQL_BOOL { $$ = make_str("bool"); }
6135+
| SQL_ENUM { $$ = make_str("enum"); }
6136+
| HOUR_P { $$ = make_str("hour"); }
6137+
| INT_P { $$ = make_str("int"); }
6138+
| SQL_LONG { $$ = make_str("long"); }
6139+
| MINUTE_P { $$ = make_str("minute"); }
6140+
| MONTH_P { $$ = make_str("month"); }
6141+
| SECOND_P { $$ = make_str("second"); }
6142+
| SQL_SHORT { $$ = make_str("short"); }
6143+
| SQL_SIGNED { $$ = make_str("signed"); }
6144+
| SQL_STRUCT { $$ = make_str("struct"); }
6145+
| SQL_UNSIGNED { $$ = make_str("unsigned"); }
6146+
| YEAR_P { $$ = make_str("year"); }
6147+
| CHAR_P { $$ = make_str("char"); }
6148+
| FLOAT_P { $$ = make_str("float"); }
6149+
| UNION { $$ = make_str("union"); }
6150+
| VARCHAR { $$ = make_str("varchar"); }
6151+
| '[' { $$ = make_str("["); }
6152+
| ']' { $$ = make_str("]"); }
6153+
| '=' { $$ = make_str("="); }
61286154
;
61296155

61306156
%%

0 commit comments

Comments
 (0)