1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
6 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
14 #line 1 "regression.h"
21 #line 4 "describe.pgc"
28 #ifdef _ECPG_INFORMIX_H
30 #include "sqlda-compat.h"
31 typedef struct sqlvar_compat sqlvar_t;
32 typedef struct sqlda_compat sqlda_t;
36 #include "sqlda-native.h"
37 typedef struct sqlvar_struct sqlvar_t;
38 typedef struct sqlda_struct sqlda_t;
42 #endif /* ECPG_SQLDA_H */
44 #line 5 "describe.pgc"
47 /* exec sql whenever sqlerror stop ; */
48 #line 7 "describe.pgc"
51 sqlda_t *sqlda1, *sqlda2, *sqlda3;
56 /* exec sql begin declare section */
63 #line 15 "describe.pgc"
64 char * stmt1 = "SELECT id, t FROM descr_t2" ;
66 #line 16 "describe.pgc"
67 char * stmt2 = "SELECT id, t FROM descr_t2 WHERE id = -1" ;
69 #line 17 "describe.pgc"
70 int i , count1 , count2 ;
72 #line 18 "describe.pgc"
73 char field_name1 [ 30 ] = "not set" ;
75 #line 19 "describe.pgc"
76 char field_name2 [ 30 ] = "not set" ;
77 /* exec sql end declare section */
78 #line 20 "describe.pgc"
85 strcpy(msg, "connect");
86 { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
87 #line 27 "describe.pgc"
89 if (sqlca.sqlcode < 0) exit (1);}
90 #line 27 "describe.pgc"
94 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
95 #line 30 "describe.pgc"
97 if (sqlca.sqlcode < 0) exit (1);}
98 #line 30 "describe.pgc"
101 strcpy(msg, "create");
102 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table descr_t2 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
103 #line 33 "describe.pgc"
105 if (sqlca.sqlcode < 0) exit (1);}
106 #line 33 "describe.pgc"
109 strcpy(msg, "insert");
110 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
111 #line 36 "describe.pgc"
113 if (sqlca.sqlcode < 0) exit (1);}
114 #line 36 "describe.pgc"
116 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
117 #line 37 "describe.pgc"
119 if (sqlca.sqlcode < 0) exit (1);}
120 #line 37 "describe.pgc"
122 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
123 #line 38 "describe.pgc"
125 if (sqlca.sqlcode < 0) exit (1);}
126 #line 38 "describe.pgc"
128 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
129 #line 39 "describe.pgc"
131 if (sqlca.sqlcode < 0) exit (1);}
132 #line 39 "describe.pgc"
135 strcpy(msg, "commit");
136 { ECPGtrans(__LINE__, NULL, "commit");
137 #line 42 "describe.pgc"
139 if (sqlca.sqlcode < 0) exit (1);}
140 #line 42 "describe.pgc"
144 * Test DESCRIBE with a query producing tuples.
145 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
146 * Informix-compat mode.
149 strcpy(msg, "allocate");
150 ECPGallocate_desc(__LINE__, "desc1");
151 #line 51 "describe.pgc"
153 if (sqlca.sqlcode < 0) exit (1);
154 #line 51 "describe.pgc"
156 ECPGallocate_desc(__LINE__, "desc2");
157 #line 52 "describe.pgc"
159 if (sqlca.sqlcode < 0) exit (1);
160 #line 52 "describe.pgc"
163 strcpy(msg, "prepare");
164 { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
165 #line 55 "describe.pgc"
167 if (sqlca.sqlcode < 0) exit (1);}
168 #line 55 "describe.pgc"
171 sqlda1 = sqlda2 = sqlda3 = NULL;
173 strcpy(msg, "describe");
174 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
175 ECPGt_descriptor, "desc1", 1L, 1L, 1L,
176 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
177 #line 60 "describe.pgc"
179 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
180 ECPGt_descriptor, "desc2", 1L, 1L, 1L,
181 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
182 #line 61 "describe.pgc"
185 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
186 ECPGt_sqlda, &sqlda1, 0L, 0L, 0L,
187 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
188 #line 63 "describe.pgc"
190 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
191 ECPGt_sqlda, &sqlda2, 0L, 0L, 0L,
192 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
193 #line 64 "describe.pgc"
195 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
196 ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
197 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
198 #line 65 "describe.pgc"
203 printf("sqlda1 NULL\n");
209 printf("sqlda2 NULL\n");
215 printf("sqlda3 NULL\n");
219 strcpy(msg, "get descriptor");
220 { ECPGget_desc_header(__LINE__, "desc1", &(count1));
222 #line 86 "describe.pgc"
224 if (sqlca.sqlcode < 0) exit (1);}
225 #line 86 "describe.pgc"
227 { ECPGget_desc_header(__LINE__, "desc1", &(count2));
229 #line 87 "describe.pgc"
231 if (sqlca.sqlcode < 0) exit (1);}
232 #line 87 "describe.pgc"
235 if (count1 != count2)
237 printf("count1 (%d) != count2 (%d)\n", count1, count2);
241 if (count1 != sqlda1->sqld)
243 printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
247 if (count1 != sqlda2->sqld)
249 printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
253 if (count1 != sqlda3->sqld)
255 printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
259 for (i = 1; i <= count1; i++)
261 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
262 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
264 #line 115 "describe.pgc"
266 if (sqlca.sqlcode < 0) exit (1);}
267 #line 115 "describe.pgc"
269 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
270 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
272 #line 116 "describe.pgc"
274 if (sqlca.sqlcode < 0) exit (1);}
275 #line 116 "describe.pgc"
277 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
278 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
279 i, field_name1, field_name2,
280 sqlda1->sqlvar[i-1].sqlname.data,
281 sqlda2->sqlvar[i-1].sqlname.data,
282 sqlda3->sqlvar[i-1].sqlname.data);
285 strcpy(msg, "deallocate");
286 ECPGdeallocate_desc(__LINE__, "desc1");
287 #line 126 "describe.pgc"
289 if (sqlca.sqlcode < 0) exit (1);
290 #line 126 "describe.pgc"
292 ECPGdeallocate_desc(__LINE__, "desc2");
293 #line 127 "describe.pgc"
295 if (sqlca.sqlcode < 0) exit (1);
296 #line 127 "describe.pgc"
302 { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
303 #line 132 "describe.pgc"
305 if (sqlca.sqlcode < 0) exit (1);}
306 #line 132 "describe.pgc"
309 /* Test DESCRIBE with a query not producing tuples */
311 strcpy(msg, "allocate");
312 ECPGallocate_desc(__LINE__, "desc1");
313 #line 137 "describe.pgc"
315 if (sqlca.sqlcode < 0) exit (1);
316 #line 137 "describe.pgc"
318 ECPGallocate_desc(__LINE__, "desc2");
319 #line 138 "describe.pgc"
321 if (sqlca.sqlcode < 0) exit (1);
322 #line 138 "describe.pgc"
325 strcpy(msg, "prepare");
326 { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
327 #line 141 "describe.pgc"
329 if (sqlca.sqlcode < 0) exit (1);}
330 #line 141 "describe.pgc"
333 sqlda1 = sqlda2 = sqlda3 = NULL;
335 strcpy(msg, "describe");
336 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
337 ECPGt_descriptor, "desc1", 1L, 1L, 1L,
338 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
339 #line 146 "describe.pgc"
341 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
342 ECPGt_descriptor, "desc2", 1L, 1L, 1L,
343 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
344 #line 147 "describe.pgc"
347 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
348 ECPGt_sqlda, &sqlda1, 0L, 0L, 0L,
349 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
350 #line 149 "describe.pgc"
352 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
353 ECPGt_sqlda, &sqlda2, 0L, 0L, 0L,
354 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
355 #line 150 "describe.pgc"
357 { ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
358 ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
359 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
360 #line 151 "describe.pgc"
363 if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
366 strcpy(msg, "get descriptor");
367 { ECPGget_desc_header(__LINE__, "desc1", &(count1));
369 #line 157 "describe.pgc"
371 if (sqlca.sqlcode < 0) exit (1);}
372 #line 157 "describe.pgc"
374 { ECPGget_desc_header(__LINE__, "desc1", &(count2));
376 #line 158 "describe.pgc"
378 if (sqlca.sqlcode < 0) exit (1);}
379 #line 158 "describe.pgc"
382 if (!( count1 == count2 &&
383 count1 == sqlda1->sqld &&
384 count1 == sqlda2->sqld &&
385 count1 == sqlda3->sqld))
388 for (i = 1; i <= count1; i++)
390 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
391 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
393 #line 168 "describe.pgc"
395 if (sqlca.sqlcode < 0) exit (1);}
396 #line 168 "describe.pgc"
398 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
399 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
401 #line 169 "describe.pgc"
403 if (sqlca.sqlcode < 0) exit (1);}
404 #line 169 "describe.pgc"
406 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
407 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
408 i, field_name1, field_name2,
409 sqlda1->sqlvar[i-1].sqlname.data,
410 sqlda2->sqlvar[i-1].sqlname.data,
411 sqlda3->sqlvar[i-1].sqlname.data);
414 strcpy(msg, "deallocate");
415 ECPGdeallocate_desc(__LINE__, "desc1");
416 #line 179 "describe.pgc"
418 if (sqlca.sqlcode < 0) exit (1);
419 #line 179 "describe.pgc"
421 ECPGdeallocate_desc(__LINE__, "desc2");
422 #line 180 "describe.pgc"
424 if (sqlca.sqlcode < 0) exit (1);
425 #line 180 "describe.pgc"
431 { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
432 #line 185 "describe.pgc"
434 if (sqlca.sqlcode < 0) exit (1);}
435 #line 185 "describe.pgc"
441 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table descr_t2", ECPGt_EOIT, ECPGt_EORT);
442 #line 190 "describe.pgc"
444 if (sqlca.sqlcode < 0) exit (1);}
445 #line 190 "describe.pgc"
448 strcpy(msg, "commit");
449 { ECPGtrans(__LINE__, NULL, "commit");
450 #line 193 "describe.pgc"
452 if (sqlca.sqlcode < 0) exit (1);}
453 #line 193 "describe.pgc"
456 strcpy(msg, "disconnect");
457 { ECPGdisconnect(__LINE__, "CURRENT");
458 #line 196 "describe.pgc"
460 if (sqlca.sqlcode < 0) exit (1);}
461 #line 196 "describe.pgc"