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

Commitfb7b1df

Browse files
author
Michael Meskes
committed
Fixed bug that caused arrays of varchar to be output with incomplete name.
In the process expanded one test case,
1 parent0f855d6 commitfb7b1df

File tree

6 files changed

+122
-71
lines changed

6 files changed

+122
-71
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,3 +2322,8 @@ Sun, 17 Feb 2008 18:45:39 +0100
23222322
- Removed duplicate include of ecpgtype.h.
23232323
- Changed INFORMIX mode symbol definition yet again because the old
23242324
way didn't work on NetBSD.
2325+
2326+
Sun, 02 Mar 2008 11:50:48 +0100
2327+
2328+
- Fixed bug that caused arrays of varchar to be output with incomplete
2329+
name.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.77 2007/12/21 14:33:20 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.78 2008/03/02 10:54:11 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -259,7 +259,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
259259

260260
ECPGdump_a_simple(o,name,
261261
type->u.element->type,
262-
type->u.element->size,type->size,NULL,prefix,type->lineno);
262+
type->u.element->size,type->size,NULL,prefix,type->u.element->lineno);
263263

264264
if (ind_type!=NULL)
265265
{

‎src/interfaces/ecpg/test/expected/preproc-array_of_struct.c

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ int main( int argc, char * argv[] )
8181

8282

8383

84+
8485

8586
#line 26 "array_of_struct.pgc"
8687
customercusts1 [10 ] ;
@@ -111,71 +112,74 @@ int main( int argc, char * argv[] )
111112

112113
#line 44 "array_of_struct.pgc"
113114
intr ;
114-
/* exec sql end declare section */
115+
115116
#line 45 "array_of_struct.pgc"
117+
structvarchar_onlyname_45 {intlen;chararr[50 ]; }onlyname [2] ;
118+
/* exec sql end declare section */
119+
#line 46 "array_of_struct.pgc"
116120

117121

118122
ECPGdebug(1,stderr);
119123

120124
{ECPGconnect(__LINE__,0,"regress1" ,NULL,NULL ,NULL,0);
121-
#line49 "array_of_struct.pgc"
125+
#line50 "array_of_struct.pgc"
122126

123127
if (sqlca.sqlwarn[0]=='W')sqlprint();
124-
#line49 "array_of_struct.pgc"
128+
#line50 "array_of_struct.pgc"
125129

126130
if (sqlca.sqlcode<0)sqlprint();}
127-
#line49 "array_of_struct.pgc"
131+
#line50 "array_of_struct.pgc"
128132

129133

130134
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"create table customers ( c varchar ( 50 ) , p int ) ",ECPGt_EOIT,ECPGt_EORT);
131-
#line51 "array_of_struct.pgc"
135+
#line52 "array_of_struct.pgc"
132136

133137
if (sqlca.sqlwarn[0]=='W')sqlprint();
134-
#line51 "array_of_struct.pgc"
138+
#line52 "array_of_struct.pgc"
135139

136140
if (sqlca.sqlcode<0)sqlprint();}
137-
#line51 "array_of_struct.pgc"
141+
#line52 "array_of_struct.pgc"
138142

139143
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"insert into customers values ( 'John Doe' , '12345' ) ",ECPGt_EOIT,ECPGt_EORT);
140-
#line52 "array_of_struct.pgc"
144+
#line53 "array_of_struct.pgc"
141145

142146
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
143-
#line52 "array_of_struct.pgc"
147+
#line53 "array_of_struct.pgc"
144148

145149
if (sqlca.sqlwarn[0]=='W')sqlprint();
146-
#line52 "array_of_struct.pgc"
150+
#line53 "array_of_struct.pgc"
147151

148152
if (sqlca.sqlcode<0)sqlprint();}
149-
#line52 "array_of_struct.pgc"
153+
#line53 "array_of_struct.pgc"
150154

151155
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"insert into customers values ( 'Jane Doe' , '67890' ) ",ECPGt_EOIT,ECPGt_EORT);
152-
#line53 "array_of_struct.pgc"
156+
#line54 "array_of_struct.pgc"
153157

154158
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
155-
#line53 "array_of_struct.pgc"
159+
#line54 "array_of_struct.pgc"
156160

157161
if (sqlca.sqlwarn[0]=='W')sqlprint();
158-
#line53 "array_of_struct.pgc"
162+
#line54 "array_of_struct.pgc"
159163

160164
if (sqlca.sqlcode<0)sqlprint();}
161-
#line53 "array_of_struct.pgc"
165+
#line54 "array_of_struct.pgc"
162166

163167

164168
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"select * from customers limit 2 ",ECPGt_EOIT,
165169
ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof(customer ),
166170
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof(structind ),
167171
ECPGt_int,&(custs1->phone),(long)1,(long)10,sizeof(customer ),
168172
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof(structind ),ECPGt_EORT);
169-
#line55 "array_of_struct.pgc"
173+
#line56 "array_of_struct.pgc"
170174

171175
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
172-
#line55 "array_of_struct.pgc"
176+
#line56 "array_of_struct.pgc"
173177

174178
if (sqlca.sqlwarn[0]=='W')sqlprint();
175-
#line55 "array_of_struct.pgc"
179+
#line56 "array_of_struct.pgc"
176180

177181
if (sqlca.sqlcode<0)sqlprint();}
178-
#line55 "array_of_struct.pgc"
182+
#line56 "array_of_struct.pgc"
179183

180184
printf("custs1:\n");
181185
for (r=0;r<2;r++)
@@ -189,16 +193,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
189193
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof(structind ),
190194
ECPGt_int,&(custs2->phone),(long)1,(long)10,sizeof(customer2 ),
191195
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof(structind ),ECPGt_EORT);
192-
#line63 "array_of_struct.pgc"
196+
#line64 "array_of_struct.pgc"
193197

194198
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
195-
#line63 "array_of_struct.pgc"
199+
#line64 "array_of_struct.pgc"
196200

197201
if (sqlca.sqlwarn[0]=='W')sqlprint();
198-
#line63 "array_of_struct.pgc"
202+
#line64 "array_of_struct.pgc"
199203

200204
if (sqlca.sqlcode<0)sqlprint();}
201-
#line63 "array_of_struct.pgc"
205+
#line64 "array_of_struct.pgc"
202206

203207
printf("\ncusts2:\n");
204208
for (r=0;r<2;r++)
@@ -212,16 +216,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
212216
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof(structind ),
213217
ECPGt_int,&(custs3->phone),(long)1,(long)10,sizeof(structcustomer3 ),
214218
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof(structind ),ECPGt_EORT);
215-
#line71 "array_of_struct.pgc"
219+
#line72 "array_of_struct.pgc"
216220

217221
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
218-
#line71 "array_of_struct.pgc"
222+
#line72 "array_of_struct.pgc"
219223

220224
if (sqlca.sqlwarn[0]=='W')sqlprint();
221-
#line71 "array_of_struct.pgc"
225+
#line72 "array_of_struct.pgc"
222226

223227
if (sqlca.sqlcode<0)sqlprint();}
224-
#line71 "array_of_struct.pgc"
228+
#line72 "array_of_struct.pgc"
225229

226230
printf("\ncusts3:\n");
227231
for (r=0;r<2;r++)
@@ -235,29 +239,49 @@ if (sqlca.sqlcode < 0) sqlprint();}
235239
ECPGt_short,&(inds[0].name_ind),(long)1,(long)1,sizeof(short),
236240
ECPGt_int,&(custs4.phone),(long)1,(long)1,sizeof(int),
237241
ECPGt_short,&(inds[0].phone_ind),(long)1,(long)1,sizeof(short),ECPGt_EORT);
238-
#line79 "array_of_struct.pgc"
242+
#line80 "array_of_struct.pgc"
239243

240244
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
241-
#line79 "array_of_struct.pgc"
245+
#line80 "array_of_struct.pgc"
242246

243247
if (sqlca.sqlwarn[0]=='W')sqlprint();
244-
#line79 "array_of_struct.pgc"
248+
#line80 "array_of_struct.pgc"
245249

246250
if (sqlca.sqlcode<0)sqlprint();}
247-
#line79 "array_of_struct.pgc"
251+
#line80 "array_of_struct.pgc"
248252

249253
printf("\ncusts4:\n");
250254
printf("name - %s\n",custs4.name.arr );
251255
printf("phone - %d\n",custs4.phone );
252256

257+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"select c from customers limit 2 ",ECPGt_EOIT,
258+
ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(structvarchar_onlyname_45),
259+
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
260+
#line 85 "array_of_struct.pgc"
261+
262+
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
263+
#line 85 "array_of_struct.pgc"
264+
265+
if (sqlca.sqlwarn[0]=='W')sqlprint();
266+
#line 85 "array_of_struct.pgc"
267+
268+
if (sqlca.sqlcode<0)sqlprint();}
269+
#line 85 "array_of_struct.pgc"
270+
271+
printf("\nname:\n");
272+
for (r=0;r<2;r++)
273+
{
274+
printf("name - %s\n",onlyname[r].arr );
275+
}
276+
253277
{ECPGdisconnect(__LINE__,"ALL");
254-
#line84 "array_of_struct.pgc"
278+
#line92 "array_of_struct.pgc"
255279

256280
if (sqlca.sqlwarn[0]=='W')sqlprint();
257-
#line84 "array_of_struct.pgc"
281+
#line92 "array_of_struct.pgc"
258282

259283
if (sqlca.sqlcode<0)sqlprint();}
260-
#line84 "array_of_struct.pgc"
284+
#line92 "array_of_struct.pgc"
261285

262286

263287
return(0 );

‎src/interfaces/ecpg/test/expected/preproc-array_of_struct.stderr

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,85 @@
22
[NO_PID]: sqlca: code: 0, state: 00000
33
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
44
[NO_PID]: sqlca: code: 0, state: 00000
5-
[NO_PID]: ecpg_execute line 51: QUERY: create table customers ( c varchar ( 50 ) , p int ) with 0 parameter on connection regress1
6-
[NO_PID]: sqlca: code: 0, state: 00000
7-
[NO_PID]: ecpg_execute line 51: using PQexec
8-
[NO_PID]: sqlca: code: 0, state: 00000
9-
[NO_PID]: ecpg_execute line 51 Ok: CREATE TABLE
10-
[NO_PID]: sqlca: code: 0, state: 00000
11-
[NO_PID]: ecpg_execute line 52: QUERY: insert into customers values ( 'John Doe' , '12345' ) with 0 parameter on connection regress1
5+
[NO_PID]: ecpg_execute line 52: QUERY: create table customers ( c varchar ( 50 ) , p int ) with 0 parameter on connection regress1
126
[NO_PID]: sqlca: code: 0, state: 00000
137
[NO_PID]: ecpg_execute line 52: using PQexec
148
[NO_PID]: sqlca: code: 0, state: 00000
15-
[NO_PID]: ecpg_execute line 52 Ok:INSERT 0 1
9+
[NO_PID]: ecpg_execute line 52 Ok:CREATE TABLE
1610
[NO_PID]: sqlca: code: 0, state: 00000
17-
[NO_PID]: ecpg_execute line 53: QUERY: insert into customers values ( 'Jane Doe' , '67890' ) with 0 parameter on connection regress1
11+
[NO_PID]: ecpg_execute line 53: QUERY: insert into customers values ( 'John Doe' , '12345' ) with 0 parameter on connection regress1
1812
[NO_PID]: sqlca: code: 0, state: 00000
1913
[NO_PID]: ecpg_execute line 53: using PQexec
2014
[NO_PID]: sqlca: code: 0, state: 00000
2115
[NO_PID]: ecpg_execute line 53 Ok: INSERT 0 1
2216
[NO_PID]: sqlca: code: 0, state: 00000
23-
[NO_PID]: ecpg_execute line 55: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
17+
[NO_PID]: ecpg_execute line 54: QUERY: insert into customers values ( 'Jane Doe' , '67890' ) with 0 parameter on connection regress1
18+
[NO_PID]: sqlca: code: 0, state: 00000
19+
[NO_PID]: ecpg_execute line 54: using PQexec
20+
[NO_PID]: sqlca: code: 0, state: 00000
21+
[NO_PID]: ecpg_execute line 54 Ok: INSERT 0 1
22+
[NO_PID]: sqlca: code: 0, state: 00000
23+
[NO_PID]: ecpg_execute line 56: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
24+
[NO_PID]: sqlca: code: 0, state: 00000
25+
[NO_PID]: ecpg_execute line 56: using PQexec
26+
[NO_PID]: sqlca: code: 0, state: 00000
27+
[NO_PID]: ecpg_execute line 56: Correctly got 2 tuples with 2 fields
28+
[NO_PID]: sqlca: code: 0, state: 00000
29+
[NO_PID]: ecpg_get_data line 56: RESULT: John Doe offset: -1 array: Yes
30+
[NO_PID]: sqlca: code: 0, state: 00000
31+
[NO_PID]: ecpg_get_data line 56: RESULT: Jane Doe offset: -1 array: Yes
32+
[NO_PID]: sqlca: code: 0, state: 00000
33+
[NO_PID]: ecpg_get_data line 56: RESULT: 12345 offset: -1 array: Yes
2434
[NO_PID]: sqlca: code: 0, state: 00000
25-
[NO_PID]:ecpg_execute line55: using PQexec
35+
[NO_PID]:ecpg_get_data line56: RESULT: 67890 offset: -1 array: Yes
2636
[NO_PID]: sqlca: code: 0, state: 00000
27-
[NO_PID]: ecpg_execute line55: Correctly got 2 tuples with2 fields
37+
[NO_PID]: ecpg_execute line64: QUERY: select * from customers limit 2 with0 parameter on connection regress1
2838
[NO_PID]: sqlca: code: 0, state: 00000
29-
[NO_PID]:ecpg_get_data line55: RESULT: John Doe offset: -1 array: Yes
39+
[NO_PID]:ecpg_execute line64: using PQexec
3040
[NO_PID]: sqlca: code: 0, state: 00000
31-
[NO_PID]:ecpg_get_data line55: RESULT: Jane Doe offset: -1 array: Yes
41+
[NO_PID]:ecpg_execute line64: Correctly got 2 tuples with 2 fields
3242
[NO_PID]: sqlca: code: 0, state: 00000
33-
[NO_PID]: ecpg_get_data line55: RESULT:12345 offset: -1 array: Yes
43+
[NO_PID]: ecpg_get_data line64: RESULT:John Doe offset: -1 array: Yes
3444
[NO_PID]: sqlca: code: 0, state: 00000
35-
[NO_PID]: ecpg_get_data line55: RESULT:67890 offset: -1 array: Yes
45+
[NO_PID]: ecpg_get_data line64: RESULT:Jane Doe offset: -1 array: Yes
3646
[NO_PID]: sqlca: code: 0, state: 00000
37-
[NO_PID]:ecpg_execute line63: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
47+
[NO_PID]:ecpg_get_data line64: RESULT: 12345 offset: -1 array: Yes
3848
[NO_PID]: sqlca: code: 0, state: 00000
39-
[NO_PID]:ecpg_execute line63: using PQexec
49+
[NO_PID]:ecpg_get_data line64: RESULT: 67890 offset: -1 array: Yes
4050
[NO_PID]: sqlca: code: 0, state: 00000
41-
[NO_PID]: ecpg_execute line63: Correctly got 2 tuples with2 fields
51+
[NO_PID]: ecpg_execute line72: QUERY: select * from customers limit 2 with0 parameter on connection regress1
4252
[NO_PID]: sqlca: code: 0, state: 00000
43-
[NO_PID]:ecpg_get_data line63: RESULT: John Doe offset: -1 array: Yes
53+
[NO_PID]:ecpg_execute line72: using PQexec
4454
[NO_PID]: sqlca: code: 0, state: 00000
45-
[NO_PID]:ecpg_get_data line63: RESULT: Jane Doe offset: -1 array: Yes
55+
[NO_PID]:ecpg_execute line72: Correctly got 2 tuples with 2 fields
4656
[NO_PID]: sqlca: code: 0, state: 00000
47-
[NO_PID]: ecpg_get_data line63: RESULT:12345 offset: -1 array: Yes
57+
[NO_PID]: ecpg_get_data line72: RESULT:John Doe offset: -1 array: Yes
4858
[NO_PID]: sqlca: code: 0, state: 00000
49-
[NO_PID]: ecpg_get_data line63: RESULT:67890 offset: -1 array: Yes
59+
[NO_PID]: ecpg_get_data line72: RESULT:Jane Doe offset: -1 array: Yes
5060
[NO_PID]: sqlca: code: 0, state: 00000
51-
[NO_PID]:ecpg_execute line71: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
61+
[NO_PID]:ecpg_get_data line72: RESULT: 12345 offset: -1 array: Yes
5262
[NO_PID]: sqlca: code: 0, state: 00000
53-
[NO_PID]:ecpg_execute line71: using PQexec
63+
[NO_PID]:ecpg_get_data line72: RESULT: 67890 offset: -1 array: Yes
5464
[NO_PID]: sqlca: code: 0, state: 00000
55-
[NO_PID]: ecpg_execute line71: Correctly got 2 tupleswith2 fields
65+
[NO_PID]: ecpg_execute line80: QUERY: select * from customers limit 1with0 parameter on connection regress1
5666
[NO_PID]: sqlca: code: 0, state: 00000
57-
[NO_PID]:ecpg_get_data line71: RESULT: John Doe offset: -1 array: Yes
67+
[NO_PID]:ecpg_execute line80: using PQexec
5868
[NO_PID]: sqlca: code: 0, state: 00000
59-
[NO_PID]:ecpg_get_data line71: RESULT: Jane Doe offset: -1 array: Yes
69+
[NO_PID]:ecpg_execute line80: Correctly got 1 tuples with 2 fields
6070
[NO_PID]: sqlca: code: 0, state: 00000
61-
[NO_PID]: ecpg_get_data line71: RESULT:12345 offset: -1 array: Yes
71+
[NO_PID]: ecpg_get_data line80: RESULT:John Doe offset: -1 array: Yes
6272
[NO_PID]: sqlca: code: 0, state: 00000
63-
[NO_PID]: ecpg_get_data line71: RESULT:67890 offset: -1 array: Yes
73+
[NO_PID]: ecpg_get_data line80: RESULT:12345 offset: -1 array: Yes
6474
[NO_PID]: sqlca: code: 0, state: 00000
65-
[NO_PID]: ecpg_execute line79: QUERY: select* from customers limit1 with 0 parameter on connection regress1
75+
[NO_PID]: ecpg_execute line85: QUERY: selectc from customers limit2 with 0 parameter on connection regress1
6676
[NO_PID]: sqlca: code: 0, state: 00000
67-
[NO_PID]: ecpg_execute line79: using PQexec
77+
[NO_PID]: ecpg_execute line85: using PQexec
6878
[NO_PID]: sqlca: code: 0, state: 00000
69-
[NO_PID]: ecpg_execute line79: Correctly got1 tuples with2 fields
79+
[NO_PID]: ecpg_execute line85: Correctly got2 tuples with1 fields
7080
[NO_PID]: sqlca: code: 0, state: 00000
71-
[NO_PID]: ecpg_get_data line79: RESULT: John Doe offset: -1 array: Yes
81+
[NO_PID]: ecpg_get_data line85: RESULT: John Doe offset: -1 array: Yes
7282
[NO_PID]: sqlca: code: 0, state: 00000
73-
[NO_PID]: ecpg_get_data line79: RESULT:12345 offset: -1 array: Yes
83+
[NO_PID]: ecpg_get_data line85: RESULT:Jane Doe offset: -1 array: Yes
7484
[NO_PID]: sqlca: code: 0, state: 00000
7585
[NO_PID]: ecpg_finish: Connection regress1 closed.
7686
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/preproc-array_of_struct.stdout

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ phone - 67890
1919
custs4:
2020
name - John Doe
2121
phone - 12345
22+
23+
name:
24+
name - John Doe
25+
name - Jane Doe

‎src/interfaces/ecpg/test/preproc/array_of_struct.pgc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int main( int argc, char * argv[] )
4242
int phone;
4343
} custs4;
4444
int r;
45+
varchar onlyname[2][50];
4546
EXEC SQL end declare section;
4647

4748
ECPGdebug(1, stderr);
@@ -81,6 +82,13 @@ int main( int argc, char * argv[] )
8182
printf( "name - %s\n", custs4.name.arr );
8283
printf( "phone - %d\n", custs4.phone );
8384

85+
EXEC SQL select c INTO :onlyname from customers limit 2;
86+
printf("\nname:\n");
87+
for (r = 0; r < 2; r++)
88+
{
89+
printf( "name - %s\n", onlyname[r].arr );
90+
}
91+
8492
EXEC SQL disconnect all;
8593

8694
return( 0 );

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp