PostgreSQL Source Code  git master
sql-define.c
Go to the documentation of this file.
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.pgc"
10 
11 #line 1 "sqlca.h"
12 #ifndef POSTGRES_SQLCA_H
13 #define POSTGRES_SQLCA_H
14 
15 #ifndef PGDLLIMPORT
16 #if defined(WIN32) || defined(__CYGWIN__)
17 #define PGDLLIMPORT __declspec (dllimport)
18 #else
19 #define PGDLLIMPORT
20 #endif /* __CYGWIN__ */
21 #endif /* PGDLLIMPORT */
22 
23 #define SQLERRMC_LEN 150
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30 struct sqlca_t
31 {
32  char sqlcaid[8];
33  long sqlabc;
34  long sqlcode;
35  struct
36  {
37  int sqlerrml;
38  char sqlerrmc[SQLERRMC_LEN];
40  char sqlerrp[8];
41  long sqlerrd[6];
42  /* Element 0: empty */
43  /* 1: OID of processed tuple if applicable */
44  /* 2: number of rows processed */
45  /* after an INSERT, UPDATE or */
46  /* DELETE statement */
47  /* 3: empty */
48  /* 4: empty */
49  /* 5: empty */
50  char sqlwarn[8];
51  /* Element 0: set to 'W' if at least one other is 'W' */
52  /* 1: if 'W' at least one character string */
53  /* value was truncated when it was */
54  /* stored into a host variable. */
55 
56  /*
57  * 2: if 'W' a (hopefully) non-fatal notice occurred
58  */ /* 3: empty */
59  /* 4: empty */
60  /* 5: empty */
61  /* 6: empty */
62  /* 7: empty */
63 
64  char sqlstate[5];
65 };
66 
67 struct sqlca_t *ECPGget_sqlca(void);
68 
69 #ifndef POSTGRES_ECPG_INTERNAL
70 #define sqlca (*ECPGget_sqlca())
71 #endif
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif
78 
79 #line 1 "define.pgc"
80 
81 
82 #line 1 "regression.h"
83 
84 
85 
86 
87 
88 
89 #line 2 "define.pgc"
90 
91 
92 
93 
94 
95 int main(void)
96 {
97  /* exec sql begin declare section */
98 
99 
100 
101 #line 10 "define.pgc"
102  int i ;
103 
104 #line 11 "define.pgc"
105  char s [ 200 ] ;
106 /* exec sql end declare section */
107 #line 12 "define.pgc"
108 
109 
110  ECPGdebug(1, stderr);
111 
112  /* exec sql whenever sqlerror do sqlprint ( ) ; */
113 #line 16 "define.pgc"
114 
115  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
116 #line 17 "define.pgc"
117 
118 if (sqlca.sqlcode < 0) sqlprint ( );}
119 #line 17 "define.pgc"
120 
121 
122  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
123 #line 19 "define.pgc"
124 
125 if (sqlca.sqlcode < 0) sqlprint ( );}
126 #line 19 "define.pgc"
127 
128  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'abcdef' )", ECPGt_EOIT, ECPGt_EORT);
129 #line 20 "define.pgc"
130 
131 if (sqlca.sqlcode < 0) sqlprint ( );}
132 #line 20 "define.pgc"
133 
134 
135 
136  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'defined' )", ECPGt_EOIT, ECPGt_EORT);
137 #line 23 "define.pgc"
138 
139 if (sqlca.sqlcode < 0) sqlprint ( );}
140 #line 23 "define.pgc"
141 
142 
143 
144 
145 
146 
147 
148 
149  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'someothervar not defined' )", ECPGt_EOIT, ECPGt_EORT);
150 #line 31 "define.pgc"
151 
152 if (sqlca.sqlcode < 0) sqlprint ( );}
153 #line 31 "define.pgc"
154 
155 
156 
157 
158 
159  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 , 29 :: text || '-' || 'abcdef'", ECPGt_EOIT,
160  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
161  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
162  ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char),
163  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
164 #line 36 "define.pgc"
165 
166 if (sqlca.sqlcode < 0) sqlprint ( );}
167 #line 36 "define.pgc"
168 
169 
170  printf("i: %d, s: %s\n", i, s);
171 
172 
173 
174  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'no string' )", ECPGt_EOIT, ECPGt_EORT);
175 #line 42 "define.pgc"
176 
177 if (sqlca.sqlcode < 0) sqlprint ( );}
178 #line 42 "define.pgc"
179 
180 
181 
182  /* no value */
183 
184 
185 
186 
187 
188 
189 
190  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT);
191 #line 53 "define.pgc"
192 
193 if (sqlca.sqlcode < 0) sqlprint ( );}
194 #line 53 "define.pgc"
195 
196 
197 
198  { ECPGdisconnect(__LINE__, "CURRENT");
199 #line 56 "define.pgc"
200 
201 if (sqlca.sqlcode < 0) sqlprint ( );}
202 #line 56 "define.pgc"
203 
204  return 0;
205 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:673
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_char
Definition: ecpgtype.h:43
void sqlprint(void)
Definition: error.c:334
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:2277
int i
Definition: isn.c:73
#define printf(...)
Definition: port.h:244
int main(void)
Definition: sql-define.c:95
#define SQLERRMC_LEN
Definition: sql-define.c:23
struct sqlca_t * ECPGget_sqlca(void)
Definition: misc.c:108
#define sqlca
Definition: sql-define.c:70
#define ECPGdebug(X, Y)
Definition: sql-define.c:7
Definition: sqlca.h:20
char sqlerrp[8]
Definition: sqlca.h:29
long sqlerrd[6]
Definition: sqlca.h:30
char sqlstate[5]
Definition: sqlca.h:53
struct sqlca_t::@151 sqlerrm
char sqlwarn[8]
Definition: sqlca.h:39
long sqlabc
Definition: sqlca.h:22
char sqlcaid[8]
Definition: sqlca.h:21
char sqlerrmc[SQLERRMC_LEN]
Definition: sqlca.h:27
long sqlcode
Definition: sqlca.h:23
int sqlerrml
Definition: sqlca.h:26