@@ -654,12 +654,12 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
654
654
}
655
655
656
656
/* special embedded SQL token */
657
- %token SQL_AT SQL_BOOL SQL_BREAK
657
+ %token SQL_AT SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
658
658
%token SQL_CALL SQL_CONNECT SQL_CONNECTION SQL_CONTINUE
659
659
%token SQL_DEALLOCATE SQL_DISCONNECT SQL_ENUM
660
660
%token SQL_FOUND SQL_FREE SQL_GO SQL_GOTO
661
661
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_INT SQL_LONG
662
- %token SQL_OPEN SQL_PREPARE SQL_RELEASE SQL_REFERENCE
662
+ %token SQL_OFF SQL_OPEN SQL_PREPARE SQL_RELEASE SQL_REFERENCE
663
663
%token SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQLERROR SQL_SQLPRINT
664
664
%token SQL_SQLWARNING SQL_START SQL_STOP SQL_STRUCT SQL_UNSIGNED
665
665
%token SQL_VAR SQL_WHENEVER
@@ -831,7 +831,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
831
831
%type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
832
832
%type <str> sql_declaration sql_variable_list sql_variable opt_at
833
833
%type <str> struct_type s_struct declaration variable_declarations
834
- %type <str> s_struct s_union union_type
834
+ %type <str> s_struct s_union union_type ECPGSetAutocommit on_off
835
835
836
836
%type <type_enum> simple_type varchar_type
837
837
@@ -842,6 +842,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
842
842
%type <index> opt_array_bounds nest_array_bounds opt_type_array_bounds
843
843
%type <index> nest_type_array_bounds
844
844
845
+ %type <ival> Iresult
845
846
%%
846
847
prog : statements ;
847
848
@@ -913,7 +914,7 @@ stmt: AddAttrStmt { output_statement($1, 0); }
913
914
if (connection)
914
915
yyerror (" no at option for connect statement.\n " );
915
916
916
- fprintf (yyout, " ECPGconnect(__LINE__, %s, %d);" , $1 , no_auto_trans );
917
+ fprintf (yyout, " ECPGconnect(__LINE__, %s, %d);" , $1 , autocommit );
917
918
whenever_action (0 );
918
919
free ($1 );
919
920
}
@@ -981,6 +982,11 @@ stmt: AddAttrStmt { output_statement($1, 0); }
981
982
free ($1 );
982
983
}
983
984
| ECPGRelease { /* output already done */ }
985
+ | ECPGSetAutocommit {
986
+ fprintf (yyout, " ECPGsetcommit(__LINE__, \" %s\" , %s);" , $1 , connection ? connection : " NULL" );
987
+ whenever_action (0 );
988
+ free ($1 );
989
+ }
984
990
| ECPGSetConnection {
985
991
if (connection)
986
992
yyerror (" no at option for set connection statement.\n " );
@@ -3170,11 +3176,14 @@ opt_array_bounds: '[' ']' nest_array_bounds
3170
3176
$$ .index2 = $3 .index1;
3171
3177
$$ .str = cat2_str(make1_str(" []" ), $3 .str);
3172
3178
}
3173
- | ' [' Iconst ' ]' nest_array_bounds
3179
+ | ' [' Iresult ' ]' nest_array_bounds
3174
3180
{
3175
- $$ .index1 = atol($2 );
3181
+ char *txt = mm_alloc(20L );
3182
+
3183
+ sprintf (txt, " %d" , $2 );
3184
+ $$ .index1 = $2 ;
3176
3185
$$ .index2 = $4 .index1;
3177
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
3186
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
3178
3187
}
3179
3188
| /* EMPTY */
3180
3189
{
@@ -3190,11 +3199,14 @@ nest_array_bounds: '[' ']' nest_array_bounds
3190
3199
$$ .index2 = $3 .index1;
3191
3200
$$ .str = cat2_str(make1_str(" []" ), $3 .str);
3192
3201
}
3193
- | ' [' Iconst ' ]' nest_array_bounds
3202
+ | ' [' Iresult ' ]' nest_array_bounds
3194
3203
{
3195
- $$ .index1 = atol($2 );
3204
+ char *txt = mm_alloc(20L );
3205
+
3206
+ sprintf (txt, " %d" , $2 );
3207
+ $$ .index1 = $2 ;
3196
3208
$$ .index2 = $4 .index1;
3197
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
3209
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
3198
3210
}
3199
3211
| /* EMPTY */
3200
3212
{
@@ -3204,6 +3216,16 @@ nest_array_bounds: '[' ']' nest_array_bounds
3204
3216
}
3205
3217
;
3206
3218
3219
+ Iresult : Iconst { $$ = atol($1 ); }
3220
+ | ' (' Iresult ' )' { $$ = $2 ; }
3221
+ | Iresult ' +' Iresult { $$ = $1 + $3 };
3222
+ | Iresult '-' Iresult { $$ = $1 - $3};
3223
+ | Iresult '*' Iresult { $$ = $1 * $3};
3224
+ | Iresult '/' Iresult { $$ = $1 / $3};
3225
+ | Iresult '%' Iresult { $$ = $1 % $3};
3226
+
3227
+
3228
+
3207
3229
/* ****************************************************************************
3208
3230
*
3209
3231
* Type syntax
@@ -3239,6 +3261,7 @@ Generic: generic
3239
3261
generic : ident { $$ = $1 ; }
3240
3262
| TYPE_P { $$ = make1_str(" type" ); }
3241
3263
| SQL_AT { $$ = make1_str(" at" ); }
3264
+ | SQL_AUTOCOMMIT { $$ = make1_str(" autocommit" ); }
3242
3265
| SQL_BOOL { $$ = make1_str(" bool" ); }
3243
3266
| SQL_BREAK { $$ = make1_str(" break" ); }
3244
3267
| SQL_CALL { $$ = make1_str(" call" ); }
@@ -3255,6 +3278,7 @@ generic: ident { $$ = $1; }
3255
3278
| SQL_INDICATOR { $$ = make1_str(" indicator" ); }
3256
3279
| SQL_INT { $$ = make1_str(" int" ); }
3257
3280
| SQL_LONG { $$ = make1_str(" long" ); }
3281
+ | SQL_OFF { $$ = make1_str(" off" ); }
3258
3282
| SQL_OPEN { $$ = make1_str(" open" ); }
3259
3283
| SQL_PREPARE { $$ = make1_str(" prepare" ); }
3260
3284
| SQL_RELEASE { $$ = make1_str(" release" ); }
@@ -4475,7 +4499,6 @@ ColId: ident { $$ = $1; }
4475
4499
| SQL_BREAK { $$ = make1_str(" break" ); }
4476
4500
| SQL_CALL { $$ = make1_str(" call" ); }
4477
4501
| SQL_CONNECT { $$ = make1_str(" connect" ); }
4478
- | SQL_CONNECTION { $$ = make1_str(" connection" ); }
4479
4502
| SQL_CONTINUE { $$ = make1_str(" continue" ); }
4480
4503
| SQL_DEALLOCATE { $$ = make1_str(" deallocate" ); }
4481
4504
| SQL_DISCONNECT { $$ = make1_str(" disconnect" ); }
@@ -4487,6 +4510,7 @@ ColId: ident { $$ = $1; }
4487
4510
| SQL_INDICATOR { $$ = make1_str(" indicator" ); }
4488
4511
| SQL_INT { $$ = make1_str(" int" ); }
4489
4512
| SQL_LONG { $$ = make1_str(" long" ); }
4513
+ | SQL_OFF { $$ = make1_str(" off" ); }
4490
4514
| SQL_OPEN { $$ = make1_str(" open" ); }
4491
4515
| SQL_PREPARE { $$ = make1_str(" prepare" ); }
4492
4516
| SQL_RELEASE { $$ = make1_str(" release" ); }
@@ -5138,13 +5162,27 @@ ECPGRelease: TransactionStmt SQL_RELEASE
5138
5162
free ($1 );
5139
5163
}
5140
5164
5165
+ /*
5166
+ * set/reset the automatic transaction mode, this needs a differnet handling
5167
+ * as the other set commands
5168
+ */
5169
+ ECPGSetAutocommit : SET SQL_AUTOCOMMIT to_equal on_off
5170
+ {
5171
+ $$ = $4 ;
5172
+ }
5173
+
5174
+ on_off : ON { $$ = make1_str(" on" ); }
5175
+ | SQL_OFF { $$ = make1_str(" off" ); }
5176
+
5177
+ to_equal : TO | " =" ;
5178
+
5141
5179
/*
5142
5180
* set the actual connection, this needs a differnet handling as the other
5143
5181
* set commands
5144
5182
*/
5145
- ECPGSetConnection : SET SQL_CONNECTION connection_object
5183
+ ECPGSetConnection : SET SQL_CONNECTION to_equal connection_object
5146
5184
{
5147
- $$ = $3 ;
5185
+ $$ = $4 ;
5148
5186
}
5149
5187
5150
5188
/*
@@ -5204,17 +5242,23 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds
5204
5242
$$ .index2 = $3 .index1;
5205
5243
$$ .str = cat2_str(make1_str(" []" ), $3 .str);
5206
5244
}
5207
- | ' [' Iconst ' ]' nest_type_array_bounds
5245
+ | ' [' Iresult ' ]' nest_type_array_bounds
5208
5246
{
5209
- $$ .index1 = atol($2 );
5247
+ char *txt = mm_alloc(20L );
5248
+
5249
+ sprintf (txt, " %d" , $2 );
5250
+ $$ .index1 = $2 ;
5210
5251
$$ .index2 = $4 .index1;
5211
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
5252
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
5212
5253
}
5213
- | ' (' Iconst ' )' nest_type_array_bounds
5254
+ | ' (' Iresult ' )' nest_type_array_bounds
5214
5255
{
5215
- $$ .index1 = atol($2 );
5256
+ char *txt = mm_alloc(20L );
5257
+
5258
+ sprintf (txt, " %d" , $2 );
5259
+ $$ .index1 = $2 ;
5216
5260
$$ .index2 = $4 .index1;
5217
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
5261
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
5218
5262
}
5219
5263
| /* EMPTY */
5220
5264
{
@@ -5236,17 +5280,23 @@ nest_type_array_bounds: '[' ']' nest_type_array_bounds
5236
5280
$$ .index2 = $3 .index1;
5237
5281
$$ .str = cat2_str(make1_str(" []" ), $3 .str);
5238
5282
}
5239
- | ' [' Iconst ' ]' nest_type_array_bounds
5283
+ | ' [' Iresult ' ]' nest_type_array_bounds
5240
5284
{
5241
- $$ .index1 = atol($2 );
5285
+ char *txt = mm_alloc(20L );
5286
+
5287
+ sprintf (txt, " %d" , $2 );
5288
+ $$ .index1 = $2 ;
5242
5289
$$ .index2 = $4 .index1;
5243
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
5290
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
5244
5291
}
5245
- | ' (' Iconst ' )' nest_type_array_bounds
5292
+ | ' (' Iresult ' )' nest_type_array_bounds
5246
5293
{
5247
- $$ .index1 = atol($2 );
5294
+ char *txt = mm_alloc(20L );
5295
+
5296
+ sprintf (txt, " %d" , $2 );
5297
+ $$ .index1 = $2 ;
5248
5298
$$ .index2 = $4 .index1;
5249
- $$ .str = cat4_str(make1_str(" [" ), $2 , make1_str(" ]" ), $4 .str);
5299
+ $$ .str = cat4_str(make1_str(" [" ), txt , make1_str(" ]" ), $4 .str);
5250
5300
}
5251
5301
| /* EMPTY */
5252
5302
{
@@ -5954,6 +6004,10 @@ c_anything: IDENT { $$ = $1; }
5954
6004
| Iconst { $$ = $1 ; }
5955
6005
| Fconst { $$ = $1 ; }
5956
6006
| ' *' { $$ = make1_str(" *" ); }
6007
+ | ' +' { $$ = make1_str(" +" ); }
6008
+ | ' -' { $$ = make1_str(" -" ); }
6009
+ | ' /' { $$ = make1_str(" /" ); }
6010
+ | ' %' { $$ = make1_str(" %" ); }
5957
6011
| S_AUTO { $$ = make1_str(" auto" ); }
5958
6012
| S_BOOL { $$ = make1_str(" bool" ); }
5959
6013
| S_CHAR { $$ = make1_str(" char" ); }
0 commit comments