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

Commit1ec4c56

Browse files
author
Michael Meskes
committed
ECPG: Add EXEC SQL CLOSE C to the tests.
Patch by Boszormenyi Zoltan <zb@cybertec.at>
1 parentdb58e8f commit1ec4c56

File tree

6 files changed

+101
-74
lines changed

6 files changed

+101
-74
lines changed

‎src/interfaces/ecpg/test/expected/sql-binary.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,19 @@ main (void)
133133

134134
printf ("name=%s, accs=%d byte=%s\n",empl.name,empl.accs,empl.byte);
135135

136+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"close C",ECPGt_EOIT,ECPGt_EORT);}
137+
#line 69 "binary.pgc"
138+
139+
136140
memset(empl.name,0,21L);
137141
ECPGset_var(1,&(empl.idnum ),__LINE__);\
138142
/* declare B binary cursor for select name , accs , byte from empl where idnum = $1 */
139-
#line70 "binary.pgc"
143+
#line72 "binary.pgc"
140144

141145
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"declare B binary cursor for select name , accs , byte from empl where idnum = $1 ",
142146
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
143147
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);}
144-
#line71 "binary.pgc"
148+
#line73 "binary.pgc"
145149

146150
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch B",ECPGt_EOIT,
147151
ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char),
@@ -150,7 +154,7 @@ main (void)
150154
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
151155
ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char),
152156
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);}
153-
#line72 "binary.pgc"
157+
#line74 "binary.pgc"
154158

155159
if (sqlca.sqlcode)
156160
{
@@ -159,7 +163,7 @@ main (void)
159163
}
160164

161165
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"close B",ECPGt_EOIT,ECPGt_EORT);}
162-
#line79 "binary.pgc"
166+
#line81 "binary.pgc"
163167

164168

165169
/* do not print a.accs because big/little endian will have different outputs here */
@@ -170,17 +174,17 @@ main (void)
170174

171175
ECPGset_var(2,&(empl.idnum ),__LINE__);\
172176
/* declare A binary cursor for select byte from empl where idnum = $1 */
173-
#line87 "binary.pgc"
177+
#line89 "binary.pgc"
174178

175179
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"declare A binary cursor for select byte from empl where idnum = $1 ",
176180
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
177181
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);}
178-
#line88 "binary.pgc"
182+
#line90 "binary.pgc"
179183

180184
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch A",ECPGt_EOIT,
181185
ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char),
182186
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);}
183-
#line89 "binary.pgc"
187+
#line91 "binary.pgc"
184188

185189
if (sqlca.sqlcode)
186190
{
@@ -189,7 +193,7 @@ main (void)
189193
}
190194

191195
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"close A",ECPGt_EOIT,ECPGt_EORT);}
192-
#line96 "binary.pgc"
196+
#line98 "binary.pgc"
193197

194198

195199
printf ("pointer=");
@@ -199,7 +203,7 @@ main (void)
199203
free(pointer);
200204

201205
{ECPGdisconnect(__LINE__,"CURRENT");}
202-
#line104 "binary.pgc"
206+
#line106 "binary.pgc"
203207

204208
exit (0);
205209
}

‎src/interfaces/ecpg/test/expected/sql-binary.stderr

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,55 +42,61 @@
4242
[NO_PID]: sqlca: code: 0, state: 00000
4343
[NO_PID]: ecpg_get_data on line 60: RESULT: \001m\000\212 offset: -1; array: no
4444
[NO_PID]: sqlca: code: 0, state: 00000
45-
[NO_PID]: ecpg_execute on line71: query:declare B binary cursor for select name , accs , byte from empl where idnum = $1; with1 parameter(s) on connection regress1
45+
[NO_PID]: ecpg_execute on line69: query:close C; with0 parameter(s) on connection regress1
4646
[NO_PID]: sqlca: code: 0, state: 00000
47-
[NO_PID]: ecpg_execute on line71: usingPQexecParams
47+
[NO_PID]: ecpg_execute on line69: usingPQexec
4848
[NO_PID]: sqlca: code: 0, state: 00000
49-
[NO_PID]:free_params on line71: parameter 1 = 1
49+
[NO_PID]:ecpg_execute on line69: OK: CLOSE CURSOR
5050
[NO_PID]: sqlca: code: 0, state: 00000
51-
[NO_PID]: ecpg_execute on line71: OK: DECLARE CURSOR
51+
[NO_PID]: ecpg_execute on line73: query: declare B binary cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
5252
[NO_PID]: sqlca: code: 0, state: 00000
53-
[NO_PID]: ecpg_execute on line72: query: fetch B; with 0 parameter(s) on connection regress1
53+
[NO_PID]: ecpg_execute on line73: using PQexecParams
5454
[NO_PID]: sqlca: code: 0, state: 00000
55-
[NO_PID]:ecpg_execute on line72: using PQexec
55+
[NO_PID]:free_params on line73: parameter 1 = 1
5656
[NO_PID]: sqlca: code: 0, state: 00000
57-
[NO_PID]: ecpg_execute on line72: correctly got 1 tuples with 3 fields
57+
[NO_PID]: ecpg_execute on line73: OK: DECLARE CURSOR
5858
[NO_PID]: sqlca: code: 0, state: 00000
59-
[NO_PID]:ecpg_get_data on line72: RESULT: BINARY offset: -1; array: no
59+
[NO_PID]:ecpg_execute on line74: query: fetch B; with 0 parameter(s) on connection regress1
6060
[NO_PID]: sqlca: code: 0, state: 00000
61-
[NO_PID]:ecpg_get_data on line72: RESULT: BINARY offset: -1; array: no
61+
[NO_PID]:ecpg_execute on line74: using PQexec
6262
[NO_PID]: sqlca: code: 0, state: 00000
63-
[NO_PID]:ecpg_get_data on line72: RESULT: BINARY offset: -1; array: no
63+
[NO_PID]:ecpg_execute on line74: correctly got 1 tuples with 3 fields
6464
[NO_PID]: sqlca: code: 0, state: 00000
65-
[NO_PID]:ecpg_execute on line79: query: close B; with 0 parameter(s) on connection regress1
65+
[NO_PID]:ecpg_get_data on line74: RESULT: BINARY offset: -1; array: no
6666
[NO_PID]: sqlca: code: 0, state: 00000
67-
[NO_PID]:ecpg_execute on line79: using PQexec
67+
[NO_PID]:ecpg_get_data on line74: RESULT: BINARY offset: -1; array: no
6868
[NO_PID]: sqlca: code: 0, state: 00000
69-
[NO_PID]:ecpg_execute on line79: OK: CLOSE CURSOR
69+
[NO_PID]:ecpg_get_data on line74: RESULT: BINARY offset: -1; array: no
7070
[NO_PID]: sqlca: code: 0, state: 00000
71-
[NO_PID]: ecpg_execute on line88: query:declare A binary cursor for select byte from empl where idnum = $1; with1 parameter(s) on connection regress1
71+
[NO_PID]: ecpg_execute on line81: query:close B; with0 parameter(s) on connection regress1
7272
[NO_PID]: sqlca: code: 0, state: 00000
73-
[NO_PID]: ecpg_execute on line88: usingPQexecParams
73+
[NO_PID]: ecpg_execute on line81: usingPQexec
7474
[NO_PID]: sqlca: code: 0, state: 00000
75-
[NO_PID]:free_params on line88: parameter 1 = 1
75+
[NO_PID]:ecpg_execute on line81: OK: CLOSE CURSOR
7676
[NO_PID]: sqlca: code: 0, state: 00000
77-
[NO_PID]: ecpg_execute on line88: OK: DECLARE CURSOR
77+
[NO_PID]: ecpg_execute on line90: query: declare A binary cursor for select byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
7878
[NO_PID]: sqlca: code: 0, state: 00000
79-
[NO_PID]: ecpg_execute on line89: query: fetch A; with 0 parameter(s) on connection regress1
79+
[NO_PID]: ecpg_execute on line90: using PQexecParams
8080
[NO_PID]: sqlca: code: 0, state: 00000
81-
[NO_PID]:ecpg_execute on line89: using PQexec
81+
[NO_PID]:free_params on line90: parameter 1 = 1
8282
[NO_PID]: sqlca: code: 0, state: 00000
83-
[NO_PID]: ecpg_execute on line89: correctly got 1 tuples with 1 fields
83+
[NO_PID]: ecpg_execute on line90: OK: DECLARE CURSOR
8484
[NO_PID]: sqlca: code: 0, state: 00000
85-
[NO_PID]:ecpg_store_result on line89: allocating memory for 1 tuples
85+
[NO_PID]:ecpg_execute on line91: query: fetch A; with 0 parameter(s) on connection regress1
8686
[NO_PID]: sqlca: code: 0, state: 00000
87-
[NO_PID]:ecpg_get_data on line89: RESULT: BINARY offset: -1; array: no
87+
[NO_PID]:ecpg_execute on line91: using PQexec
8888
[NO_PID]: sqlca: code: 0, state: 00000
89-
[NO_PID]: ecpg_execute on line96: query: close A;with0 parameter(s) on connection regress1
89+
[NO_PID]: ecpg_execute on line91: correctly got 1 tupleswith1 fields
9090
[NO_PID]: sqlca: code: 0, state: 00000
91-
[NO_PID]:ecpg_execute on line96: using PQexec
91+
[NO_PID]:ecpg_store_result on line91: allocating memory for 1 tuples
9292
[NO_PID]: sqlca: code: 0, state: 00000
93-
[NO_PID]: ecpg_execute on line 96: OK: CLOSE CURSOR
93+
[NO_PID]: ecpg_get_data on line 91: RESULT: BINARY offset: -1; array: no
94+
[NO_PID]: sqlca: code: 0, state: 00000
95+
[NO_PID]: ecpg_execute on line 98: query: close A; with 0 parameter(s) on connection regress1
96+
[NO_PID]: sqlca: code: 0, state: 00000
97+
[NO_PID]: ecpg_execute on line 98: using PQexec
98+
[NO_PID]: sqlca: code: 0, state: 00000
99+
[NO_PID]: ecpg_execute on line 98: OK: CLOSE CURSOR
94100
[NO_PID]: sqlca: code: 0, state: 00000
95101
[NO_PID]: ecpg_finish: connection regress1 closed
96102
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/sql-fetch.c

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,72 +162,82 @@ if (sqlca.sqlcode < 0) sqlprint();}
162162

163163
printf("%d: %s\n",i,str);
164164

165-
/* declare D cursor for select * from My_Table where Item1 = $1 */
165+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"close C",ECPGt_EOIT,ECPGt_EORT);
166166
#line 42 "fetch.pgc"
167167

168+
if (sqlca.sqlwarn[0]=='W')sqlprint();
169+
#line 42 "fetch.pgc"
170+
171+
if (sqlca.sqlcode<0)sqlprint();}
172+
#line 42 "fetch.pgc"
173+
174+
175+
/* declare D cursor for select * from My_Table where Item1 = $1 */
176+
#line 44 "fetch.pgc"
177+
168178

169179
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"declare D cursor for select * from My_Table where Item1 = $1",
170180
ECPGt_const,"1",(long)1,(long)1,strlen("1"),
171181
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
172-
#line44 "fetch.pgc"
182+
#line46 "fetch.pgc"
173183

174184
if (sqlca.sqlwarn[0]=='W')sqlprint();
175-
#line44 "fetch.pgc"
185+
#line46 "fetch.pgc"
176186

177187
if (sqlca.sqlcode<0)sqlprint();}
178-
#line44 "fetch.pgc"
188+
#line46 "fetch.pgc"
179189

180190

181191
/* exec sql whenever not found break ; */
182-
#line46 "fetch.pgc"
192+
#line48 "fetch.pgc"
183193

184194
while (1) {
185195
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"fetch 1 in D",ECPGt_EOIT,
186196
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
187197
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
188198
ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
189199
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
190-
#line48 "fetch.pgc"
200+
#line50 "fetch.pgc"
191201

192202
if (sqlca.sqlcode==ECPG_NOT_FOUND)break;
193-
#line48 "fetch.pgc"
203+
#line50 "fetch.pgc"
194204

195205
if (sqlca.sqlwarn[0]=='W')sqlprint();
196-
#line48 "fetch.pgc"
206+
#line50 "fetch.pgc"
197207

198208
if (sqlca.sqlcode<0)sqlprint();}
199-
#line48 "fetch.pgc"
209+
#line50 "fetch.pgc"
200210

201211
printf("%d: %s\n",i,str);
202212
}
203213
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"close D",ECPGt_EOIT,ECPGt_EORT);
204-
#line51 "fetch.pgc"
214+
#line53 "fetch.pgc"
205215

206216
if (sqlca.sqlwarn[0]=='W')sqlprint();
207-
#line51 "fetch.pgc"
217+
#line53 "fetch.pgc"
208218

209219
if (sqlca.sqlcode<0)sqlprint();}
210-
#line51 "fetch.pgc"
220+
#line53 "fetch.pgc"
211221

212222

213223
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop table My_Table",ECPGt_EOIT,ECPGt_EORT);
214-
#line53 "fetch.pgc"
224+
#line55 "fetch.pgc"
215225

216226
if (sqlca.sqlwarn[0]=='W')sqlprint();
217-
#line53 "fetch.pgc"
227+
#line55 "fetch.pgc"
218228

219229
if (sqlca.sqlcode<0)sqlprint();}
220-
#line53 "fetch.pgc"
230+
#line55 "fetch.pgc"
221231

222232

223233
{ECPGdisconnect(__LINE__,"ALL");
224-
#line55 "fetch.pgc"
234+
#line57 "fetch.pgc"
225235

226236
if (sqlca.sqlwarn[0]=='W')sqlprint();
227-
#line55 "fetch.pgc"
237+
#line57 "fetch.pgc"
228238

229239
if (sqlca.sqlcode<0)sqlprint();}
230-
#line55 "fetch.pgc"
240+
#line57 "fetch.pgc"
231241

232242

233243
return0;

‎src/interfaces/ecpg/test/expected/sql-fetch.stderr

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,46 +102,49 @@
102102
[NO_PID]: sqlca: code: 0, state: 00000
103103
[NO_PID]: ecpg_get_data on line 39: RESULT: text4 offset: -1; array: no
104104
[NO_PID]: sqlca: code: 0, state: 00000
105-
[NO_PID]: ecpg_execute on line44: query:declare D cursor for select * from My_Table where Item1 = $1; with1 parameter(s) on connection regress1
105+
[NO_PID]: ecpg_execute on line42: query:close C; with0 parameter(s) on connection regress1
106106
[NO_PID]: sqlca: code: 0, state: 00000
107-
[NO_PID]: ecpg_execute on line44: usingPQexecParams
107+
[NO_PID]: ecpg_execute on line42: usingPQexec
108108
[NO_PID]: sqlca: code: 0, state: 00000
109-
[NO_PID]:free_params on line44: parameter 1 = 1
109+
[NO_PID]:ecpg_execute on line42: OK: CLOSE CURSOR
110110
[NO_PID]: sqlca: code: 0, state: 00000
111-
[NO_PID]: ecpg_execute on line44: OK: DECLARE CURSOR
111+
[NO_PID]: ecpg_execute on line46: query: declare D cursor for select * from My_Table where Item1 = $1; with 1 parameter(s) on connection regress1
112112
[NO_PID]: sqlca: code: 0, state: 00000
113-
[NO_PID]: ecpg_execute on line48: query: fetch 1 in D; with 0 parameter(s) on connection regress1
113+
[NO_PID]: ecpg_execute on line46: using PQexecParams
114114
[NO_PID]: sqlca: code: 0, state: 00000
115-
[NO_PID]:ecpg_execute on line48: using PQexec
115+
[NO_PID]:free_params on line46: parameter 1 = 1
116116
[NO_PID]: sqlca: code: 0, state: 00000
117-
[NO_PID]: ecpg_execute on line48: correctly got 1 tuples with 2 fields
117+
[NO_PID]: ecpg_execute on line46: OK: DECLARE CURSOR
118118
[NO_PID]: sqlca: code: 0, state: 00000
119-
[NO_PID]:ecpg_get_data on line48: RESULT: 1 offset: -1; array: no
119+
[NO_PID]:ecpg_execute on line50: query: fetch 1 in D; with 0 parameter(s) on connection regress1
120120
[NO_PID]: sqlca: code: 0, state: 00000
121-
[NO_PID]:ecpg_get_data on line48: RESULT: text1 offset: -1; array: no
121+
[NO_PID]:ecpg_execute on line50: using PQexec
122122
[NO_PID]: sqlca: code: 0, state: 00000
123-
[NO_PID]: ecpg_execute on line48: query: fetch 1in D;with0 parameter(s) on connection regress1
123+
[NO_PID]: ecpg_execute on line50: correctly got 1tupleswith2 fields
124124
[NO_PID]: sqlca: code: 0, state: 00000
125-
[NO_PID]:ecpg_execute on line48: using PQexec
125+
[NO_PID]:ecpg_get_data on line50: RESULT: 1 offset: -1; array: no
126126
[NO_PID]: sqlca: code: 0, state: 00000
127-
[NO_PID]:ecpg_execute on line48: correctly got 0 tuples with 2 fields
127+
[NO_PID]:ecpg_get_data on line50: RESULT: text1 offset: -1; array: no
128128
[NO_PID]: sqlca: code: 0, state: 00000
129-
[NO_PID]: raising sqlcode 100 on line 48: no data found on line 48
130-
[NO_PID]: sqlca: code: 100, state: 02000
131-
[NO_PID]: ecpg_execute on line 51: query: close D; with 0 parameter(s) on connection regress1
129+
[NO_PID]: ecpg_execute on line 50: query: fetch 1 in D; with 0 parameter(s) on connection regress1
132130
[NO_PID]: sqlca: code: 0, state: 00000
133-
[NO_PID]: ecpg_execute on line51: using PQexec
131+
[NO_PID]: ecpg_execute on line50: using PQexec
134132
[NO_PID]: sqlca: code: 0, state: 00000
135-
[NO_PID]: ecpg_execute on line51: OK: CLOSE CURSOR
133+
[NO_PID]: ecpg_execute on line50: correctly got 0 tuples with 2 fields
136134
[NO_PID]: sqlca: code: 0, state: 00000
137-
[NO_PID]: ecpg_execute on line 53: query: drop table My_Table; with 0 parameter(s) on connection regress1
135+
[NO_PID]: raising sqlcode 100 on line 50: no data found on line 50
136+
[NO_PID]: sqlca: code: 100, state: 02000
137+
[NO_PID]: ecpg_execute on line 53: query: close D; with 0 parameter(s) on connection regress1
138138
[NO_PID]: sqlca: code: 0, state: 00000
139139
[NO_PID]: ecpg_execute on line 53: using PQexec
140140
[NO_PID]: sqlca: code: 0, state: 00000
141-
[NO_PID]: ecpg_check_PQresult on line 53: bad response - ERROR: cannot DROP TABLE "my_table" because it is being used by active queries in this session
141+
[NO_PID]: ecpg_execute on line 53: OK: CLOSE CURSOR
142+
[NO_PID]: sqlca: code: 0, state: 00000
143+
[NO_PID]: ecpg_execute on line 55: query: drop table My_Table; with 0 parameter(s) on connection regress1
144+
[NO_PID]: sqlca: code: 0, state: 00000
145+
[NO_PID]: ecpg_execute on line 55: using PQexec
146+
[NO_PID]: sqlca: code: 0, state: 00000
147+
[NO_PID]: ecpg_execute on line 55: OK: DROP TABLE
142148
[NO_PID]: sqlca: code: 0, state: 00000
143-
[NO_PID]: raising sqlstate 55006 (sqlcode -400): cannot DROP TABLE "my_table" because it is being used by active queries in this session on line 53
144-
[NO_PID]: sqlca: code: -400, state: 55006
145-
SQL error: cannot DROP TABLE "my_table" because it is being used by active queries in this session on line 53
146149
[NO_PID]: ecpg_finish: connection regress1 closed
147150
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/sql/binary.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ main (void)
6666

6767
printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
6868

69+
EXEC SQL CLOSE C;
70+
6971
memset(empl.name, 0, 21L);
7072
EXEC SQL DECLARE B BINARY CURSOR FOR select name, accs, byte from empl where idnum =:empl.idnum;
7173
EXEC SQL OPEN B;

‎src/interfaces/ecpg/test/sql/fetch.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ int main() {
3939
EXEC SQL FETCH :count IN C INTO :i, :str;
4040
printf("%d: %s\n", i, str);
4141

42+
EXEC SQL CLOSE C;
43+
4244
EXEC SQL DECLARE D CURSOR FOR SELECT * FROM My_Table WHERE Item1 = $1;
4345

4446
EXEC SQL OPEN D using 1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp