Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf576de1

Browse files
author
Michael Meskes
committed
Improved ECPG warning as suggested by Michael Paquier and removed test case
that triggers the warning during regression tests.
1 parent31f860a commitf576de1

File tree

5 files changed

+118
-263
lines changed

5 files changed

+118
-263
lines changed

‎src/interfaces/ecpg/preproc/ecpg.header

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ check_declared_list(const char *name)
595595
if (strcmp(name, ptr -> name) == 0)
596596
{
597597
if (connection)
598-
mmerror(PARSE_ERROR, ET_WARNING, "connection %s is overwritten to %s.", connection, ptr->connection);
598+
if (connection && strcmp(ptr->connection, connection) != 0)
599+
mmerror(PARSE_ERROR, ET_WARNING, "connection %s is overwritten with %s by declare statement %s.", connection, ptr->connection, name);
599600
connection = mm_strdup(ptr -> connection);
600601
return true;
601602
}

‎src/interfaces/ecpg/test/expected/sql-declare.c

Lines changed: 58 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -366,103 +366,71 @@ if (sqlca.sqlcode < 0) sqlprint();}
366366
printResult("testcase2",2);
367367

368368
/*
369-
* testcase3. using DECLARE STATEMENTat con1,
370-
* using PREPARE andCURSOR statementat con2
369+
* testcase3. using DECLARE STATEMENTwithout using AT clause,
370+
* using PREPARE andEXECUTE statementwithout using AT clause
371371
*/
372372
reset();
373373

374374
/* declare \"stmt_3\" as an SQL identifier */
375375
#line 122 "declare.pgc"
376376

377-
{ECPGprepare(__LINE__,"con1",0,"stmt_3",selectString);
377+
{ECPGprepare(__LINE__,NULL,0,"stmt_3",selectString);
378378
#line 123 "declare.pgc"
379379

380380
if (sqlca.sqlcode<0)sqlprint();}
381381
#line 123 "declare.pgc"
382382

383-
/* declare cur_3 cursor for $1 */
384-
#line 124 "declare.pgc"
385-
386-
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"declare cur_3 cursor for $1",
387-
ECPGt_char_variable,(ECPGprepared_statement("con1","stmt_3",__LINE__)),(long)1,(long)1,(1)*sizeof(char),
388-
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
389-
#line 125 "declare.pgc"
390-
391-
if (sqlca.sqlcode<0)sqlprint();}
392-
#line 125 "declare.pgc"
393-
394-
395-
/* exec sql whenever not found break ; */
396-
#line 127 "declare.pgc"
397-
398-
i=0;
399-
while (1)
400-
{
401-
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"fetch cur_3",ECPGt_EOIT,
402-
ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int),
383+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_execute,"stmt_3",ECPGt_EOIT,
384+
ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int),
403385
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
404-
ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int),
386+
ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int),
405387
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
406-
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
388+
ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char),
407389
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
408-
#line 131 "declare.pgc"
409-
410-
if (sqlca.sqlcode==ECPG_NOT_FOUND)break;
411-
#line 131 "declare.pgc"
390+
#line 124 "declare.pgc"
412391

413392
if (sqlca.sqlcode<0)sqlprint();}
414-
#line 131 "declare.pgc"
415-
416-
i++;
417-
}
418-
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"close cur_3",ECPGt_EOIT,ECPGt_EORT);
419-
#line 134 "declare.pgc"
393+
#line 124 "declare.pgc"
420394

421-
if (sqlca.sqlcode<0)sqlprint();}
422-
#line 134 "declare.pgc"
423395

424-
{ECPGdeallocate(__LINE__,0,"con1","stmt_3");
425-
#line135 "declare.pgc"
396+
{ECPGdeallocate(__LINE__,0,NULL,"stmt_3");
397+
#line126 "declare.pgc"
426398

427399
if (sqlca.sqlcode<0)sqlprint();}
428-
#line 135 "declare.pgc"
429-
430-
/* exec sql whenever not found continue ; */
431-
#line 136 "declare.pgc"
400+
#line 126 "declare.pgc"
432401

433402

434403
printResult("testcase3",2);
435404

436-
437405
/*
438406
* testcase4. using DECLARE STATEMENT without using AT clause,
439407
* using PREPARE and CURSOR statement at con2
440408
*/
441409
reset();
442410

443411
/* declare \"stmt_4\" as an SQL identifier */
444-
#line147 "declare.pgc"
412+
#line136 "declare.pgc"
445413

446414
{ECPGprepare(__LINE__,"con2",0,"stmt_4",selectString);
447-
#line148 "declare.pgc"
415+
#line137 "declare.pgc"
448416

449417
if (sqlca.sqlcode<0)sqlprint();}
450-
#line148 "declare.pgc"
418+
#line137 "declare.pgc"
451419

452420
/* declare cur_4 cursor for $1 */
453-
#line149 "declare.pgc"
421+
#line138 "declare.pgc"
454422

455423
{ECPGdo(__LINE__,0,1,"con2",0,ECPGst_normal,"declare cur_4 cursor for $1",
456424
ECPGt_char_variable,(ECPGprepared_statement("con2","stmt_4",__LINE__)),(long)1,(long)1,(1)*sizeof(char),
457425
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
458-
#line150 "declare.pgc"
426+
#line139 "declare.pgc"
459427

460428
if (sqlca.sqlcode<0)sqlprint();}
461-
#line150 "declare.pgc"
429+
#line139 "declare.pgc"
462430

463431

464432
/* exec sql whenever not found break ; */
465-
#line152 "declare.pgc"
433+
#line141 "declare.pgc"
466434

467435
i=0;
468436
while (1)
@@ -474,173 +442,136 @@ if (sqlca.sqlcode < 0) sqlprint();}
474442
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
475443
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
476444
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
477-
#line156 "declare.pgc"
445+
#line145 "declare.pgc"
478446

479447
if (sqlca.sqlcode==ECPG_NOT_FOUND)break;
480-
#line156 "declare.pgc"
448+
#line145 "declare.pgc"
481449

482450
if (sqlca.sqlcode<0)sqlprint();}
483-
#line156 "declare.pgc"
451+
#line145 "declare.pgc"
484452

485453
i++;
486454
}
487455
{ECPGdo(__LINE__,0,1,"con2",0,ECPGst_normal,"close cur_4",ECPGt_EOIT,ECPGt_EORT);
488-
#line159 "declare.pgc"
456+
#line148 "declare.pgc"
489457

490458
if (sqlca.sqlcode<0)sqlprint();}
491-
#line159 "declare.pgc"
459+
#line148 "declare.pgc"
492460

493461
{ECPGdeallocate(__LINE__,0,"con2","stmt_4");
494-
#line160 "declare.pgc"
462+
#line149 "declare.pgc"
495463

496464
if (sqlca.sqlcode<0)sqlprint();}
497-
#line160 "declare.pgc"
465+
#line149 "declare.pgc"
498466

499467
/* exec sql whenever not found continue ; */
500-
#line161 "declare.pgc"
468+
#line150 "declare.pgc"
501469

502470

503471
printResult("testcase4",2);
504472

505-
/*
506-
* testcase5. using DECLARE STATEMENT without using AT clause,
507-
* using PREPARE and EXECUTE statement without using AT clause
508-
*/
509-
reset();
510-
511-
/* declare \"stmt_5\" as an SQL identifier */
512-
#line 171 "declare.pgc"
513-
514-
{ECPGprepare(__LINE__,NULL,0,"stmt_5",selectString);
515-
#line 172 "declare.pgc"
516-
517-
if (sqlca.sqlcode<0)sqlprint();}
518-
#line 172 "declare.pgc"
519-
520-
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_execute,"stmt_5",ECPGt_EOIT,
521-
ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int),
522-
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
523-
ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int),
524-
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
525-
ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char),
526-
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
527-
#line 173 "declare.pgc"
528-
529-
if (sqlca.sqlcode<0)sqlprint();}
530-
#line 173 "declare.pgc"
531-
532-
533-
{ECPGdeallocate(__LINE__,0,NULL,"stmt_5");
534-
#line 175 "declare.pgc"
535-
536-
if (sqlca.sqlcode<0)sqlprint();}
537-
#line 175 "declare.pgc"
538-
539-
540-
printResult("testcase5",2);
541-
542473
/*
543474
* DESCRIBE statement is also supported.
544475
*/
545476
/* declare \"stmt_desc\" as an SQL identifier */
546-
#line182 "declare.pgc"
477+
#line157 "declare.pgc"
547478

548479
{ECPGprepare(__LINE__,"con1",0,"stmt_desc",selectString);
549-
#line183 "declare.pgc"
480+
#line158 "declare.pgc"
550481

551482
if (sqlca.sqlcode<0)sqlprint();}
552-
#line183 "declare.pgc"
483+
#line158 "declare.pgc"
553484

554485
/* declare cur_desc cursor for $1 */
555-
#line184 "declare.pgc"
486+
#line159 "declare.pgc"
556487

557488
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"declare cur_desc cursor for $1",
558489
ECPGt_char_variable,(ECPGprepared_statement("con1","stmt_desc",__LINE__)),(long)1,(long)1,(1)*sizeof(char),
559490
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
560-
#line185 "declare.pgc"
491+
#line160 "declare.pgc"
561492

562493
if (sqlca.sqlcode<0)sqlprint();}
563-
#line185 "declare.pgc"
494+
#line160 "declare.pgc"
564495

565496

566497
/* descriptor can be used for describe statement */
567498
ECPGallocate_desc(__LINE__,"desc_for_describe");
568-
#line188 "declare.pgc"
499+
#line163 "declare.pgc"
569500

570501
if (sqlca.sqlcode<0)sqlprint();
571-
#line188 "declare.pgc"
502+
#line163 "declare.pgc"
572503

573504
{ECPGdescribe(__LINE__,0,0,"con1","stmt_desc",
574505
ECPGt_descriptor,"desc_for_describe",1L,1L,1L,
575506
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);}
576-
#line189 "declare.pgc"
507+
#line164 "declare.pgc"
577508

578509

579510
{ECPGget_desc_header(__LINE__,"desc_for_describe",&(count));
580511

581-
#line191 "declare.pgc"
512+
#line166 "declare.pgc"
582513

583514
if (sqlca.sqlcode<0)sqlprint();}
584-
#line191 "declare.pgc"
515+
#line166 "declare.pgc"
585516

586517
{ECPGget_desc(__LINE__,"desc_for_describe",3,ECPGd_length,
587518
ECPGt_int,&(length),(long)1,(long)1,sizeof(int),ECPGd_EODT);
588519

589-
#line192 "declare.pgc"
520+
#line167 "declare.pgc"
590521

591522
if (sqlca.sqlcode<0)sqlprint();}
592-
#line192 "declare.pgc"
523+
#line167 "declare.pgc"
593524

594525

595526
ECPGdeallocate_desc(__LINE__,"desc_for_describe");
596-
#line194 "declare.pgc"
527+
#line169 "declare.pgc"
597528

598529
if (sqlca.sqlcode<0)sqlprint();
599-
#line194 "declare.pgc"
530+
#line169 "declare.pgc"
600531

601532

602533
/* for fetch statement */
603534
ECPGallocate_desc(__LINE__,"desc_for_fetch");
604-
#line197 "declare.pgc"
535+
#line172 "declare.pgc"
605536

606537
if (sqlca.sqlcode<0)sqlprint();
607-
#line197 "declare.pgc"
538+
#line172 "declare.pgc"
608539

609540
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"fetch cur_desc",ECPGt_EOIT,
610541
ECPGt_descriptor,"desc_for_fetch",1L,1L,1L,
611542
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
612-
#line198 "declare.pgc"
543+
#line173 "declare.pgc"
613544

614545
if (sqlca.sqlcode<0)sqlprint();}
615-
#line198 "declare.pgc"
546+
#line173 "declare.pgc"
616547

617548

618549
{ECPGget_desc(__LINE__,"desc_for_fetch",3,ECPGd_data,
619550
ECPGt_char,(f3[0]),(long)20,(long)1,(20)*sizeof(char),ECPGd_EODT);
620551

621-
#line200 "declare.pgc"
552+
#line175 "declare.pgc"
622553

623554
if (sqlca.sqlcode<0)sqlprint();}
624-
#line200 "declare.pgc"
555+
#line175 "declare.pgc"
625556

626557

627558
ECPGdeallocate_desc(__LINE__,"desc_for_fetch");
628-
#line202 "declare.pgc"
559+
#line177 "declare.pgc"
629560

630561
if (sqlca.sqlcode<0)sqlprint();
631-
#line202 "declare.pgc"
562+
#line177 "declare.pgc"
632563

633564
{ECPGdo(__LINE__,0,1,"con1",0,ECPGst_normal,"close cur_desc",ECPGt_EOIT,ECPGt_EORT);
634-
#line203 "declare.pgc"
565+
#line178 "declare.pgc"
635566

636567
if (sqlca.sqlcode<0)sqlprint();}
637-
#line203 "declare.pgc"
568+
#line178 "declare.pgc"
638569

639570
{ECPGdeallocate(__LINE__,0,"con1","stmt_desc");
640-
#line204 "declare.pgc"
571+
#line179 "declare.pgc"
641572

642573
if (sqlca.sqlcode<0)sqlprint();}
643-
#line204 "declare.pgc"
574+
#line179 "declare.pgc"
644575

645576

646577
printf("****descriptor results****\n");
@@ -650,16 +581,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
650581
voidcommitTable()
651582
{
652583
{ECPGtrans(__LINE__,"con1","commit");
653-
#line212 "declare.pgc"
584+
#line187 "declare.pgc"
654585

655586
if (sqlca.sqlcode<0)sqlprint();}
656-
#line212 "declare.pgc"
587+
#line187 "declare.pgc"
657588

658589
{ECPGtrans(__LINE__,"con2","commit");
659-
#line213 "declare.pgc"
590+
#line188 "declare.pgc"
660591

661592
if (sqlca.sqlcode<0)sqlprint();}
662-
#line213 "declare.pgc"
593+
#line188 "declare.pgc"
663594

664595
}
665596

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp