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

Commitdb07a3f

Browse files
author
Michael Meskes
committed
- Synced preproc.y with gram.y.
- Include some patches by Christof Petig <christof.petig@wtal.de>.
1 parent0c439e5 commitdb07a3f

File tree

8 files changed

+160
-57
lines changed

8 files changed

+160
-57
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,3 +1086,8 @@ Wed Jun 13 14:39:12 CEST 2001
10861086
- Applied bug fix by John Summerfield.
10871087
- Set ecpg version to 2.9.0.
10881088
- Set library version to 3.3.0.
1089+
1090+
Son Aug 19 11:04:39 CEST 2001
1091+
1092+
- Synced preproc.y with gram.y.
1093+
- Include some patches by Christof Petig <christof.petig@wtal.de>.

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

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
6565
{
6666
switch (vartype)
6767
{
68-
caseECPGt_short:
68+
caseECPGt_short:
6969
*(short*)var= (short)value;
7070
break;
7171
caseECPGt_int:
@@ -143,13 +143,16 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
143143
va_listargs;
144144
PGresult*ECPGresult=ECPGresultByDescriptor(lineno,desc_name);
145145
enumECPGdtypetype;
146-
boolDataButNoIndicator= false;
146+
boolIndicator_seen= false,
147+
Data_seen= false;
148+
intntuples,act_tuple;
147149

148150
va_start(args,index);
149151
if (!ECPGresult)
150152
return (false);
151153

152-
if (PQntuples(ECPGresult)<1)
154+
ntuples=PQntuples(ECPGresult);
155+
if (ntuples<1)
153156
{
154157
ECPGraise(lineno,ECPG_NOT_FOUND,NULL);
155158
return (false);
@@ -184,10 +187,23 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
184187
switch (type)
185188
{
186189
case (ECPGd_indicator):
187-
if (!get_int_item(lineno,var,vartype,-PQgetisnull(ECPGresult,0,index)))
188-
return (false);
189-
190-
ECPGlog("ECPGget_desc: INDICATOR = %d\n",-PQgetisnull(ECPGresult,0,index));
190+
/* this is like ECPGexecute
191+
* missing : allocate arrays, perhaps this should go into
192+
* a common function !!
193+
*/
194+
if (ntuples>arrsize)
195+
{ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
196+
lineno,ntuples,arrsize);
197+
ECPGraise(lineno,ECPG_TOO_MANY_MATCHES,NULL);
198+
return false;
199+
}
200+
Indicator_seen= true;
201+
for (act_tuple=0;act_tuple<ntuples ;act_tuple++)
202+
{if (!get_int_item(lineno,var,vartype,-PQgetisnull(ECPGresult,act_tuple,index)))
203+
return (false);
204+
var= (char*)var+offset;
205+
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n",act_tuple,-PQgetisnull(ECPGresult,act_tuple,index));
206+
}
191207
break;
192208

193209
caseECPGd_name:
@@ -225,10 +241,22 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
225241

226242
caseECPGd_ret_length:
227243
caseECPGd_ret_octet:
228-
if (!get_int_item(lineno,var,vartype,PQgetlength(ECPGresult,0,index)))
229-
return (false);
230-
231-
ECPGlog("ECPGget_desc: RETURNED = %d\n",PQgetlength(ECPGresult,0,index));
244+
/* this is like ECPGexecute
245+
* missing : allocate arrays, perhaps this should go into
246+
* a common function !!
247+
*/
248+
if (ntuples>arrsize)
249+
{ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
250+
lineno,ntuples,arrsize);
251+
ECPGraise(lineno,ECPG_TOO_MANY_MATCHES,NULL);
252+
return false;
253+
}
254+
for (act_tuple=0;act_tuple<ntuples ;act_tuple++)
255+
{if (!get_int_item(lineno,var,vartype,PQgetlength(ECPGresult,act_tuple,index)))
256+
return (false);
257+
var= (char*)var+offset;
258+
ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n",act_tuple,PQgetlength(ECPGresult,act_tuple,index));
259+
}
232260
break;
233261

234262
caseECPGd_octet:
@@ -259,9 +287,32 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
259287
ECPGlog("ECPGget_desc: TYPE = %d\n",ECPGDynamicType_DDT(PQftype(ECPGresult,index)));
260288
break;
261289
caseECPGd_data:
262-
if (!get_data(ECPGresult,0,index,lineno,vartype,ECPGt_NO_INDICATOR,var,NULL,varcharsize,offset, false))
290+
/* this is like ECPGexecute
291+
* missing : allocate arrays, perhaps this should go into
292+
* a common function !!
293+
*/
294+
if (ntuples>arrsize)
295+
{ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
296+
lineno,ntuples,arrsize);
297+
ECPGraise(lineno,ECPG_TOO_MANY_MATCHES,NULL);
298+
return false;
299+
}
300+
Data_seen= true;
301+
for (act_tuple=0;act_tuple<ntuples ;act_tuple++)
302+
{if (PQgetisnull(ECPGresult,act_tuple,index))
303+
continue;/* do not touch data on null value */
304+
if (!get_data(ECPGresult,act_tuple,index,lineno,
305+
vartype,ECPGt_NO_INDICATOR,var,NULL,
306+
varcharsize,offset, false))
307+
return (false);
308+
}
309+
break;
310+
311+
caseECPGd_cardinality:
312+
if (!get_int_item(lineno,var,vartype,PQntuples(ECPGresult)))
263313
return (false);
264314

315+
ECPGlog("ECPGget_desc: CARDINALITY = %d\n",PQntuples(ECPGresult));
265316
break;
266317

267318
default:
@@ -273,10 +324,15 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
273324
type=va_arg(args,enumECPGdtype);
274325
}
275326

276-
if (DataButNoIndicator&&PQgetisnull(ECPGresult,0,index))
277-
{
278-
ECPGraise(lineno,ECPG_MISSING_INDICATOR,NULL);
279-
return (false);
327+
if (Data_seen&& !Indicator_seen)
328+
{
329+
for (act_tuple=0;act_tuple<ntuples ;act_tuple++)
330+
{if (PQgetisnull(ECPGresult,act_tuple,index))
331+
{
332+
ECPGraise(lineno,ECPG_MISSING_INDICATOR,NULL);
333+
return (false);
334+
}
335+
}
280336
}
281337

282338
return (true);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,9 @@ ECPGexecute(struct statement * stmt)
812812
ECPGraise(stmt->lineno,ECPG_PGSQL,PQerrorMessage(stmt->connection->connection));
813813
}
814814
else
815+
/* note: since some of the following code is duplicated in descriptor.c
816+
* it should go into a separate function
817+
*/
815818
{
816819
var=stmt->outlist;
817820
switch (PQresultStatus(results))
@@ -1032,7 +1035,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10321035
*
10331036
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
10341037
*
1035-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.20 2001/08/10 22:50:10 tgl Exp $
1038+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.21 2001/08/19 09:21:44 meskes Exp $
10361039
*/
10371040

10381041
PGconn*ECPG_internal_get_connection(char*name);

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/*
22
* functions needed for descriptor handling
3+
*
4+
* since descriptor might be either a string constant or a string var
5+
* we need to check for a constant if we expect a constant
36
*/
47

58
#include"postgres_fe.h"
@@ -71,7 +74,11 @@ static struct descriptor *descriptors;
7174
void
7275
add_descriptor(char*name,char*connection)
7376
{
74-
structdescriptor*new= (structdescriptor*)mm_alloc(sizeof(structdescriptor));
77+
structdescriptor*new;
78+
79+
if (name[0]!='"')return;
80+
81+
new= (structdescriptor*)mm_alloc(sizeof(structdescriptor));
7582

7683
new->next=descriptors;
7784
new->name=mm_alloc(strlen(name)+1);
@@ -92,6 +99,8 @@ drop_descriptor(char *name, char *connection)
9299
structdescriptor*i;
93100
structdescriptor**lastptr=&descriptors;
94101

102+
if (name[0]!='"')return;
103+
95104
for (i=descriptors;i;lastptr=&i->next,i=i->next)
96105
{
97106
if (!strcmp(name,i->name))
@@ -119,6 +128,8 @@ lookup_descriptor(char *name, char *connection)
119128
{
120129
structdescriptor*i;
121130

131+
if (name[0]!='"')returnNULL;
132+
122133
for (i=descriptors;i;i=i->next)
123134
{
124135
if (!strcmp(name,i->name))
@@ -139,7 +150,7 @@ output_get_descr_header(char *desc_name)
139150
{
140151
structassignment*results;
141152

142-
fprintf(yyout,"{ ECPGget_desc_header(%d,\"%s\", &(",yylineno,desc_name);
153+
fprintf(yyout,"{ ECPGget_desc_header(%d,%s, &(",yylineno,desc_name);
143154
for (results=assignments;results!=NULL;results=results->next)
144155
{
145156
if (results->value==ECPGd_count)
@@ -161,7 +172,7 @@ output_get_descr(char *desc_name, char *index)
161172
{
162173
structassignment*results;
163174

164-
fprintf(yyout,"{ ECPGget_desc(%d,\"%s\",%s,",yylineno,desc_name,index);
175+
fprintf(yyout,"{ ECPGget_desc(%d, %s,%s,",yylineno,desc_name,index);
165176
for (results=assignments;results!=NULL;results=results->next)
166177
{
167178
conststructvariable*v=find_variable(results->variable);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* lexical token lookup for reserved words in postgres embedded SQL
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.23 2001/03/22 04:01:20 momjian Exp $
7+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.24 2001/08/19 09:21:44 meskes Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -29,6 +29,7 @@ static ScanKeyword ScanKeywords[] = {
2929
{"bool",SQL_BOOL},
3030
{"break",SQL_BREAK},
3131
{"call",SQL_CALL},
32+
{"cardinality",SQL_CARDINALITY},
3233
{"connect",SQL_CONNECT},
3334
{"connection",SQL_CONNECTION},
3435
{"continue",SQL_CONTINUE},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ output_statement(char *stmt, int mode, char *descriptor, char *con)
111111
if (descriptor==NULL)
112112
fprintf(yyout,"{ ECPGdo(__LINE__, %s, \"",con ?con :"NULL");
113113
else
114-
fprintf(yyout,"{ ECPGdo_descriptor(__LINE__, %s,\"%s\", \"",
114+
fprintf(yyout,"{ ECPGdo_descriptor(__LINE__, %s,%s, \"",
115115
con ?con :"NULL",descriptor);
116116

117117
/* do this char by char as we have to filter '\"' */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp