aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-06-03 13:55:15 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-06-03 13:55:15 +0000
commit2a74511bf4a66bc878ebf1eb097fa68062b7233f (patch)
tree029b5baad7814b89022af886c4284d27331995d0
parent0b09955da8721c049d3f504cb9dcb85702e7fb8b (diff)
downloadpostgresql-2a74511bf4a66bc878ebf1eb097fa68062b7233f.tar.gz
postgresql-2a74511bf4a66bc878ebf1eb097fa68062b7233f.zip
From: Michael Meskes <meskes@topsystem.de>
+ Wed Jun 3 13:38:57 CEST 1998 + + - Made sqlca struct compatible with other systems. + - Give back a warning in case of truncation + - Changed the handling of OptimizableStmt since the old one broke + CREATE RULE + - Set library version to 2.3 + - Set version to 2.3.3
-rw-r--r--src/interfaces/ecpg/ChangeLog9
-rw-r--r--src/interfaces/ecpg/TODO9
-rw-r--r--src/interfaces/ecpg/include/sqlca.h28
-rw-r--r--src/interfaces/ecpg/lib/Makefile.in2
-rw-r--r--src/interfaces/ecpg/lib/ecpglib.c6
-rw-r--r--src/interfaces/ecpg/preproc/Makefile2
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y39
-rw-r--r--src/interfaces/ecpg/test/header_test.h1
-rw-r--r--src/interfaces/ecpg/test/test2.pgc2
9 files changed, 74 insertions, 24 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 0211c321cb7..bef6e29787b 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -239,3 +239,12 @@ Wed May 20 10:46:48 CEST 1998
initialization.
- Added enum datatype.
- Set version to 2.3.2
+
+Wed Jun 3 13:38:57 CEST 1998
+
+ - Made sqlca struct compatible with other systems.
+ - Give back a warning in case of truncation
+ - Changed the handling of OptimizableStmt since the old one broke
+ CREATE RULE
+ - Set library version to 2.3
+ - Set version to 2.3.3
diff --git a/src/interfaces/ecpg/TODO b/src/interfaces/ecpg/TODO
index 06a818d1e8d..b174b56e5e9 100644
--- a/src/interfaces/ecpg/TODO
+++ b/src/interfaces/ecpg/TODO
@@ -3,6 +3,14 @@ section of the structure variable for ecpg to be able to understand it.
Variable type bool has to be checked. I never used it so far.
+The error message for "no data" in an exec sql insert select from statement
+has to be 100.
+
+sqlwarn[6] should be 'W' if the PRECISION or SCALE value specified in a SET
+DESCRIPTOR statement will be ignored.
+
+it would be nice to be able to use :var[:index] as cvariable
+
Missing statements:
- exec sql type
- exec sql define
@@ -10,3 +18,4 @@ Missing statements:
- exec sql allocate
- exqc sql free
- SQLSTATE
+ - exec sql whenever sqlwarning
diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h
index 7e99484d5ae..7d6c9994349 100644
--- a/src/interfaces/ecpg/include/sqlca.h
+++ b/src/interfaces/ecpg/include/sqlca.h
@@ -7,13 +7,37 @@ extern "C" {
struct sqlca
{
- int sqlcode;
+ char sqlcaid[8];
+ long sqlabc;
+ long sqlcode;
struct
{
int sqlerrml;
- char sqlerrmc[1000];
+ char sqlerrmc[70];
} sqlerrm;
+ char sqlerrp[8];
long sqlerrd[6];
+ /* Element 0: empty */
+ /* 1: empty */
+ /* 2: number of rows processed */
+ /* after an INSERT, UPDATE or*/
+ /* DELETE statement */
+ /* 3: empty */
+ /* 4: empty */
+ /* 5: empty */
+ char sqlwarn[8];
+ /* Element 0: set to 'W' if at least one other is 'W' */
+ /* 1: if 'W' at least one character string */
+ /* value was truncated when it was */
+ /* stored into a host variable. */
+ /* 2: empty */
+ /* 3: empty */
+ /* 4: empty */
+ /* 5: empty */
+ /* 6: empty */
+ /* 7: empty */
+
+ char sqlext[8];
} sqlca;
#endif
diff --git a/src/interfaces/ecpg/lib/Makefile.in b/src/interfaces/ecpg/lib/Makefile.in
index c402afc8446..1b38c6a539a 100644
--- a/src/interfaces/ecpg/lib/Makefile.in
+++ b/src/interfaces/ecpg/lib/Makefile.in
@@ -4,7 +4,7 @@ include $(SRCDIR)/Makefile.global
PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
SO_MAJOR_VERSION=2
-SO_MINOR_VERSION=2
+SO_MINOR_VERSION=3
PORTNAME=@PORTNAME@
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c
index 504a0388ccd..ecbd2354617 100644
--- a/src/interfaces/ecpg/lib/ecpglib.c
+++ b/src/interfaces/ecpg/lib/ecpglib.c
@@ -38,7 +38,7 @@ static FILE *debugstream = NULL;
static int committed = true;
static void
-register_error(int code, char *fmt,...)
+register_error(long code, char *fmt,...)
{
va_list args;
@@ -131,9 +131,9 @@ ECPGdo(int lineno, char *query,...)
long offset, ind_offset;
enum ECPGttype ind_type;
+ memset((char *) &sqlca, 0, sizeof (sqlca));
va_start(ap, query);
- sqlca.sqlcode = 0;
copiedquery = strdup(query);
type = va_arg(ap, enum ECPGttype);
@@ -666,6 +666,7 @@ ECPGdo(int lineno, char *query,...)
default:
break;
}
+ sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
}
}
}
@@ -702,6 +703,7 @@ ECPGdo(int lineno, char *query,...)
default:
break;
}
+ sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
var->len = varcharsize;
}
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 30b6d829a37..e90d0731c46 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2
MINOR_VERSION=3
-PATCHLEVEL=2
+PATCHLEVEL=3
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 138cd601d1c..9a7b348f619 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -643,9 +643,9 @@ output_statement(char * stmt, int mode)
%type <str> group_clause groupby_list groupby having_clause from_clause
%type <str> from_list from_val join_expr join_outer join_spec join_list
%type <str> join_using where_clause relation_expr row_op sub_type
-%type <str> opt_column_list insert_rest InsertStmt
+%type <str> opt_column_list insert_rest InsertStmt OptimizableStmt
%type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt
-%type <str> NotifyStmt columnElem copy_dirn OptimizableStmt
+%type <str> NotifyStmt columnElem copy_dirn
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
%type <str> opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name
%type <str> ClosePortalStmt DestroyStmt VacuumStmt opt_verbose
@@ -691,6 +691,7 @@ output_statement(char * stmt, int mode)
%type <action> action
%type <index> opt_array_bounds nest_array_bounds
+
%%
prog: statements;
@@ -735,7 +736,16 @@ stmt: AddAttrStmt { output_statement($1, 0); }
| RemoveStmt { output_statement($1, 0); }
| RenameStmt { output_statement($1, 0); }
| RevokeStmt { output_statement($1, 0); }
- | OptimizableStmt { /* output already written */ }
+ | OptimizableStmt {
+ if (strncmp($1, "/* declare" , sizeof("/* declare")-1) == 0)
+ {
+ fputs($1, yyout);
+ output_line_number();
+ free($1);
+ }
+ else
+ output_statement($1, 1);
+ }
| RuleStmt { output_statement($1, 0); }
| TransactionStmt {
fprintf(yyout, "ECPGtrans(__LINE__, \"%s\");", $1);
@@ -1989,7 +1999,7 @@ OptStmtMulti: OptStmtMulti OptimizableStmt ';'
| OptStmtMulti OptimizableStmt
{ $$ = cat2_str($1, $2); }
| OptimizableStmt ';'
- { $$ = $1; }
+ { $$ = cat2_str($1, make1_str(";")); }
;
event_object: relation_name '.' attr_name
@@ -2197,17 +2207,12 @@ ExplainStmt: EXPLAIN opt_verbose OptimizableStmt
* *
*****************************************************************************/
-OptimizableStmt: SelectStmt { output_statement($1, 1); }
- | CursorStmt
- {
- fputs($1, yyout);
- output_line_number();
- free($1);
- }
- | UpdateStmt { output_statement($1, 0); }
- | InsertStmt { output_statement($1, 0); }
- | NotifyStmt { output_statement($1, 0); }
- | DeleteStmt { output_statement($1, 0); }
+OptimizableStmt: SelectStmt
+ | CursorStmt
+ | UpdateStmt
+ | InsertStmt
+ | NotifyStmt
+ | DeleteStmt
;
@@ -2334,7 +2339,7 @@ CursorStmt: DECLARE name opt_binary CURSOR FOR
cur = this;
}
- $$ = cat5_str(make1_str("/* declare cursor\""), $2, make1_str("\"statement has been moved to location of open cursor \""), strdup($2), make1_str("\"statement. */"));
+ $$ = make5_str(make1_str("/* declare cursor \""), $2, make1_str("\" statement has been moved to location of open cursor \""), strdup($2), make1_str("\" statement. */"));
}
;
@@ -4584,7 +4589,7 @@ cinputvariable : cvariable indicator {
add_variable(&argsinsert, find_variable($1), ($2 == NULL) ? &no_indicator : find_variable($2));
}
-civariableonly : cvariable name {
+civariableonly : cvariable {
add_variable(&argsinsert, find_variable($1), &no_indicator);
}
diff --git a/src/interfaces/ecpg/test/header_test.h b/src/interfaces/ecpg/test/header_test.h
index cc84aed778f..7d495ac64fb 100644
--- a/src/interfaces/ecpg/test/header_test.h
+++ b/src/interfaces/ecpg/test/header_test.h
@@ -1,4 +1,3 @@
exec sql include sqlca;
-exec sql whenever not found do break;
exec sql whenever sqlerror sqlprint;
diff --git a/src/interfaces/ecpg/test/test2.pgc b/src/interfaces/ecpg/test/test2.pgc
index 3b7ff3f9d55..324a63b941b 100644
--- a/src/interfaces/ecpg/test/test2.pgc
+++ b/src/interfaces/ecpg/test/test2.pgc
@@ -48,6 +48,8 @@ exec sql end declare section;
strcpy(msg, "open");
exec sql open cur;
+ exec sql whenever not found do break;
+
while (1) {
strcpy(msg, "fetch");
exec sql fetch cur into :personal:ind_personal, :married:ind_married;