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))
9
#line 1 "outofscope.pgc"
16
#line 1 "regression.h"
23
#line 6 "outofscope.pgc"
27
#line 1 "pgtypes_numeric.h"
28
#ifndef PGTYPES_NUMERIC
29
#define PGTYPES_NUMERIC
31
#define NUMERIC_POS 0x0000
32
#define NUMERIC_NEG 0x4000
33
#define NUMERIC_NAN 0xC000
34
#define NUMERIC_NULL 0xF000
35
#define NUMERIC_MAX_PRECISION 1000
36
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
37
#define NUMERIC_MIN_DISPLAY_SCALE 0
38
#define NUMERIC_MIN_SIG_DIGITS 16
42
typedef unsigned char NumericDigit;
45
int ndigits; /* number of digits in digits[] - can be 0! */
46
int weight; /* weight of first digit */
47
int rscale; /* result scale */
48
int dscale; /* display scale */
49
int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
50
NumericDigit *buf; /* start of alloc'd space for digits[] */
51
NumericDigit *digits; /* decimal digits */
56
int ndigits; /* number of digits in digits[] - can be 0! */
57
int weight; /* weight of first digit */
58
int rscale; /* result scale */
59
int dscale; /* display scale */
60
int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
61
NumericDigit digits[DECSIZE]; /* decimal digits */
69
numeric *PGTYPESnumeric_new(void);
70
decimal *PGTYPESdecimal_new(void);
71
void PGTYPESnumeric_free(numeric *);
72
void PGTYPESdecimal_free(decimal *);
73
numeric *PGTYPESnumeric_from_asc(char *, char **);
74
char *PGTYPESnumeric_to_asc(numeric *, int);
75
int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
76
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
77
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
78
int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
79
int PGTYPESnumeric_cmp(numeric *, numeric *);
80
int PGTYPESnumeric_from_int(signed int, numeric *);
81
int PGTYPESnumeric_from_long(signed long int, numeric *);
82
int PGTYPESnumeric_copy(numeric *, numeric *);
83
int PGTYPESnumeric_from_double(double, numeric *);
84
int PGTYPESnumeric_to_double(numeric *, double *);
85
int PGTYPESnumeric_to_int(numeric *, int *);
86
int PGTYPESnumeric_to_long(numeric *, long *);
87
int PGTYPESnumeric_to_decimal(numeric *, decimal *);
88
int PGTYPESnumeric_from_decimal(decimal *, numeric *);
94
#endif /* PGTYPES_NUMERIC */
96
#line 8 "outofscope.pgc"
99
/* exec sql begin declare section */
110
typedef struct mytype MYTYPE ;
123
typedef struct mynulltype MYNULLTYPE ;
128
#line 11 "outofscope.pgc"
145
} ; struct mynulltype {
160
} ;/* exec sql end declare section */
161
#line 12 "outofscope.pgc"
164
/* exec sql whenever sqlerror stop ; */
165
#line 14 "outofscope.pgc"
168
/* Functions for test 1 */
171
get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
173
/* exec sql begin declare section */
177
#line 22 "outofscope.pgc"
178
MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
180
#line 23 "outofscope.pgc"
181
MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
182
/* exec sql end declare section */
183
#line 24 "outofscope.pgc"
186
/* Test DECLARE ... SELECT ... INTO with pointers */
188
ECPGset_var( 0, ( myvar ), __LINE__);\
189
ECPGset_var( 1, ( mynullvar ), __LINE__);\
190
/* declare mycur cursor for select * from a1 */
191
#line 28 "outofscope.pgc"
194
if (sqlca.sqlcode != 0)
198
*mynullvar0 = mynullvar;
204
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
205
ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int),
206
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int),
207
ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
208
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int),
209
ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double),
210
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int),
211
ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double),
212
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int),
213
ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
214
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
215
#line 40 "outofscope.pgc"
217
if (sqlca.sqlcode < 0) exit (1);}
218
#line 40 "outofscope.pgc"
221
if (sqlca.sqlcode != 0)
228
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT,
229
ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int),
230
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int),
231
ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
232
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int),
233
ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double),
234
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int),
235
ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double),
236
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int),
237
ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
238
ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
239
#line 49 "outofscope.pgc"
241
if (sqlca.sqlcode < 0) exit (1);}
242
#line 49 "outofscope.pgc"
245
if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
252
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
253
#line 58 "outofscope.pgc"
255
if (sqlca.sqlcode < 0) exit (1);}
256
#line 58 "outofscope.pgc"
259
if (sqlca.sqlcode != 0)
267
MYNULLTYPE *mynullvar;
271
ECPGdebug(1, stderr);
273
strcpy(msg, "connect");
274
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
275
#line 75 "outofscope.pgc"
277
if (sqlca.sqlcode < 0) exit (1);}
278
#line 75 "outofscope.pgc"
282
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
283
#line 78 "outofscope.pgc"
285
if (sqlca.sqlcode < 0) exit (1);}
286
#line 78 "outofscope.pgc"
289
strcpy(msg, "create");
290
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
291
#line 81 "outofscope.pgc"
293
if (sqlca.sqlcode < 0) exit (1);}
294
#line 81 "outofscope.pgc"
297
strcpy(msg, "insert");
298
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
299
#line 84 "outofscope.pgc"
301
if (sqlca.sqlcode < 0) exit (1);}
302
#line 84 "outofscope.pgc"
304
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
305
#line 85 "outofscope.pgc"
307
if (sqlca.sqlcode < 0) exit (1);}
308
#line 85 "outofscope.pgc"
310
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
311
#line 86 "outofscope.pgc"
313
if (sqlca.sqlcode < 0) exit (1);}
314
#line 86 "outofscope.pgc"
317
strcpy(msg, "commit");
318
{ ECPGtrans(__LINE__, NULL, "commit");
319
#line 89 "outofscope.pgc"
321
if (sqlca.sqlcode < 0) exit (1);}
322
#line 89 "outofscope.pgc"
325
/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
327
get_var1(&myvar, &mynullvar);
330
/* exec sql whenever not found break ; */
331
#line 96 "outofscope.pgc"
336
memset(myvar, 0, sizeof(MYTYPE));
338
if (sqlca.sqlcode == ECPG_NOT_FOUND)
340
printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
341
myvar->id, mynullvar->id ? " (NULL)" : "",
342
myvar->t, mynullvar->t ? " (NULL)" : "",
343
myvar->d1, mynullvar->d1 ? " (NULL)" : "",
344
myvar->d2, mynullvar->d2 ? " (NULL)" : "",
345
myvar->c, mynullvar->c ? " (NULL)" : "");
351
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
352
#line 115 "outofscope.pgc"
354
if (sqlca.sqlcode < 0) exit (1);}
355
#line 115 "outofscope.pgc"
358
strcpy(msg, "commit");
359
{ ECPGtrans(__LINE__, NULL, "commit");
360
#line 118 "outofscope.pgc"
362
if (sqlca.sqlcode < 0) exit (1);}
363
#line 118 "outofscope.pgc"
366
strcpy(msg, "disconnect");
367
{ ECPGdisconnect(__LINE__, "CURRENT");
368
#line 121 "outofscope.pgc"
370
if (sqlca.sqlcode < 0) exit (1);}
371
#line 121 "outofscope.pgc"