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 $ */
2
2
3
3
/* Copyright comment */
4
4
%{
@@ -47,7 +47,15 @@ static struct inf_compat_val
47
47
char *val;
48
48
struct inf_compat_val *next;
49
49
} *informix_val;
50
-
50
+
51
+ void mm (void )
52
+ {
53
+ int i,j;
54
+
55
+ i=1 ;
56
+ j=i+1 ;
57
+ }
58
+
51
59
/*
52
60
* Handle parsing errors and warnings
53
61
*/
@@ -367,7 +375,7 @@ create_questionmarks(char *name, bool array)
367
375
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
368
376
%type <str> FetchStmt from_in CreateOpClassStmt
369
377
%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
371
379
%type <str> analyze_keyword opt_name_list ExplainStmt index_params
372
380
%type <str> index_elem opt_class access_method_clause
373
381
%type <str> index_opt_unique IndexStmt func_return ConstInterval
@@ -424,7 +432,7 @@ create_questionmarks(char *name, bool array)
424
432
%type <str> opt_sort_clause transaction_access_mode
425
433
426
434
%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
428
436
%type <str> storage_declaration storage_clause opt_initializer c_anything
429
437
%type <str> variable_list variable c_thing c_term ECPGKeywords_vanames
430
438
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
@@ -433,18 +441,19 @@ create_questionmarks(char *name, bool array)
433
441
%type <str> user_name opt_user char_variable ora_user ident opt_reference
434
442
%type <str> var_type_declarations quoted_ident_stringvar ECPGKeywords_rest
435
443
%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
437
445
%type <str> enum_type civar civarind ECPGCursorStmt ECPGDeallocate
438
446
%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
440
448
%type <str> var_declaration type_declaration single_vt_declaration
441
449
%type <str> ECPGSetAutocommit on_off variable_declarations ECPGDescribe
442
450
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_output
443
451
%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
445
453
%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
447
455
%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
456
+ %type <str> ecpg_into_using
448
457
449
458
%type <struct_union> s_struct_union_symbol
450
459
@@ -664,6 +673,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
664
673
struct cursor *ptr;
665
674
struct arguments *p;
666
675
676
+ mm ();
667
677
for (ptr = cur; ptr != NULL ; ptr=ptr->next)
668
678
{
669
679
if (strcmp(ptr->name, $1 ) == 0 )
@@ -1729,9 +1739,9 @@ TruncateStmt: TRUNCATE opt_table qualified_name
1729
1739
*
1730
1740
*****************************************************************************/
1731
1741
1732
- FetchStmt : FETCH fetch_direction from_in name ecpg_into
1742
+ FetchStmt : FETCH fetch_direction from_in name ecpg_into_using
1733
1743
{ $$ = cat_str(4 , make_str(" fetch" ), $2 , $3 , $4 ); }
1734
- | FETCH name ecpg_into
1744
+ | FETCH name ecpg_into_using
1735
1745
{ $$ = cat2_str(make_str(" fetch" ), $2 ); }
1736
1746
| MOVE fetch_direction from_in name
1737
1747
{ $$ = cat_str(4 , make_str(" move" ), $2 , $3 , $4 ); }
@@ -2622,6 +2632,7 @@ DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
2622
2632
this = (struct cursor *) mm_alloc(sizeof (struct cursor ));
2623
2633
2624
2634
/* initial definition */
2635
+ mm ();
2625
2636
this ->next = cur;
2626
2637
this ->name = $2 ;
2627
2638
this ->connection = connection;
@@ -2698,7 +2709,7 @@ into_clause: INTO OptTempTableName
2698
2709
FoundInto = 1 ;
2699
2710
$$ = cat2_str(make_str(" into" ), $2 );
2700
2711
}
2701
- | ecpg_into { $$ = EMPTY; }
2712
+ | ecpg_into_using { $$ = EMPTY; }
2702
2713
| /* EMPTY*/ { $$ = EMPTY; }
2703
2714
;
2704
2715
@@ -4333,6 +4344,7 @@ opt_scale: ',' NumConst { $$ = $2; }
4333
4344
4334
4345
ecpg_interval : opt_interval { $$ = $1 ; }
4335
4346
| YEAR_P TO MINUTE_P { $$ = make_str(" year to minute" ); }
4347
+ | YEAR_P TO SECOND_P { $$ = make_str(" year to second" ); }
4336
4348
| DAY_P TO DAY_P { $$ = make_str(" day to day" ); }
4337
4349
| MONTH_P TO MONTH_P { $$ = make_str(" month to month" ); }
4338
4350
;
@@ -5116,12 +5128,19 @@ ECPGExecute : EXECUTE IMMEDIATE execstring
5116
5128
5117
5129
add_variable (&argsinsert, thisquery, &no_indicator);
5118
5130
}
5119
- opt_ecpg_using opt_ecpg_into
5131
+ execute_rest
5120
5132
{
5121
5133
$$ = make_str(" ?" );
5122
5134
}
5123
5135
;
5124
5136
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
+
5125
5144
execstring : char_variable
5126
5145
{ $$ = $1 ; }
5127
5146
| CSTRING
@@ -5140,7 +5159,10 @@ ECPGFree: SQL_FREE name { $$ = $2; };
5140
5159
ECPGOpen : SQL_OPEN name opt_ecpg_using { $$ = $2 ; };
5141
5160
5142
5161
opt_ecpg_using : /* EMPTY*/ { $$ = EMPTY; }
5143
- | USING variablelist { $$ = EMPTY; }
5162
+ | ecpg_using { $$ = $1 ; }
5163
+ ;
5164
+
5165
+ ecpg_using : USING using_list { $$ = EMPTY; }
5144
5166
;
5145
5167
5146
5168
using_descriptor : USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
@@ -5159,19 +5181,15 @@ into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
5159
5181
5160
5182
opt_sql : /* EMPTY*/ | SQL_SQL ;
5161
5183
5162
- ecpg_into : INTO into_list { $$ = EMPTY; }
5163
- | into_descriptor { $$ = $1 ; }
5184
+ ecpg_into_using : ecpg_into { $$ = EMPTY; }
5164
5185
| using_descriptor { $$ = $1 ; }
5165
5186
;
5166
5187
5167
- opt_ecpg_into : /* EMPTY*/ { $$ = EMPTY; }
5168
- | INTO into_list { $$ = EMPTY; }
5188
+ ecpg_into : INTO into_list { $$ = EMPTY; }
5169
5189
| into_descriptor { $$ = $1 ; }
5170
5190
;
5171
-
5172
- c_variable : civarind | civar ;
5173
-
5174
- variablelist : c_variable | c_variable ' ,' variablelist ;
5191
+
5192
+ using_list : civar | civar ' ,' using_list ;
5175
5193
5176
5194
/*
5177
5195
* As long as the prepare statement is not supported by the backend, we will
@@ -5186,19 +5204,22 @@ ECPGPrepare: PREPARE name FROM execstring
5186
5204
* We accept descibe but do nothing with it so far.
5187
5205
*/
5188
5206
ECPGDescribe : SQL_DESCRIBE INPUT_P name using_descriptor
5189
- {
5207
+ {
5190
5208
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 );
5192
5211
}
5193
5212
| SQL_DESCRIBE opt_output name using_descriptor
5194
5213
{
5195
5214
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 );
5197
5217
}
5198
5218
| SQL_DESCRIBE opt_output name into_descriptor
5199
5219
{
5200
5220
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 );
5202
5223
}
5203
5224
;
5204
5225
@@ -6076,55 +6097,60 @@ c_thing: c_anything { $$ = $1; }
6076
6097
| ' ;' { $$ = make_str(" ;" ); }
6077
6098
;
6078
6099
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(" =" ); }
6128
6154
;
6129
6155
6130
6156
%%
0 commit comments