PostgreSQL Source Code: src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c Source File (original) (raw)
1
2
6
8
9#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
10
11#line 1 "test_informix2.pgc"
12#include <stdio.h>
13#include <stdlib.h>
15
16
17#line 1 "sqlca.h"
18#ifndef POSTGRES_SQLCA_H
19#define POSTGRES_SQLCA_H
20
21#ifndef PGDLLIMPORT
22#if defined(WIN32) || defined(__CYGWIN__)
23#define PGDLLIMPORT __declspec (dllimport)
24#else
25#define PGDLLIMPORT
26#endif
27#endif
28
29#define SQLERRMC_LEN 150
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif
35
37{
41 struct
42 {
48
49
50
51
52
53
54
55
57
58
59
60
61
62
63
64
65
66
67
68
69
71};
72
74
75#ifndef POSTGRES_ECPG_INTERNAL
76#define sqlca (*ECPGget_sqlca())
77#endif
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif
84
85#line 5 "test_informix2.pgc"
86
87
88#line 1 "regression.h"
89
90
91
92
93
94
95#line 6 "test_informix2.pgc"
96
97
98
99
100static void sql_check(const char *fn, const char *caller, int ignore)
101{
102 char errorstring[255];
103
105 return;
106 else
107 {
109 {
110
111 sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]",
113 fprintf(stderr, "%s", errorstring);
114 printf("%s\n", errorstring);
115
116
117 { ECPGtrans(__LINE__, NULL, "rollback");}
118#line 27 "test_informix2.pgc"
119
120
122 {
123 sprintf(errorstring, "Rollback successful.\n");
124 } else {
125 sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
126 }
127
128 fprintf(stderr, "%s", errorstring);
129 printf("%s\n", errorstring);
130
131 exit(1);
132 }
133 }
134}
135
137{
138
139
140
141
142
143
144
145#line 47 "test_informix2.pgc"
146 int c ;
147
148#line 48 "test_informix2.pgc"
150
151#line 49 "test_informix2.pgc"
153
154#line 50 "test_informix2.pgc"
156
157#line 51 "test_informix2.pgc"
159
160#line 52 "test_informix2.pgc"
161
162
164
165
166#line 56 "test_informix2.pgc"
167
168
170
171 strcpy(dbname, "ecpg1_regression");
173#line 61 "test_informix2.pgc"
174
175if (sqlca.sqlcode < 0) exit (1);}
176#line 61 "test_informix2.pgc"
177
179
181#line 64 "test_informix2.pgc"
182
183if (sqlca.sqlcode < 0) exit (1);}
184#line 64 "test_informix2.pgc"
185
186
187 { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) )", ECPGt_EOIT, ECPGt_EORT);
188#line 66 "test_informix2.pgc"
189
190if (sqlca.sqlcode < 0) exit (1);}
191#line 66 "test_informix2.pgc"
192
194
195 { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT);
196#line 71 "test_informix2.pgc"
197
198if (sqlca.sqlcode < 0) exit (1);}
199#line 71 "test_informix2.pgc"
200
202
206#line 76 "test_informix2.pgc"
207
208if (sqlca.sqlcode < 0) exit (1);}
209#line 76 "test_informix2.pgc"
210
211 sql_check("main", "select max", 100);
212
213 { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select customerid , timestamp from history where timestamp = $1 limit 1",
216 ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
220#line 83 "test_informix2.pgc"
221
222if (sqlca.sqlcode < 0) exit (1);}
223#line 83 "test_informix2.pgc"
224
226
227 printf("Read in customer %d\n", c);
228
232 c++;
233
234 { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1,1 , 1,2 , 'test' , 'test' )",
235 ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
239#line 95 "test_informix2.pgc"
240
241if (sqlca.sqlcode < 0) exit (1);}
242#line 95 "test_informix2.pgc"
243
245
246 { ECPGtrans(__LINE__, NULL, "commit");
247#line 98 "test_informix2.pgc"
248
249if (sqlca.sqlcode < 0) exit (1);}
250#line 98 "test_informix2.pgc"
251
252
254#line 100 "test_informix2.pgc"
255
256if (sqlca.sqlcode < 0) exit (1);}
257#line 100 "test_informix2.pgc"
258
260
261 { ECPGtrans(__LINE__, NULL, "commit");
262#line 103 "test_informix2.pgc"
263
264if (sqlca.sqlcode < 0) exit (1);}
265#line 103 "test_informix2.pgc"
266
267
269#line 105 "test_informix2.pgc"
270
271if (sqlca.sqlcode < 0) exit (1);}
272#line 105 "test_informix2.pgc"
273
274 sql_check("main", "disconnect", 0);
275
277
278 exit(0);
279
280
281
282
283
284
285
286
287
288
289
290}
struct sqlca_t * ECPGget_sqlca(void)
static void sql_check(const char *fn, const char *caller, int ignore)
bool ECPGdisconnect(int lineno, const char *connection_name)
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
#define fprintf(file, fmt, msg)
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,...)
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
interval * PGTYPESinterval_from_asc(char *str, char **endptr)
int PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tout)
struct sqlca_t::@168 sqlerrm
char sqlerrmc[SQLERRMC_LEN]
static void * fn(void *arg)