aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1999-01-21 20:01:34 +0000
committerMarc G. Fournier <scrappy@hub.org>1999-01-21 20:01:34 +0000
commitcdbaec771c5c0b77a4a130a3726e6ea043c59eed (patch)
treebe07e5b884c1929d287c2166e774f2ba94c8c8f3
parent1f37905681dc3f068a2690b21a7162df145c4690 (diff)
downloadpostgresql-cdbaec771c5c0b77a4a130a3726e6ea043c59eed.tar.gz
postgresql-cdbaec771c5c0b77a4a130a3726e6ea043c59eed.zip
From: Michael Meskes <Michael.Meskes@usa.net>
See attached file. Now accepts "exec sql whenever sqlwarning".
-rw-r--r--src/interfaces/ecpg/ChangeLog18
-rw-r--r--src/interfaces/ecpg/lib/Makefile.in4
-rw-r--r--src/interfaces/ecpg/lib/ecpglib.c13
-rw-r--r--src/interfaces/ecpg/preproc/ecpg_keywords.c1
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y19
-rw-r--r--src/interfaces/ecpg/test/header_test.h14
6 files changed, 51 insertions, 18 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 464f5cea0b8..9675f482272 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -335,7 +335,7 @@ Thu Sep 17 08:55:33 CEST 1998
Thu Sep 17 19:23:24 CEST 1998
- - Added missing ´;´ in preproc.y
+ - Added missing ';' in preproc.y
- Set version to 2.4.2
Tue Sep 29 10:22:00 CEST 1998
@@ -357,23 +357,29 @@ Thu Okt 15 10:05:04 CEST 1998
- Synced preproc.y with gram.y yet again.
- Set version to 2.4.4
-Wed Dec 9 11:24:54 MEZ 1998
+Wed Dec 9 20:24:54 MEZ 1998
- Synced preproc.y with gram.y and the keywords.c files to add CASE
statement.
-Tue Dec 22 14:16:11 CET 1998
+Tue Dec 22 19:16:11 CET 1998
- Synced preproc.y with gram.y for locking statements.
- Set version to 2.4.5
-Tue Jan 7 15:19:34 CET 1999
+Tue Jan 7 19:19:34 CET 1999
- Synced preproc.y with gram.y for for-update clause and changes in
handling of numerics
-Mon Jan 18 11:22:44 CET 1999
+Mon Jan 18 19:22:44 CET 1999
- Added INTERSECT, EXCEPT and UNION for Select statements
- Put keywords.c in sync again after forgettimg it the last time.
- - Set version to 2.4.6
+
+Thu Jan 21 21:29:00 CET 1999
+
+ - Fixed libecpg to not segfault if there is no connection.
+ - Set library version to 2.6.3
+ - Added 'exec sql whenever sqlwarning'.
+ - Set ecpg version to 2.4.6
diff --git a/src/interfaces/ecpg/lib/Makefile.in b/src/interfaces/ecpg/lib/Makefile.in
index 182fd657432..9173f36c4ee 100644
--- a/src/interfaces/ecpg/lib/Makefile.in
+++ b/src/interfaces/ecpg/lib/Makefile.in
@@ -6,13 +6,13 @@
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.39 1999/01/17 06:19:24 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.40 1999/01/21 20:01:32 scrappy Exp $
#
#-------------------------------------------------------------------------
NAME= ecpg
SO_MAJOR_VERSION= 2
-SO_MINOR_VERSION= 6.2
+SO_MINOR_VERSION= 6.3
SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c
index f982d5103cb..62769941a7c 100644
--- a/src/interfaces/ecpg/lib/ecpglib.c
+++ b/src/interfaces/ecpg/lib/ecpglib.c
@@ -886,12 +886,17 @@ ECPGtrans(int lineno, const char *transaction)
PGresult *res;
ECPGlog("ECPGtrans line %d action = %s\n", lineno, transaction);
- if ((res = PQexec(actual_connection->connection, transaction)) == NULL)
+
+ /* if we have no connection we just simulate the command */
+ if (actual_connection && actual_connection->connection)
{
- register_error(ECPG_TRANS, "Error in transaction processing line %d.", lineno);
- return FALSE;
+ if ((res = PQexec(actual_connection->connection, transaction)) == NULL)
+ {
+ register_error(ECPG_TRANS, "Error in transaction processing line %d.", lineno);
+ return FALSE;
+ }
+ PQclear(res);
}
- PQclear(res);
if (strcmp(transaction, "commit") == 0 || strcmp(transaction, "rollback") == 0)
committed = 1;
return TRUE;
diff --git a/src/interfaces/ecpg/preproc/ecpg_keywords.c b/src/interfaces/ecpg/preproc/ecpg_keywords.c
index 77d7eaacc0c..04e0d6165d5 100644
--- a/src/interfaces/ecpg/preproc/ecpg_keywords.c
+++ b/src/interfaces/ecpg/preproc/ecpg_keywords.c
@@ -38,6 +38,7 @@ static ScanKeyword ScanKeywords[] = {
{"section", SQL_SECTION},
{"sqlerror", SQL_SQLERROR},
{"sqlprint", SQL_SQLPRINT},
+ {"sqlwarning", SQL_SQLWARNING},
{"stop", SQL_STOP},
{"whenever", SQL_WHENEVER},
};
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 7f2949373f7..0e34aa36dcd 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -45,7 +45,7 @@ output_line_number()
/*
* store the whenever action here
*/
-static struct when when_error, when_nf;
+static struct when when_error, when_nf, when_warn;
static void
print_action(struct when *w)
@@ -76,6 +76,12 @@ whenever_action(int mode)
fprintf(yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
print_action(&when_nf);
}
+ if (when_warn.code != W_NOTHING)
+ {
+ output_line_number();
+ fprintf(yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
+ print_action(&when_warn);
+ }
if (when_error.code != W_NOTHING)
{
output_line_number();
@@ -517,7 +523,7 @@ output_statement(char * stmt, int mode)
%token SQL_DISCONNECT SQL_FOUND SQL_GO SQL_GOTO
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_OPEN SQL_RELEASE
%token SQL_SECTION SQL_SEMI SQL_SQLERROR SQL_SQLPRINT SQL_START
-%token SQL_STOP SQL_WHENEVER
+%token SQL_STOP SQL_WHENEVER SQL_SQLWARNING
/* C token */
%token S_ANYTHING S_AUTO S_BOOL S_CHAR S_CONST S_DOUBLE S_ENUM S_EXTERN
@@ -4630,9 +4636,7 @@ ECPGSetConnection: SET SQL_CONNECTION connection_object
}
/*
* whenever statement: decide what to do in case of error/no data found
- * according to SQL standards we miss: SQLSTATE, CONSTRAINT, SQLEXCEPTION
- * and SQLWARNING
-
+ * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
*/
ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
when_error.code = $<action>3.code;
@@ -4644,6 +4648,11 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
when_nf.command = $<action>4.command;
$$ = cat3_str(make1_str("/* exec sql whenever not found "), $4.str, make1_str("; */\n"));
}
+ | SQL_WHENEVER SQL_SQLWARNING action {
+ when_warn.code = $<action>3.code;
+ when_warn.command = $<action>3.command;
+ $$ = cat3_str(make1_str("/* exec sql whenever sql_warning "), $3.str, make1_str("; */\n"));
+}
action : SQL_CONTINUE {
$<action>$.code = W_NOTHING;
diff --git a/src/interfaces/ecpg/test/header_test.h b/src/interfaces/ecpg/test/header_test.h
index 7d495ac64fb..5050113e184 100644
--- a/src/interfaces/ecpg/test/header_test.h
+++ b/src/interfaces/ecpg/test/header_test.h
@@ -1,3 +1,15 @@
exec sql include sqlca;
-exec sql whenever sqlerror sqlprint;
+exec sql whenever sqlerror do print_and_stop();
+exec sql whenever sqlwarning do warn();
+
+void print_and_stop(void)
+{
+ sqlprint();
+ exit(-1);
+}
+
+void warn(void)
+{
+ fprintf(stderr, "Warning: At least one column was truncated\n");
+}