From: Marc G. Fournier Date: Wed, 3 Jun 1998 13:55:15 +0000 (+0000) Subject: From: Michael Meskes X-Git-Tag: REL6_4_2~935 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a74511bf4a66bc878ebf1eb097fa68062b7233f;p=postgresql From: Michael Meskes + 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/ChangeLog b/src/interfaces/ecpg/ChangeLog index 0211c321cb..bef6e29787 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 06a818d1e8..b174b56e5e 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 7e99484d5a..7d6c999434 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 c402afc844..1b38c6a539 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 504a0388cc..ecbd235461 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 30b6d829a3..e90d0731c4 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 138cd601d1..9a7b348f61 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 group_clause groupby_list groupby having_clause from_clause %type from_list from_val join_expr join_outer join_spec join_list %type join_using where_clause relation_expr row_op sub_type -%type opt_column_list insert_rest InsertStmt +%type opt_column_list insert_rest InsertStmt OptimizableStmt %type columnList DeleteStmt LockStmt UpdateStmt CursorStmt -%type NotifyStmt columnElem copy_dirn OptimizableStmt +%type NotifyStmt columnElem copy_dirn %type copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary %type opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name %type ClosePortalStmt DestroyStmt VacuumStmt opt_verbose @@ -691,6 +691,7 @@ output_statement(char * stmt, int mode) %type action %type 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 cc84aed778..7d495ac64f 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 3b7ff3f9d5..324a63b941 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;