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

Commit991b974

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent62f0645 commit991b974

File tree

21 files changed

+623
-333
lines changed

21 files changed

+623
-333
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,5 +819,10 @@ Thu Feb 17 19:37:44 CET 2000
819819

820820
- Synced preproc.y with gram.y.
821821
- Started to clean up preproc.y.
822+
823+
Tue Feb 22 13:48:18 CET 2000
824+
825+
- Synced preproc.y with gram.y.
826+
- Much more clean ups.
822827
- Set library version to 3.1.0.
823828
- Set ecpg version to 2.7.0.

‎src/interfaces/ecpg/TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ instead of libpq so we can write backend functions using ecpg.
2828

2929
make ECPGnumeric_lvalue more accurate by using something like ECPGdump_a_*
3030

31+
remove space_or_nl and line_end from pgc.l
32+
3133
Missing statements:
3234
- exec sql ifdef
3335
- SQLSTATE

‎src/interfaces/ecpg/include/ecpgerrno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
/* dynamic SQL related */
3333
#defineECPG_UNKNOWN_DESCRIPTOR-240
3434
#defineECPG_INVALID_DESCRIPTOR_INDEX-241
35+
#defineECPG_UNKNOWN_DESCRIPTOR_ITEM-242
36+
#defineECPG_VAR_NOT_NUMERIC-243
3537

3638
/* finally the backend error messages, they start at 400 */
3739
#defineECPG_PGSQL-400

‎src/interfaces/ecpg/include/ecpglib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ extern"C"
6161
boolECPGallocate_desc(intline,constchar*name);
6262
voidECPGraise(intline,intcode,constchar*str);
6363
boolECPGget_desc_header(int,char*,int*);
64+
boolECPGget_desc(int,char*,int, ...);
6465

6566

6667
#ifdef__cplusplus

‎src/interfaces/ecpg/include/ecpgtype.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ extern"C"
4949
ECPGt_EORT,/* End of result types. */
5050
ECPGt_NO_INDICATOR/* no indicator */
5151
};
52+
53+
enumECPGdtype
54+
{
55+
ECPGd_count,
56+
ECPGd_data,
57+
ECPGd_di_code,
58+
ECPGd_di_precision,
59+
ECPGd_indicator,
60+
ECPGd_key_member,
61+
ECPGd_length,
62+
ECPGd_name,
63+
ECPGd_nullable,
64+
ECPGd_octet,
65+
ECPGd_precision,
66+
ECPGd_ret_length,
67+
ECPGd_ret_octet,
68+
ECPGd_scale,
69+
ECPGd_type,
70+
ECPGd_EODT,/* End of descriptor types. */
71+
};
5272

5373
#defineIS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)
5474

‎src/interfaces/ecpg/lib/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1994, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.58 2000/02/16 16:18:05 meskes Exp $
9+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.59 2000/02/22 19:57:05 meskes Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -23,7 +23,7 @@ ifdef KRBVERS
2323
CFLAGS+=$(KRBFLAGS)
2424
endif
2525

26-
OBJS= ecpglib.o typename.o
26+
OBJS= ecpglib.o typename.o descriptor.o
2727

2828
SHLIB_LINK= -L../../libpq -lpq
2929

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

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,157 @@ ECPGget_desc_header(int lineno, char * desc_name, int *count)
1010
return false;
1111

1212
*count=PQnfields(ECPGresult);
13-
ECPGlog("ECPGget-desc_header: found %dsttributes.\n",*count);
13+
ECPGlog("ECPGget_desc_header: found %dattributes.\n",*count);
1414
return true;
1515
}
16+
17+
staticbool
18+
get_int_item(intlineno,void*var,enumECPGdtypevartype,intvalue)
19+
{
20+
switch (vartype)
21+
{
22+
caseECPGt_short:
23+
*(short*)var=value;
24+
break;
25+
caseECPGt_int:
26+
*(int*)var=value;
27+
break;
28+
caseECPGt_long:
29+
*(long*)var=value;
30+
break;
31+
caseECPGt_unsigned_short:
32+
*(unsigned short*)var=value;
33+
break;
34+
caseECPGt_unsigned_int:
35+
*(unsignedint*)var=value;
36+
break;
37+
caseECPGt_unsigned_long:
38+
*(unsigned long*)var=value;
39+
break;
40+
caseECPGt_float:
41+
*(float*)var=value;
42+
break;
43+
caseECPGt_double:
44+
*(double*)var=value;
45+
break;
46+
default:
47+
ECPGraise(lineno,ECPG_VAR_NOT_NUMERIC,NULL);
48+
return (false);
49+
}
50+
51+
return(true);
52+
}
53+
54+
bool
55+
ECPGget_desc(intlineno,char*desc_name,intindex, ...)
56+
{
57+
va_listargs;
58+
PGresult*ECPGresult=ECPGresultByDescriptor(lineno,desc_name);
59+
enumECPGdtypetype;
60+
boolDataButNoIndicator= false;
61+
62+
va_start(args,index);
63+
if (!ECPGresult)
64+
return (false);
65+
66+
if (PQntuples(ECPGresult)<1)
67+
{
68+
ECPGraise(lineno,ECPG_NOT_FOUND,NULL);
69+
return (false);
70+
}
71+
72+
if (index<1||index>PQnfields(ECPGresult))
73+
{
74+
ECPGraise(lineno,ECPG_INVALID_DESCRIPTOR_INDEX,NULL);
75+
return (false);
76+
}
77+
78+
ECPGlog("ECPGget_desc: reading items for tuple %d\n",index);
79+
--index;
80+
81+
type=va_arg(args,enumECPGdtype);
82+
83+
while (type!=ECPGd_EODT)
84+
{
85+
chartype_str[20];
86+
longvarcharsize;
87+
longoffset;
88+
longarrsize;
89+
enumECPGttypevartype;
90+
void*var;
91+
92+
vartype=va_arg(args,enumECPGttype);
93+
var=va_arg(args,void*);
94+
varcharsize=va_arg(args,long);
95+
arrsize=va_arg(args,long);
96+
offset=va_arg(args,long);
97+
98+
switch (type)
99+
{
100+
case (ECPGd_indicator):
101+
if (!get_int_item(lineno,var,vartype,-PQgetisnull(ECPGresult,0,index)))
102+
return (false);
103+
break;
104+
105+
caseECPGd_name:
106+
strncpy((char*)var,PQfname(ECPGresult,index),varcharsize);
107+
break;
108+
109+
caseECPGd_nullable:
110+
if (!get_int_item(lineno,var,vartype,1))
111+
return (false);
112+
break;
113+
114+
caseECPGd_key_member:
115+
if (!get_int_item(lineno,var,vartype,0))
116+
return (false);
117+
break;
118+
119+
caseECPGd_scale:
120+
if (!get_int_item(lineno,var,vartype, (PQfmod(ECPGresult,index)-VARHDRSZ)&0xffff))
121+
return (false);
122+
break;
123+
124+
caseECPGd_precision:
125+
if (!get_int_item(lineno,var,vartype,PQfmod(ECPGresult,index) >>16))
126+
return (false);
127+
break;
128+
129+
caseECPGd_ret_length:
130+
caseECPGd_ret_octet:
131+
if (!get_int_item(lineno,var,vartype,PQgetlength(ECPGresult,0,index)))
132+
return (false);
133+
break;
134+
135+
caseECPGd_octet:
136+
if (!get_int_item(lineno,var,vartype,PQfsize(ECPGresult,index)))
137+
return (false);
138+
break;
139+
140+
caseECPGd_length:
141+
if (!get_int_item(lineno,var,vartype,PQfmod(ECPGresult,index)-VARHDRSZ))
142+
return (false);
143+
break;
144+
145+
caseECPGd_type:
146+
if (!get_int_item(lineno,var,vartype,ECPGDynamicType(PQftype(ECPGresult,index))))
147+
return (false);
148+
break;
149+
150+
default:
151+
snprintf(type_str,sizeof(type_str),"%d",type);
152+
ECPGraise(lineno,ECPG_UNKNOWN_DESCRIPTOR_ITEM,type_str);
153+
return(false);
154+
}
155+
156+
type=va_arg(args,enumECPGdtype);
157+
}
158+
159+
if (DataButNoIndicator&&PQgetisnull(ECPGresult,0,index))
160+
{
161+
ECPGraise(lineno,ECPG_MISSING_INDICATOR,NULL);
162+
return (false);
163+
}
164+
165+
return (true);
166+
}

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.4 2000/02/18 16:02:49 meskes Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.5 2000/02/22 19:57:05 meskes Exp $
66
*/
77

88
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
@@ -198,15 +198,16 @@ bool ECPGdo_descriptor(int line,const char *connection,
198198

199199
/* free previous result */
200200
if (i->result)PQclear(i->result);
201-
i->result=NULL;
201+
i->result=NULL;
202202

203203
status=do_descriptor2(line,connection,&i->result,query);
204204

205205
if (!i->result)PQmakeEmptyPGresult(NULL,0);
206206
return (status);
207207
}
208208
}
209-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
209+
210+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,descriptor);
210211
return false;
211212
}
212213

@@ -219,7 +220,7 @@ PGresult *ECPGresultByDescriptor(int line,const char *name)
219220
if (!strcmp(name,i->name))returni->result;
220221
}
221222

222-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
223+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,name);
223224

224225
returnNULL;
225226
}
@@ -238,7 +239,7 @@ bool ECPGdeallocate_desc(int line,const char *name)
238239
return true;
239240
}
240241
}
241-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
242+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,name);
242243
return false;
243244
}
244245

@@ -259,7 +260,7 @@ ECPGraise(int line, int code, const char *str)
259260
{
260261
structauto_mem*am;
261262

262-
sqlca.sqlcode=code;
263+
sqlca.sqlcode=code;
263264
switch (code)
264265
{
265266
caseECPG_NOT_FOUND:
@@ -294,15 +295,25 @@ ECPGraise(int line, int code, const char *str)
294295

295296
caseECPG_UNKNOWN_DESCRIPTOR:
296297
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
297-
"descriptor not found, line %d.",line);
298+
"descriptor%snot found, line %d.",str,line);
298299
break;
299300

300301
caseECPG_INVALID_DESCRIPTOR_INDEX:
301302
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
302303
"descriptor index out of range, line %d.",line);
303304
break;
305+
306+
caseECPG_UNKNOWN_DESCRIPTOR_ITEM:
307+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
308+
"unknown descriptor item %s, line %d.",str,line);
309+
break;
310+
311+
caseECPG_VAR_NOT_NUMERIC:
312+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
313+
"variable is not a numeric type, line %d.",line);
314+
break;
304315

305-
default:
316+
default:
306317
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
307318
"SQL error #%d, line %d.",code,line);
308319
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp