PostgreSQL Source Code git master
sql-code100.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 "code100.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
26extern "C"
27{
28#endif
29
30struct sqlca_t
31{
32 char sqlcaid[8];
33 long sqlabc;
34 long sqlcode;
35 struct
36 {
37 int sqlerrml;
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
67struct 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 "code100.pgc"
80
81#include <stdio.h>
82
83
84#line 1 "regression.h"
85
86
87
88
89
90
91#line 4 "code100.pgc"
92
93
94
95int main()
96{ /* exec sql begin declare section */
97
98
99#line 9 "code100.pgc"
100 int index ;
101/* exec sql end declare section */
102#line 10 "code100.pgc"
103
104
105
106 ECPGdebug(1,stderr);
107
108 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
109#line 15 "code100.pgc"
110
111 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
112
113 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null )", ECPGt_EOIT, ECPGt_EORT);}
114#line 20 "code100.pgc"
115
116 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
117 { ECPGtrans(__LINE__, NULL, "commit work");}
118#line 22 "code100.pgc"
119
120 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
121
122 for (index=0;index<10;++index)
123 { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( payload , index ) values ( 0 , $1 )",
124 ECPGt_int,&(index),(long)1,(long)1,sizeof(int),
125 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
126#line 28 "code100.pgc"
127
128 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
129 }
130 { ECPGtrans(__LINE__, NULL, "commit work");}
131#line 31 "code100.pgc"
132
133 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
134
135 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update test set payload = payload + 1 where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
136#line 35 "code100.pgc"
137
138 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
139
140 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from test where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
141#line 38 "code100.pgc"
142
143 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
144
145 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( select * from test where index = - 1 )", ECPGt_EOIT, ECPGt_EORT);}
146#line 41 "code100.pgc"
147
148 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
149
150 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);}
151#line 44 "code100.pgc"
152
153 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
154 { ECPGtrans(__LINE__, NULL, "commit work");}
155#line 46 "code100.pgc"
156
157 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
158
159 { ECPGdisconnect(__LINE__, "CURRENT");}
160#line 49 "code100.pgc"
161
162 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
163 return 0;
164}
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:676
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
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:2275
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:160
#define printf(...)
Definition: port.h:245
struct sqlca_t * ECPGget_sqlca(void)
Definition: misc.c:108
#define SQLERRMC_LEN
Definition: sql-code100.c:23
#define sqlca
Definition: sql-code100.c:70
#define ECPGdebug(X, Y)
Definition: sql-code100.c:7
int main()
Definition: sql-code100.c:95
Definition: type.h:96
Definition: sqlca.h:20
struct sqlca_t::@168 sqlerrm
char sqlerrp[8]
Definition: sqlca.h:29
long sqlerrd[6]
Definition: sqlca.h:30
char sqlstate[5]
Definition: sqlca.h:53
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