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

Commitcdbaec7

Browse files
committed
From: Michael Meskes <Michael.Meskes@usa.net>See attached file. Now accepts "exec sql whenever sqlwarning".
1 parent1f37905 commitcdbaec7

File tree

6 files changed

+51
-18
lines changed

6 files changed

+51
-18
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Thu Sep 17 08:55:33 CEST 1998
335335

336336
Thu Sep 17 19:23:24 CEST 1998
337337

338-
- Added missing�;� in preproc.y
338+
- Added missing';' in preproc.y
339339
- Set version to 2.4.2
340340

341341
Tue Sep 29 10:22:00 CEST 1998
@@ -357,23 +357,29 @@ Thu Okt 15 10:05:04 CEST 1998
357357
- Synced preproc.y with gram.y yet again.
358358
- Set version to 2.4.4
359359

360-
Wed Dec 911:24:54 MEZ 1998
360+
Wed Dec 920:24:54 MEZ 1998
361361

362362
- Synced preproc.y with gram.y and the keywords.c files to add CASE
363363
statement.
364364

365-
Tue Dec 2214:16:11 CET 1998
365+
Tue Dec 2219:16:11 CET 1998
366366

367367
- Synced preproc.y with gram.y for locking statements.
368368
- Set version to 2.4.5
369369

370-
Tue Jan 715:19:34 CET 1999
370+
Tue Jan 719:19:34 CET 1999
371371

372372
- Synced preproc.y with gram.y for for-update clause and changes in
373373
handling of numerics
374374

375-
Mon Jan 1811:22:44 CET 1999
375+
Mon Jan 1819:22:44 CET 1999
376376

377377
- Added INTERSECT, EXCEPT and UNION for Select statements
378378
- Put keywords.c in sync again after forgettimg it the last time.
379-
- Set version to 2.4.6
379+
380+
Thu Jan 21 21:29:00 CET 1999
381+
382+
- Fixed libecpg to not segfault if there is no connection.
383+
- Set library version to 2.6.3
384+
- Added 'exec sql whenever sqlwarning'.
385+
- Set ecpg version to 2.4.6

‎src/interfaces/ecpg/lib/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# Copyright (c) 1994, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.39 1999/01/17 06:19:24 momjian Exp $
9+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.40 1999/01/21 20:01:32 scrappy Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

1313
NAME= ecpg
1414
SO_MAJOR_VERSION= 2
15-
SO_MINOR_VERSION= 6.2
15+
SO_MINOR_VERSION= 6.3
1616

1717
SRCDIR= @top_srcdir@
1818
include$(SRCDIR)/Makefile.global

‎src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,12 +886,17 @@ ECPGtrans(int lineno, const char *transaction)
886886
PGresult*res;
887887

888888
ECPGlog("ECPGtrans line %d action = %s\n",lineno,transaction);
889-
if ((res=PQexec(actual_connection->connection,transaction))==NULL)
889+
890+
/* if we have no connection we just simulate the command */
891+
if (actual_connection&&actual_connection->connection)
890892
{
891-
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
892-
return FALSE;
893+
if ((res=PQexec(actual_connection->connection,transaction))==NULL)
894+
{
895+
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
896+
return FALSE;
897+
}
898+
PQclear(res);
893899
}
894-
PQclear(res);
895900
if (strcmp(transaction,"commit")==0||strcmp(transaction,"rollback")==0)
896901
committed=1;
897902
return TRUE;

‎src/interfaces/ecpg/preproc/ecpg_keywords.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static ScanKeyword ScanKeywords[] = {
3838
{"section",SQL_SECTION},
3939
{"sqlerror",SQL_SQLERROR},
4040
{"sqlprint",SQL_SQLPRINT},
41+
{"sqlwarning",SQL_SQLWARNING},
4142
{"stop",SQL_STOP},
4243
{"whenever",SQL_WHENEVER},
4344
};

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ output_line_number()
4545
/*
4646
* store the whenever action here
4747
*/
48-
staticstructwhen when_error, when_nf;
48+
staticstructwhen when_error, when_nf, when_warn;
4949

5050
staticvoid
5151
print_action(structwhen *w)
@@ -76,6 +76,12 @@ whenever_action(int mode)
7676
fprintf(yyout,"\nif (sqlca.sqlcode == ECPG_NOT_FOUND)");
7777
print_action(&when_nf);
7878
}
79+
if (when_warn.code != W_NOTHING)
80+
{
81+
output_line_number();
82+
fprintf(yyout,"\nif (sqlca.sqlwarn[0] == 'W')");
83+
print_action(&when_warn);
84+
}
7985
if (when_error.code != W_NOTHING)
8086
{
8187
output_line_number();
@@ -517,7 +523,7 @@ output_statement(char * stmt, int mode)
517523
%tokenSQL_DISCONNECTSQL_FOUNDSQL_GOSQL_GOTO
518524
%tokenSQL_IDENTIFIEDSQL_IMMEDIATESQL_INDICATORSQL_OPENSQL_RELEASE
519525
%tokenSQL_SECTIONSQL_SEMISQL_SQLERRORSQL_SQLPRINTSQL_START
520-
%tokenSQL_STOPSQL_WHENEVER
526+
%tokenSQL_STOPSQL_WHENEVERSQL_SQLWARNING
521527

522528
/* C token*/
523529
%tokenS_ANYTHINGS_AUTOS_BOOLS_CHARS_CONSTS_DOUBLES_ENUMS_EXTERN
@@ -4630,9 +4636,7 @@ ECPGSetConnection: SET SQL_CONNECTION connection_object
46304636
}
46314637
/*
46324638
* whenever statement: decide what to do in case of error/no data found
4633-
* according to SQL standards we miss: SQLSTATE, CONSTRAINT, SQLEXCEPTION
4634-
* and SQLWARNING
4635-
4639+
* according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
46364640
*/
46374641
ECPGWhenever:SQL_WHENEVERSQL_SQLERRORaction {
46384642
when_error.code = $<action>3.code;
@@ -4644,6 +4648,11 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
46444648
when_nf.command = $<action>4.command;
46454649
$$ = cat3_str(make1_str("/* exec sql whenever not found"),$4.str, make1_str("; */\n"));
46464650
}
4651+
|SQL_WHENEVERSQL_SQLWARNINGaction {
4652+
when_warn.code = $<action>3.code;
4653+
when_warn.command = $<action>3.command;
4654+
$$ = cat3_str(make1_str("/* exec sql whenever sql_warning"),$3.str, make1_str("; */\n"));
4655+
}
46474656

46484657
action :SQL_CONTINUE {
46494658
$<action>$.code = W_NOTHING;
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
execsqlincludesqlca;
22

3-
execsqlwheneversqlerrorsqlprint;
3+
execsqlwheneversqlerrordoprint_and_stop();
4+
execsqlwheneversqlwarningdowarn();
5+
6+
voidprint_and_stop(void)
7+
{
8+
sqlprint();
9+
exit(-1);
10+
}
11+
12+
voidwarn(void)
13+
{
14+
fprintf(stderr,"Warning: At least one column was truncated\n");
15+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp