@@ -135,6 +135,7 @@ ECPG: rule stmt ViewStmt
135
135
136
136
fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %d, %s, %s,", compat, $1.input, connection ? connection : "NULL", $1.stmt_name);
137
137
dump_variables(argsresult, 1);
138
+ argsresult = NULL;
138
139
fputs("ECPGt_EORT);", base_yyout);
139
140
fprintf(base_yyout, "}");
140
141
output_line_number();
@@ -181,6 +182,7 @@ ECPG: rule stmt ViewStmt
181
182
182
183
if ((ptr = add_additional_variables(@1, true)) != NULL)
183
184
{
185
+ free(connection);
184
186
connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
185
187
output_statement(ptr->command, 0, ECPGst_normal);
186
188
ptr->opened = true;
@@ -247,15 +249,13 @@ ECPG: addon var_value NumericOnly
247
249
ECPG: addon fetch_args cursor_name
248
250
struct cursor *ptr = add_additional_variables(@1, false);
249
251
250
- if (ptr->connection)
251
- connection = mm_strdup(ptr->connection);
252
+ update_connection(ptr->connection);
252
253
if (@1[0] == ':')
253
254
@$ = "$0";
254
255
ECPG: addon fetch_args from_in cursor_name
255
256
struct cursor *ptr = add_additional_variables(@2, false);
256
257
257
- if (ptr->connection)
258
- connection = mm_strdup(ptr->connection);
258
+ update_connection(ptr->connection);
259
259
if (@2[0] == ':')
260
260
@$ = cat2_str(@1, "$0");
261
261
ECPG: addon fetch_args NEXT opt_from_in cursor_name
@@ -265,16 +265,14 @@ ECPG: addon fetch_args LAST_P opt_from_in cursor_name
265
265
ECPG: addon fetch_args ALL opt_from_in cursor_name
266
266
struct cursor *ptr = add_additional_variables(@3, false);
267
267
268
- if (ptr->connection)
269
- connection = mm_strdup(ptr->connection);
268
+ update_connection(ptr->connection);
270
269
if (@3[0] == ':')
271
270
@$ = cat_str(3, @1, @2, "$0");
272
271
ECPG: addon fetch_args SignedIconst opt_from_in cursor_name
273
272
struct cursor *ptr = add_additional_variables(@3, false);
274
273
bool replace = false;
275
274
276
- if (ptr->connection)
277
- connection = mm_strdup(ptr->connection);
275
+ update_connection(ptr->connection);
278
276
if (@3[0] == ':')
279
277
{
280
278
@3 = "$0";
@@ -291,8 +289,7 @@ ECPG: addon fetch_args FORWARD ALL opt_from_in cursor_name
291
289
ECPG: addon fetch_args BACKWARD ALL opt_from_in cursor_name
292
290
struct cursor *ptr = add_additional_variables(@4, false);
293
291
294
- if (ptr->connection)
295
- connection = mm_strdup(ptr->connection);
292
+ update_connection(ptr->connection);
296
293
if (@4[0] == ':')
297
294
@$ = cat_str(4, @1, @2, @3, "$0");
298
295
ECPG: addon fetch_args ABSOLUTE_P SignedIconst opt_from_in cursor_name
@@ -302,8 +299,7 @@ ECPG: addon fetch_args BACKWARD SignedIconst opt_from_in cursor_name
302
299
struct cursor *ptr = add_additional_variables(@4, false);
303
300
bool replace = false;
304
301
305
- if (ptr->connection)
306
- connection = mm_strdup(ptr->connection);
302
+ update_connection(ptr->connection);
307
303
if (@4[0] == ':')
308
304
{
309
305
@4 = "$0";
@@ -412,8 +408,7 @@ ECPG: block ClosePortalStmt CLOSE cursor_name
412
408
{
413
409
if (strcmp(@2, ptr->name) == 0)
414
410
{
415
- if (ptr->connection)
416
- connection = mm_strdup(ptr->connection);
411
+ update_connection(ptr->connection);
417
412
break;
418
413
}
419
414
}
@@ -483,8 +478,7 @@ ECPG: rule FetchStmt MOVE fetch_args
483
478
const char *cursor_marker = @3[0] == ':' ? "$0" : @3;
484
479
struct cursor *ptr = add_additional_variables(@3, false);
485
480
486
- if (ptr->connection)
487
- connection = mm_strdup(ptr->connection);
481
+ update_connection(ptr->connection);
488
482
489
483
@$ = cat_str(2, "fetch forward", cursor_marker);
490
484
}
@@ -493,8 +487,7 @@ ECPG: rule FetchStmt MOVE fetch_args
493
487
const char *cursor_marker = @4[0] == ':' ? "$0" : @4;
494
488
struct cursor *ptr = add_additional_variables(@4, false);
495
489
496
- if (ptr->connection)
497
- connection = mm_strdup(ptr->connection);
490
+ update_connection(ptr->connection);
498
491
499
492
@$ = cat_str(2, "fetch forward from", cursor_marker);
500
493
}
@@ -503,8 +496,7 @@ ECPG: rule FetchStmt MOVE fetch_args
503
496
const char *cursor_marker = @3[0] == ':' ? "$0" : @3;
504
497
struct cursor *ptr = add_additional_variables(@3, false);
505
498
506
- if (ptr->connection)
507
- connection = mm_strdup(ptr->connection);
499
+ update_connection(ptr->connection);
508
500
509
501
@$ = cat_str(2, "fetch backward", cursor_marker);
510
502
}
@@ -513,8 +505,7 @@ ECPG: rule FetchStmt MOVE fetch_args
513
505
const char *cursor_marker = @4[0] == ':' ? "$0" : @4;
514
506
struct cursor *ptr = add_additional_variables(@4, false);
515
507
516
- if (ptr->connection)
517
- connection = mm_strdup(ptr->connection);
508
+ update_connection(ptr->connection);
518
509
519
510
@$ = cat_str(2, "fetch backward from", cursor_marker);
520
511
}
@@ -523,8 +514,7 @@ ECPG: rule FetchStmt MOVE fetch_args
523
514
const char *cursor_marker = @3[0] == ':' ? "$0" : @3;
524
515
struct cursor *ptr = add_additional_variables(@3, false);
525
516
526
- if (ptr->connection)
527
- connection = mm_strdup(ptr->connection);
517
+ update_connection(ptr->connection);
528
518
529
519
@$ = cat_str(2, "move forward", cursor_marker);
530
520
}
@@ -533,8 +523,7 @@ ECPG: rule FetchStmt MOVE fetch_args
533
523
const char *cursor_marker = @4[0] == ':' ? "$0" : @4;
534
524
struct cursor *ptr = add_additional_variables(@4, false);
535
525
536
- if (ptr->connection)
537
- connection = mm_strdup(ptr->connection);
526
+ update_connection(ptr->connection);
538
527
539
528
@$ = cat_str(2, "move forward from", cursor_marker);
540
529
}
@@ -543,8 +532,7 @@ ECPG: rule FetchStmt MOVE fetch_args
543
532
const char *cursor_marker = @3[0] == ':' ? "$0" : @3;
544
533
struct cursor *ptr = add_additional_variables(@3, false);
545
534
546
- if (ptr->connection)
547
- connection = mm_strdup(ptr->connection);
535
+ update_connection(ptr->connection);
548
536
549
537
@$ = cat_str(2, "move backward", cursor_marker);
550
538
}
@@ -553,8 +541,7 @@ ECPG: rule FetchStmt MOVE fetch_args
553
541
const char *cursor_marker = @4[0] == ':' ? "$0" : @4;
554
542
struct cursor *ptr = add_additional_variables(@4, false);
555
543
556
- if (ptr->connection)
557
- connection = mm_strdup(ptr->connection);
544
+ update_connection(ptr->connection);
558
545
559
546
@$ = cat_str(2, "move backward from", cursor_marker);
560
547
}
0 commit comments