@@ -33,6 +33,7 @@ ECPG: stmtUpdateStmt block
33
33
{ output_statement($1, 1, ECPGst_prepnormal); }
34
34
ECPG: stmtExecuteStmt block
35
35
{
36
+ check_declared_list($1.name);
36
37
if ($1.type == NULL || strlen($1.type) == 0)
37
38
output_statement($1.name, 1, ECPGst_execute);
38
39
else
@@ -56,6 +57,7 @@ ECPG: stmtExecuteStmt block
56
57
}
57
58
ECPG: stmtPrepareStmt block
58
59
{
60
+ check_declared_list($1.name);
59
61
if ($1.type == NULL)
60
62
output_prepare_statement($1.name, $1.stmt);
61
63
else if (strlen($1.type) == 0)
@@ -104,6 +106,10 @@ ECPG: stmtViewStmt rule
104
106
whenever_action(2);
105
107
free($1);
106
108
}
109
+ | ECPGDeclareStmt
110
+ {
111
+ output_simple_statement($1, 0);
112
+ }
107
113
| ECPGCursorStmt
108
114
{
109
115
output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0);
@@ -244,14 +250,20 @@ ECPG: var_valueNumericOnly addon
244
250
$1 = mm_strdup("$0");
245
251
}
246
252
ECPG: fetch_argscursor_name addon
247
- add_additional_variables($1, false);
253
+ struct cursor *ptr = add_additional_variables($1, false);
254
+ if (ptr -> connection)
255
+ connection = mm_strdup(ptr -> connection);
256
+
248
257
if ($1[0] == ':')
249
258
{
250
259
free($1);
251
260
$1 = mm_strdup("$0");
252
261
}
253
262
ECPG: fetch_argsfrom_incursor_name addon
254
- add_additional_variables($2, false);
263
+ struct cursor *ptr = add_additional_variables($2, false);
264
+ if (ptr -> connection)
265
+ connection = mm_strdup(ptr -> connection);
266
+
255
267
if ($2[0] == ':')
256
268
{
257
269
free($2);
@@ -262,14 +274,20 @@ ECPG: fetch_argsPRIORopt_from_incursor_name addon
262
274
ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
263
275
ECPG: fetch_argsLAST_Popt_from_incursor_name addon
264
276
ECPG: fetch_argsALLopt_from_incursor_name addon
265
- add_additional_variables($3, false);
277
+ struct cursor *ptr = add_additional_variables($3, false);
278
+ if (ptr -> connection)
279
+ connection = mm_strdup(ptr -> connection);
280
+
266
281
if ($3[0] == ':')
267
282
{
268
283
free($3);
269
284
$3 = mm_strdup("$0");
270
285
}
271
286
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
272
- add_additional_variables($3, false);
287
+ struct cursor *ptr = add_additional_variables($3, false);
288
+ if (ptr -> connection)
289
+ connection = mm_strdup(ptr -> connection);
290
+
273
291
if ($3[0] == ':')
274
292
{
275
293
free($3);
@@ -282,7 +300,10 @@ ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
282
300
}
283
301
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
284
302
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
285
- add_additional_variables($4, false);
303
+ struct cursor *ptr = add_additional_variables($4, false);
304
+ if (ptr -> connection)
305
+ connection = mm_strdup(ptr -> connection);
306
+
286
307
if ($4[0] == ':')
287
308
{
288
309
free($4);
@@ -292,7 +313,10 @@ ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
292
313
ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
293
314
ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
294
315
ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
295
- add_additional_variables($4, false);
316
+ struct cursor *ptr = add_additional_variables($4, false);
317
+ if (ptr -> connection)
318
+ connection = mm_strdup(ptr -> connection);
319
+
296
320
if ($4[0] == ':')
297
321
{
298
322
free($4);
@@ -348,6 +372,9 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
348
372
char *comment, *c1, *c2;
349
373
int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
350
374
375
+ if (INFORMIX_MODE && pg_strcasecmp($2, "database") == 0)
376
+ mmfatal(PARSE_ERROR, "\"database\" cannot be used as cursor name in INFORMIX mode");
377
+
351
378
for (ptr = cur; ptr != NULL; ptr = ptr->next)
352
379
{
353
380
if (strcmp_fn($2, ptr->name) == 0)
@@ -388,6 +415,17 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
388
415
ECPG: ClosePortalStmtCLOSEcursor_name block
389
416
{
390
417
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
418
+ struct cursor *ptr = NULL;
419
+ for (ptr = cur; ptr != NULL; ptr = ptr -> next)
420
+ {
421
+ if (strcmp($2, ptr -> name) == 0)
422
+ {
423
+ if (ptr -> connection)
424
+ connection = mm_strdup(ptr -> connection);
425
+
426
+ break;
427
+ }
428
+ }
391
429
$$ = cat2_str(mm_strdup("close"), cursor_marker);
392
430
}
393
431
ECPG: opt_hold block
@@ -466,49 +504,73 @@ ECPG: FetchStmtMOVEfetch_args rule
466
504
| FETCH FORWARD cursor_name opt_ecpg_fetch_into
467
505
{
468
506
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
469
- add_additional_variables($3, false);
507
+ struct cursor *ptr = add_additional_variables($3, false);
508
+ if (ptr -> connection)
509
+ connection = mm_strdup(ptr -> connection);
510
+
470
511
$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
471
512
}
472
513
| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
473
514
{
474
515
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
475
- add_additional_variables($4, false);
516
+ struct cursor *ptr = add_additional_variables($4, false);
517
+ if (ptr -> connection)
518
+ connection = mm_strdup(ptr -> connection);
519
+
476
520
$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
477
521
}
478
522
| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
479
523
{
480
524
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
481
- add_additional_variables($3, false);
525
+ struct cursor *ptr = add_additional_variables($3, false);
526
+ if (ptr -> connection)
527
+ connection = mm_strdup(ptr -> connection);
528
+
482
529
$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
483
530
}
484
531
| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
485
532
{
486
533
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
487
- add_additional_variables($4, false);
534
+ struct cursor *ptr = add_additional_variables($4, false);
535
+ if (ptr -> connection)
536
+ connection = mm_strdup(ptr -> connection);
537
+
488
538
$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
489
539
}
490
540
| MOVE FORWARD cursor_name
491
541
{
492
542
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
493
- add_additional_variables($3, false);
543
+ struct cursor *ptr = add_additional_variables($3, false);
544
+ if (ptr -> connection)
545
+ connection = mm_strdup(ptr -> connection);
546
+
494
547
$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
495
548
}
496
549
| MOVE FORWARD from_in cursor_name
497
550
{
498
551
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
499
- add_additional_variables($4, false);
552
+ struct cursor *ptr = add_additional_variables($4, false);
553
+ if (ptr -> connection)
554
+ connection = mm_strdup(ptr -> connection);
555
+
500
556
$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
501
557
}
502
558
| MOVE BACKWARD cursor_name
503
559
{
504
560
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
505
- add_additional_variables($3, false);
561
+ struct cursor *ptr = add_additional_variables($3, false);
562
+ if (ptr -> connection)
563
+ connection = mm_strdup(ptr -> connection);
564
+
506
565
$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
507
566
}
508
567
| MOVE BACKWARD from_in cursor_name
509
568
{
510
569
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
511
- add_additional_variables($4, false);
570
+ struct cursor *ptr = add_additional_variables($4, false);
571
+ if (ptr -> connection)
572
+ connection = mm_strdup(ptr -> connection);
573
+
512
574
$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
513
575
}
514
576
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
0 commit comments