PostgreSQL Source Code: src/interfaces/ecpg/test/expected/sql-dyntest.c Source File (original) (raw)
1
2
6
7#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8
9#line 1 "dyntest.pgc"
10
11
12
13#include <stdio.h>
14#include <stdlib.h>
15
16
17#line 1 "sql3types.h"
18#ifndef _ECPG_SQL3TYPES_H
19#define _ECPG_SQL3TYPES_H
20
21
22
23
24
25enum
26{
43
45
46
47
48enum
49{
55
57
59
60#endif
61
62#line 7 "dyntest.pgc"
63
64
65#line 1 "sqlca.h"
66#ifndef POSTGRES_SQLCA_H
67#define POSTGRES_SQLCA_H
68
69#ifndef PGDLLIMPORT
70#if defined(WIN32) || defined(__CYGWIN__)
71#define PGDLLIMPORT __declspec (dllimport)
72#else
73#define PGDLLIMPORT
74#endif
75#endif
76
77#define SQLERRMC_LEN 150
78
79#ifdef __cplusplus
80extern "C"
81{
82#endif
83
85{
89 struct
90 {
96
97
98
99
100
101
102
103
105
106
107
108
109
110
111
112
113
114
115
116
117
119};
120
122
123#ifndef POSTGRES_ECPG_INTERNAL
124#define sqlca (*ECPGget_sqlca())
125#endif
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
132
133#line 8 "dyntest.pgc"
134
135
136#line 1 "regression.h"
137
138
139
140
141
142
143#line 9 "dyntest.pgc"
144
145
146static void
148{
149 printf ("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
150 exit (1);
151}
152
153int
155{
156
157
158
159
160
161
162
163
164
165
166
167
168#line 22 "dyntest.pgc"
170
171#line 23 "dyntest.pgc"
172 int INTVAR ;
173
174#line 24 "dyntest.pgc"
175 int INDEX ;
176
177#line 25 "dyntest.pgc"
178 int INDICATOR ;
179
180#line 26 "dyntest.pgc"
181 int TYPE , LENGTH , OCTET_LENGTH , PRECISION , SCALE , RETURNED_OCTET_LENGTH ;
182
183#line 27 "dyntest.pgc"
184 int DATETIME_INTERVAL_CODE ;
185
186#line 28 "dyntest.pgc"
187 char NAME [ 120 ] , BOOLVAR ;
188
189#line 29 "dyntest.pgc"
190 char STRINGVAR [ 1024 ] ;
191
192#line 30 "dyntest.pgc"
193 double DOUBLEVAR ;
194
195#line 31 "dyntest.pgc"
196 char * QUERY ;
197
198#line 32 "dyntest.pgc"
199
200 int done = 0;
201
202
203#line 35 "dyntest.pgc"
204
205
207
208 QUERY = "select * from dyntest";
209
210
211#line 43 "dyntest.pgc"
212
213
215#line 45 "dyntest.pgc"
216
218#line 45 "dyntest.pgc"
219
220
221 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
222#line 47 "dyntest.pgc"
223
225#line 47 "dyntest.pgc"
226
227
229#line 49 "dyntest.pgc"
230
232#line 49 "dyntest.pgc"
233
234
235 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date )", ECPGt_EOIT, ECPGt_EORT);
236#line 53 "dyntest.pgc"
237
239#line 53 "dyntest.pgc"
240
241 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into dyntest values ( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' )", ECPGt_EOIT, ECPGt_EORT);
242#line 54 "dyntest.pgc"
243
245#line 54 "dyntest.pgc"
246
247 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into dyntest values ( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' )", ECPGt_EOIT, ECPGt_EORT);
248#line 55 "dyntest.pgc"
249
251#line 55 "dyntest.pgc"
252
253
254 { ECPGprepare(__LINE__, NULL, 0, "myquery", QUERY);
255#line 57 "dyntest.pgc"
256
258#line 57 "dyntest.pgc"
259
260
261#line 58 "dyntest.pgc"
262
263
264 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare MYCURS cursor for $1",
267#line 60 "dyntest.pgc"
268
270#line 60 "dyntest.pgc"
271
272
273 while (1)
274 {
278#line 64 "dyntest.pgc"
279
281#line 64 "dyntest.pgc"
282
283
284 if (sqlca.sqlcode)
285 break;
286
288
289#line 69 "dyntest.pgc"
290
292#line 69 "dyntest.pgc"
293
294 if (!done)
295 {
297 done = 1;
298 }
299
300 for (INDEX = 1; INDEX <= COUNT; ++INDEX)
301 {
311
312#line 86 "dyntest.pgc"
313
315#line 86 "dyntest.pgc"
316
317 printf ("%2d\t%s (type: %d length: %d precision: %d scale: %d = " , INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE);
318 switch (TYPE)
319 {
322 break;
324 printf ("numeric(%d,%d)", PRECISION, SCALE);
325 break;
327 printf ("decimal(%d,%d)", PRECISION, SCALE);
328 break;
331 break;
334 break;
336 printf ("float(%d,%d)", PRECISION, SCALE);
337 break;
340 break;
342 printf ("double precision");
343 break;
346 ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
347
348#line 116 "dyntest.pgc"
349
351#line 116 "dyntest.pgc"
352
353 switch (DATETIME_INTERVAL_CODE)
354 {
357 break;
360 break;
362 printf ("timestamp");
363 break;
365 printf ("time with time zone");
366 break;
368 printf ("timestamp with time zone");
369 break;
370 }
371 break;
374 break;
376 if (LENGTH > 0)
377 printf ("char(%d)", LENGTH);
378 else
380 break;
382 if (LENGTH > 0)
383 printf ("varchar(%d)", LENGTH);
384 else
385 printf ("varchar()");
386 break;
387 default:
388 printf ("<SQL3 %d>", TYPE);
389 break;
390 }
391 printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
392 OCTET_LENGTH, RETURNED_OCTET_LENGTH);
393 if (INDICATOR == -1)
395 else
396 switch (TYPE)
397 {
401
402#line 163 "dyntest.pgc"
403
405#line 163 "dyntest.pgc"
406
407 printf ("%s\n", BOOLVAR ? "true" : "false");
408 break;
413
414#line 168 "dyntest.pgc"
415
417#line 168 "dyntest.pgc"
418
419 printf ("%d\n", INTVAR);
420 break;
424
425#line 172 "dyntest.pgc"
426
428#line 172 "dyntest.pgc"
429
430 printf ("%.*f\n", PRECISION, DOUBLEVAR);
431 break;
435 ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
436
437#line 178 "dyntest.pgc"
438
440#line 178 "dyntest.pgc"
441
442 printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
443 break;
448
449#line 183 "dyntest.pgc"
450
452#line 183 "dyntest.pgc"
453
454 printf ("\"%s\"\n", STRINGVAR);
455 break;
456 default:
459
460#line 187 "dyntest.pgc"
461
463#line 187 "dyntest.pgc"
464
465 printf ("<\"%s\">\n", STRINGVAR);
466 break;
467 }
468 }
469 }
470
472#line 194 "dyntest.pgc"
473
475#line 194 "dyntest.pgc"
476
477
479#line 196 "dyntest.pgc"
480
482#line 196 "dyntest.pgc"
483
484
485 return 0;
486 }
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
bool ECPGdeallocate_desc(int line, const char *name)
bool ECPGget_desc(int lineno, const char *desc_name, int index,...)
bool ECPGallocate_desc(int line, const char *name)
bool ECPGget_desc_header(int lineno, const char *desc_name, int *count)
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
@ SQL3_DATE_TIME_TIMESTAMP
struct sqlca_t * ECPGget_sqlca(void)
@ SQL3_DDT_TIME_WITH_TIME_ZONE
@ SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE
struct sqlca_t::@168 sqlerrm
char sqlerrmc[SQLERRMC_LEN]