Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2a74511

Browse files
committed
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
1 parent 0b09955 commit 2a74511

File tree

9 files changed

+74
-24
lines changed

9 files changed

+74
-24
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,12 @@ Wed May 20 10:46:48 CEST 1998
239239
initialization.
240240
- Added enum datatype.
241241
- Set version to 2.3.2
242+
243+
Wed Jun 3 13:38:57 CEST 1998
244+
245+
- Made sqlca struct compatible with other systems.
246+
- Give back a warning in case of truncation
247+
- Changed the handling of OptimizableStmt since the old one broke
248+
CREATE RULE
249+
- Set library version to 2.3
250+
- Set version to 2.3.3

src/interfaces/ecpg/TODO

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@ section of the structure variable for ecpg to be able to understand it.
33

44
Variable type bool has to be checked. I never used it so far.
55

6+
The error message for "no data" in an exec sql insert select from statement
7+
has to be 100.
8+
9+
sqlwarn[6] should be 'W' if the PRECISION or SCALE value specified in a SET
10+
DESCRIPTOR statement will be ignored.
11+
12+
it would be nice to be able to use :var[:index] as cvariable
13+
614
Missing statements:
715
- exec sql type
816
- exec sql define
917
- exec sql prepare
1018
- exec sql allocate
1119
- exqc sql free
1220
- SQLSTATE
21+
- exec sql whenever sqlwarning

src/interfaces/ecpg/include/sqlca.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,37 @@ extern "C" {
77

88
struct sqlca
99
{
10-
int sqlcode;
10+
char sqlcaid[8];
11+
long sqlabc;
12+
long sqlcode;
1113
struct
1214
{
1315
int sqlerrml;
14-
char sqlerrmc[1000];
16+
char sqlerrmc[70];
1517
} sqlerrm;
18+
char sqlerrp[8];
1619
long sqlerrd[6];
20+
/* Element 0: empty */
21+
/* 1: empty */
22+
/* 2: number of rows processed */
23+
/* after an INSERT, UPDATE or*/
24+
/* DELETE statement */
25+
/* 3: empty */
26+
/* 4: empty */
27+
/* 5: empty */
28+
char sqlwarn[8];
29+
/* Element 0: set to 'W' if at least one other is 'W' */
30+
/* 1: if 'W' at least one character string */
31+
/* value was truncated when it was */
32+
/* stored into a host variable. */
33+
/* 2: empty */
34+
/* 3: empty */
35+
/* 4: empty */
36+
/* 5: empty */
37+
/* 6: empty */
38+
/* 7: empty */
39+
40+
char sqlext[8];
1741
} sqlca;
1842

1943
#endif

src/interfaces/ecpg/lib/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(SRCDIR)/Makefile.global
44
PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
55

66
SO_MAJOR_VERSION=2
7-
SO_MINOR_VERSION=2
7+
SO_MINOR_VERSION=3
88

99
PORTNAME=@PORTNAME@
1010

src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static FILE *debugstream = NULL;
3838
static int committed = true;
3939

4040
static void
41-
register_error(int code, char *fmt,...)
41+
register_error(long code, char *fmt,...)
4242
{
4343
va_list args;
4444

@@ -131,9 +131,9 @@ ECPGdo(int lineno, char *query,...)
131131
long offset, ind_offset;
132132
enum ECPGttype ind_type;
133133

134+
memset((char *) &sqlca, 0, sizeof (sqlca));
134135
va_start(ap, query);
135136

136-
sqlca.sqlcode = 0;
137137
copiedquery = strdup(query);
138138

139139
type = va_arg(ap, enum ECPGttype);
@@ -666,6 +666,7 @@ ECPGdo(int lineno, char *query,...)
666666
default:
667667
break;
668668
}
669+
sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
669670
}
670671
}
671672
}
@@ -702,6 +703,7 @@ ECPGdo(int lineno, char *query,...)
702703
default:
703704
break;
704705
}
706+
sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
705707

706708
var->len = varcharsize;
707709
}

src/interfaces/ecpg/preproc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=2
55
MINOR_VERSION=3
6-
PATCHLEVEL=2
6+
PATCHLEVEL=3
77

88
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,9 @@ output_statement(char * stmt, int mode)
643643
%type <str> group_clause groupby_list groupby having_clause from_clause
644644
%type <str> from_list from_val join_expr join_outer join_spec join_list
645645
%type <str> join_using where_clause relation_expr row_op sub_type
646-
%type <str> opt_column_list insert_rest InsertStmt
646+
%type <str> opt_column_list insert_rest InsertStmt OptimizableStmt
647647
%type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt
648-
%type <str> NotifyStmt columnElem copy_dirn OptimizableStmt
648+
%type <str> NotifyStmt columnElem copy_dirn
649649
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
650650
%type <str> opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name
651651
%type <str> ClosePortalStmt DestroyStmt VacuumStmt opt_verbose
@@ -691,6 +691,7 @@ output_statement(char * stmt, int mode)
691691
%type <action> action
692692

693693
%type <index> opt_array_bounds nest_array_bounds
694+
694695
%%
695696
prog: statements;
696697

@@ -735,7 +736,16 @@ stmt: AddAttrStmt { output_statement($1, 0); }
735736
| RemoveStmt { output_statement($1, 0); }
736737
| RenameStmt { output_statement($1, 0); }
737738
| RevokeStmt { output_statement($1, 0); }
738-
| OptimizableStmt { /* output already written */ }
739+
| OptimizableStmt {
740+
if (strncmp($1, "/* declare" , sizeof("/* declare")-1) == 0)
741+
{
742+
fputs($1, yyout);
743+
output_line_number();
744+
free($1);
745+
}
746+
else
747+
output_statement($1, 1);
748+
}
739749
| RuleStmt { output_statement($1, 0); }
740750
| TransactionStmt {
741751
fprintf(yyout, "ECPGtrans(__LINE__, \"%s\");", $1);
@@ -1989,7 +1999,7 @@ OptStmtMulti: OptStmtMulti OptimizableStmt ';'
19891999
| OptStmtMulti OptimizableStmt
19902000
{ $$ = cat2_str($1, $2); }
19912001
| OptimizableStmt ';'
1992-
{ $$ = $1; }
2002+
{ $$ = cat2_str($1, make1_str(";")); }
19932003
;
19942004

19952005
event_object: relation_name '.' attr_name
@@ -2197,17 +2207,12 @@ ExplainStmt: EXPLAIN opt_verbose OptimizableStmt
21972207
* *
21982208
*****************************************************************************/
21992209

2200-
OptimizableStmt: SelectStmt { output_statement($1, 1); }
2201-
| CursorStmt
2202-
{
2203-
fputs($1, yyout);
2204-
output_line_number();
2205-
free($1);
2206-
}
2207-
| UpdateStmt { output_statement($1, 0); }
2208-
| InsertStmt { output_statement($1, 0); }
2209-
| NotifyStmt { output_statement($1, 0); }
2210-
| DeleteStmt { output_statement($1, 0); }
2210+
OptimizableStmt: SelectStmt
2211+
| CursorStmt
2212+
| UpdateStmt
2213+
| InsertStmt
2214+
| NotifyStmt
2215+
| DeleteStmt
22112216
;
22122217

22132218

@@ -2334,7 +2339,7 @@ CursorStmt: DECLARE name opt_binary CURSOR FOR
23342339
cur = this;
23352340
}
23362341

2337-
$$ = cat5_str(make1_str("/* declare cursor\""), $2, make1_str("\"statement has been moved to location of open cursor \""), strdup($2), make1_str("\"statement. */"));
2342+
$$ = make5_str(make1_str("/* declare cursor \""), $2, make1_str("\" statement has been moved to location of open cursor \""), strdup($2), make1_str("\" statement. */"));
23382343
}
23392344
;
23402345

@@ -4584,7 +4589,7 @@ cinputvariable : cvariable indicator {
45844589
add_variable(&argsinsert, find_variable($1), ($2 == NULL) ? &no_indicator : find_variable($2));
45854590
}
45864591

4587-
civariableonly : cvariable name {
4592+
civariableonly : cvariable {
45884593
add_variable(&argsinsert, find_variable($1), &no_indicator);
45894594
}
45904595

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
exec sql include sqlca;
22

3-
exec sql whenever not found do break;
43
exec sql whenever sqlerror sqlprint;

src/interfaces/ecpg/test/test2.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ exec sql end declare section;
4848
strcpy(msg, "open");
4949
exec sql open cur;
5050

51+
exec sql whenever not found do break;
52+
5153
while (1) {
5254
strcpy(msg, "fetch");
5355
exec sql fetch cur into :personal:ind_personal, :married:ind_married;

0 commit comments

Comments
 (0)