| 1 |
/* Processed by ecpg (regression mode) */ |
| 2 |
/* These include files are added by the preprocessor */ |
| 3 |
#include <ecpglib.h> |
| 4 |
#include <ecpgerrno.h> |
| 5 |
#include <sqlca.h> |
| 6 |
/* End of automatic include section */ |
| 7 |
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) |
| 8 |
|
| 9 |
#line 1 "define_prelim.pgc" |
| 10 |
/* |
| 11 |
* Test that the effects of these commands don't carry over to the next |
| 12 |
* file named on the ecpg command line. |
| 13 |
*/ |
| 14 |
|
| 15 |
|
| 16 |
/* Processed by ecpg (regression mode) */ |
| 17 |
/* These include files are added by the preprocessor */ |
| 18 |
#include <ecpglib.h> |
| 19 |
#include <ecpgerrno.h> |
| 20 |
#include <sqlca.h> |
| 21 |
/* End of automatic include section */ |
| 22 |
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) |
| 23 |
|
| 24 |
#line 1 "define.pgc" |
| 25 |
|
| 26 |
#line 1 "sqlca.h" |
| 27 |
#ifndef POSTGRES_SQLCA_H |
| 28 |
#define POSTGRES_SQLCA_H |
| 29 |
|
| 30 |
#ifndef PGDLLIMPORT |
| 31 |
#if defined(WIN32) || defined(__CYGWIN__) |
| 32 |
#define PGDLLIMPORT __declspec (dllimport) |
| 33 |
#else |
| 34 |
#define PGDLLIMPORT |
| 35 |
#endif /* __CYGWIN__ */ |
| 36 |
#endif /* PGDLLIMPORT */ |
| 37 |
|
| 38 |
#define SQLERRMC_LEN 150 |
| 39 |
|
| 40 |
#ifdef __cplusplus |
| 41 |
extern "C" |
| 42 |
{ |
| 43 |
#endif |
| 44 |
|
| 45 |
struct sqlca_t |
| 46 |
{ |
| 47 |
char sqlcaid[8]; |
| 48 |
long sqlabc; |
| 49 |
long sqlcode; |
| 50 |
struct |
| 51 |
{ |
| 52 |
int sqlerrml; |
| 53 |
char sqlerrmc[SQLERRMC_LEN]; |
| 54 |
} sqlerrm; |
| 55 |
char sqlerrp[8]; |
| 56 |
long sqlerrd[6]; |
| 57 |
/* Element 0: empty */ |
| 58 |
/* 1: OID of processed tuple if applicable */ |
| 59 |
/* 2: number of rows processed */ |
| 60 |
/* after an INSERT, UPDATE or */ |
| 61 |
/* DELETE statement */ |
| 62 |
/* 3: empty */ |
| 63 |
/* 4: empty */ |
| 64 |
/* 5: empty */ |
| 65 |
char sqlwarn[8]; |
| 66 |
/* Element 0: set to 'W' if at least one other is 'W' */ |
| 67 |
/* 1: if 'W' at least one character string */ |
| 68 |
/* value was truncated when it was */ |
| 69 |
/* stored into a host variable. */ |
| 70 |
|
| 71 |
/* |
| 72 |
* 2: if 'W' a (hopefully) non-fatal notice occurred |
| 73 |
*/ /* 3: empty */ |
| 74 |
/* 4: empty */ |
| 75 |
/* 5: empty */ |
| 76 |
/* 6: empty */ |
| 77 |
/* 7: empty */ |
| 78 |
|
| 79 |
char sqlstate[5]; |
| 80 |
}; |
| 81 |
|
| 82 |
struct sqlca_t *ECPGget_sqlca(void); |
| 83 |
|
| 84 |
#ifndef POSTGRES_ECPG_INTERNAL |
| 85 |
#define sqlca (*ECPGget_sqlca()) |
| 86 |
#endif |
| 87 |
|
| 88 |
#ifdef __cplusplus |
| 89 |
} |
| 90 |
#endif |
| 91 |
|
| 92 |
#endif |
| 93 |
|
| 94 |
#line 1 "define.pgc" |
| 95 |
|
| 96 |
|
| 97 |
#line 1 "regression.h" |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
#line 2 "define.pgc" |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
int main(void) |
| 111 |
{ |
| 112 |
/* exec sql begin declare section */ |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
#line 10 "define.pgc" |
| 117 |
int i ; |
| 118 |
|
| 119 |
#line 11 "define.pgc" |
| 120 |
char s [ 200 ] ; |
| 121 |
/* exec sql end declare section */ |
| 122 |
#line 12 "define.pgc" |
| 123 |
|
| 124 |
|
| 125 |
ECPGdebug(1, stderr); |
| 126 |
|
| 127 |
/* exec sql whenever sqlerror do sqlprint ( ) ; */ |
| 128 |
#line 16 "define.pgc" |
| 129 |
|
| 130 |
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); |
| 131 |
#line 17 "define.pgc" |
| 132 |
|
| 133 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 134 |
#line 17 "define.pgc" |
| 135 |
|
| 136 |
|
| 137 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT); |
| 138 |
#line 19 "define.pgc" |
| 139 |
|
| 140 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 141 |
#line 19 "define.pgc" |
| 142 |
|
| 143 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'abcdef' )", ECPGt_EOIT, ECPGt_EORT); |
| 144 |
#line 20 "define.pgc" |
| 145 |
|
| 146 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 147 |
#line 20 "define.pgc" |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'defined' )", ECPGt_EOIT, ECPGt_EORT); |
| 152 |
#line 23 "define.pgc" |
| 153 |
|
| 154 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 155 |
#line 23 "define.pgc" |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'someothervar not defined' )", ECPGt_EOIT, ECPGt_EORT); |
| 165 |
#line 31 "define.pgc" |
| 166 |
|
| 167 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 168 |
#line 31 "define.pgc" |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 , 29 :: text || '-' || 'abcdef'", ECPGt_EOIT, |
| 175 |
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |
| 176 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 177 |
ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), |
| 178 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 179 |
#line 36 "define.pgc" |
| 180 |
|
| 181 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 182 |
#line 36 "define.pgc" |
| 183 |
|
| 184 |
|
| 185 |
printf("i: %d, s: %s\n", i, s); |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'no string' )", ECPGt_EOIT, ECPGt_EORT); |
| 190 |
#line 42 "define.pgc" |
| 191 |
|
| 192 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 193 |
#line 42 "define.pgc" |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
/* no value */ |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT); |
| 206 |
#line 53 "define.pgc" |
| 207 |
|
| 208 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 209 |
#line 53 "define.pgc" |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
/* test handling of a macro defined on the command line */ |
| 214 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 123", ECPGt_EOIT, |
| 215 |
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |
| 216 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 217 |
#line 57 "define.pgc" |
| 218 |
|
| 219 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 220 |
#line 57 "define.pgc" |
| 221 |
|
| 222 |
printf("original CMDLINESYM: %d\n", i); |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 42", ECPGt_EOIT, |
| 227 |
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |
| 228 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 229 |
#line 62 "define.pgc" |
| 230 |
|
| 231 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 232 |
#line 62 "define.pgc" |
| 233 |
|
| 234 |
printf("redefined CMDLINESYM: %d\n", i); |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 43", ECPGt_EOIT, |
| 239 |
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |
| 240 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 241 |
#line 67 "define.pgc" |
| 242 |
|
| 243 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 244 |
#line 67 "define.pgc" |
| 245 |
|
| 246 |
printf("redefined CMDLINESYM: %d\n", i); |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
/* this macro should not have carried over from define_prelim.pgc */ |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
{ ECPGdisconnect(__LINE__, "CURRENT"); |
| 260 |
#line 81 "define.pgc" |
| 261 |
|
| 262 |
if (sqlca.sqlcode < 0) sqlprint ( );} |
| 263 |
#line 81 "define.pgc" |
| 264 |
|
| 265 |
return 0; |
| 266 |
} |