PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
preproc-autoprep.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for preproc-autoprep.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Functions

static void test (void)
 
int main ()
 

Macro Definition Documentation

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file preproc-autoprep.c.

Referenced by test().

Function Documentation

int main ( void  )

Definition at line 251 of file preproc-autoprep.c.

References test().

251  {
252  test();
253  test(); /* retry */
254 
255  return 0;
256 }
static void test(void)
static void test ( void  )
static

Definition at line 26 of file preproc-autoprep.c.

References ECPG_NOT_FOUND, ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGprepare(), ECPGprepared_statement(), ECPGst_execute, ECPGst_normal, ECPGst_prepnormal, ECPGt_char_variable, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, i, NULL, sqlca, and sqlprint().

Referenced by _bt_checkkeys(), _hash_checkqual(), EvalPlanQualFetch(), ExecLockRows(), ExecOnConflictUpdate(), GetTupleForTrigger(), gistindex_keytest(), main(), run_schedule(), SnapBuildExportSnapshot(), and StringAt().

26  {
27  /* exec sql begin declare section */
28 
29 
30 
31 
32 #line 10 "autoprep.pgc"
33  int item [ 4 ] , ind [ 4 ] , i = 1 ;
34 
35 #line 11 "autoprep.pgc"
36  int item1 , ind1 ;
37 
38 #line 12 "autoprep.pgc"
39  char sqlstr [ 64 ] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST" ;
40 /* exec sql end declare section */
41 #line 13 "autoprep.pgc"
42 
43 
44  ECPGdebug(1, stderr);
45  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
46 #line 16 "autoprep.pgc"
47 
48 
49  /* exec sql whenever sql_warning sqlprint ; */
50 #line 18 "autoprep.pgc"
51 
52  /* exec sql whenever sqlerror sqlprint ; */
53 #line 19 "autoprep.pgc"
54 
55 
56  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
57 #line 21 "autoprep.pgc"
58 
59 if (sqlca.sqlwarn[0] == 'W') sqlprint();
60 #line 21 "autoprep.pgc"
61 
62 if (sqlca.sqlcode < 0) sqlprint();}
63 #line 21 "autoprep.pgc"
64 
65 
66  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
67 #line 23 "autoprep.pgc"
68 
69 if (sqlca.sqlwarn[0] == 'W') sqlprint();
70 #line 23 "autoprep.pgc"
71 
72 if (sqlca.sqlcode < 0) sqlprint();}
73 #line 23 "autoprep.pgc"
74 
75  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1 )",
76  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
78 #line 24 "autoprep.pgc"
79 
80 if (sqlca.sqlwarn[0] == 'W') sqlprint();
81 #line 24 "autoprep.pgc"
82 
83 if (sqlca.sqlcode < 0) sqlprint();}
84 #line 24 "autoprep.pgc"
85 
86  i++;
87  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1 )",
88  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
90 #line 26 "autoprep.pgc"
91 
92 if (sqlca.sqlwarn[0] == 'W') sqlprint();
93 #line 26 "autoprep.pgc"
94 
95 if (sqlca.sqlcode < 0) sqlprint();}
96 #line 26 "autoprep.pgc"
97 
98  { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
99 #line 27 "autoprep.pgc"
100 
101 if (sqlca.sqlwarn[0] == 'W') sqlprint();
102 #line 27 "autoprep.pgc"
103 
104 if (sqlca.sqlcode < 0) sqlprint();}
105 #line 27 "autoprep.pgc"
106 
107  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", ECPGt_EOIT, ECPGt_EORT);
108 #line 28 "autoprep.pgc"
109 
110 if (sqlca.sqlwarn[0] == 'W') sqlprint();
111 #line 28 "autoprep.pgc"
112 
113 if (sqlca.sqlcode < 0) sqlprint();}
114 #line 28 "autoprep.pgc"
115 
116 
117  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT,
118  ECPGt_int,(item),(long)1,(long)4,sizeof(int),
119  ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
120 #line 30 "autoprep.pgc"
121 
122 if (sqlca.sqlwarn[0] == 'W') sqlprint();
123 #line 30 "autoprep.pgc"
124 
125 if (sqlca.sqlcode < 0) sqlprint();}
126 #line 30 "autoprep.pgc"
127 
128 
129  for (i=0; i<4; i++)
130  printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
131 
132  /* declare C cursor for select Item1 from T */
133 #line 35 "autoprep.pgc"
134 
135 
136  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
137 #line 37 "autoprep.pgc"
138 
139 if (sqlca.sqlwarn[0] == 'W') sqlprint();
140 #line 37 "autoprep.pgc"
141 
142 if (sqlca.sqlcode < 0) sqlprint();}
143 #line 37 "autoprep.pgc"
144 
145 
146  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT,
147  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
148  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
149 #line 39 "autoprep.pgc"
150 
151 if (sqlca.sqlwarn[0] == 'W') sqlprint();
152 #line 39 "autoprep.pgc"
153 
154 if (sqlca.sqlcode < 0) sqlprint();}
155 #line 39 "autoprep.pgc"
156 
157  printf("i = %d\n", i);
158 
159  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
160 #line 42 "autoprep.pgc"
161 
162 if (sqlca.sqlwarn[0] == 'W') sqlprint();
163 #line 42 "autoprep.pgc"
164 
165 if (sqlca.sqlcode < 0) sqlprint();}
166 #line 42 "autoprep.pgc"
167 
168 
169  { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr);
170 #line 44 "autoprep.pgc"
171 
172 if (sqlca.sqlwarn[0] == 'W') sqlprint();
173 #line 44 "autoprep.pgc"
174 
175 if (sqlca.sqlcode < 0) sqlprint();}
176 #line 44 "autoprep.pgc"
177 
178 
179  /* declare cur1 cursor for $1 */
180 #line 46 "autoprep.pgc"
181 
182 
183  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1",
184  ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
185  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
186 #line 48 "autoprep.pgc"
187 
188 if (sqlca.sqlwarn[0] == 'W') sqlprint();
189 #line 48 "autoprep.pgc"
190 
191 if (sqlca.sqlcode < 0) sqlprint();}
192 #line 48 "autoprep.pgc"
193 
194 
195  /* exec sql whenever not found break ; */
196 #line 50 "autoprep.pgc"
197 
198 
199  i = 0;
200  while (1)
201  {
202  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT,
203  ECPGt_int,&(item1),(long)1,(long)1,sizeof(int),
204  ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
205 #line 55 "autoprep.pgc"
206 
207 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
208 #line 55 "autoprep.pgc"
209 
210 if (sqlca.sqlwarn[0] == 'W') sqlprint();
211 #line 55 "autoprep.pgc"
212 
213 if (sqlca.sqlcode < 0) sqlprint();}
214 #line 55 "autoprep.pgc"
215 
216  printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
217  i++;
218  }
219 
220  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
221 #line 60 "autoprep.pgc"
222 
223 if (sqlca.sqlwarn[0] == 'W') sqlprint();
224 #line 60 "autoprep.pgc"
225 
226 if (sqlca.sqlcode < 0) sqlprint();}
227 #line 60 "autoprep.pgc"
228 
229 
230  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
231 #line 62 "autoprep.pgc"
232 
233 if (sqlca.sqlwarn[0] == 'W') sqlprint();
234 #line 62 "autoprep.pgc"
235 
236 if (sqlca.sqlcode < 0) sqlprint();}
237 #line 62 "autoprep.pgc"
238 
239 
240  { ECPGdisconnect(__LINE__, "ALL");
241 #line 64 "autoprep.pgc"
242 
243 if (sqlca.sqlwarn[0] == 'W') sqlprint();
244 #line 64 "autoprep.pgc"
245 
246 if (sqlca.sqlcode < 0) sqlprint();}
247 #line 64 "autoprep.pgc"
248 
249 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
#define sqlca
Definition: sqlca.h:59
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,...)
Definition: execute.c:2031
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
Definition: prepare.c:161
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
#define ECPG_NOT_FOUND
Definition: ecpgerrno.h:10
void sqlprint(void)
Definition: error.c:336
#define ECPGdebug(X, Y)
#define NULL
Definition: c.h:226
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
Definition: prepare.c:306
int i