PostgreSQL Source Code git master
Loading...
Searching...
No Matches
sql-quote.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 "quote.pgc"
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13
14
15#line 1 "regression.h"
16
17
18
19
20
21
22#line 5 "quote.pgc"
23
24
25int main() {
26 /* exec sql begin declare section */
27
28
29
30#line 9 "quote.pgc"
31 char var [ 25 ] ;
32
33#line 10 "quote.pgc"
34 int i , loopcount ;
35/* exec sql end declare section */
36#line 11 "quote.pgc"
37
38
39 ECPGdebug(1, stderr);
40 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
41#line 14 "quote.pgc"
42
43
44 { ECPGsetcommit(__LINE__, "on", NULL);}
45#line 16 "quote.pgc"
46
47 /* exec sql whenever sql_warning sqlprint ; */
48#line 17 "quote.pgc"
49
50 /* exec sql whenever sqlerror stop ; */
51#line 18 "quote.pgc"
52
53
54 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table \"My_Table\" ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT);
55#line 20 "quote.pgc"
56
57if (sqlca.sqlwarn[0] == 'W') sqlprint();
58#line 20 "quote.pgc"
59
60if (sqlca.sqlcode < 0) exit (1);}
61#line 20 "quote.pgc"
62
63
64 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
65#line 22 "quote.pgc"
66
67if (sqlca.sqlwarn[0] == 'W') sqlprint();
68#line 22 "quote.pgc"
69
70if (sqlca.sqlcode < 0) exit (1);}
71#line 22 "quote.pgc"
72
73
74 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
75 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
77#line 24 "quote.pgc"
78
79if (sqlca.sqlwarn[0] == 'W') sqlprint();
80#line 24 "quote.pgc"
81
82if (sqlca.sqlcode < 0) exit (1);}
83#line 24 "quote.pgc"
84
85 printf("Standard conforming strings: %s\n", var);
86
87 /* this is a\\\\b actually */
88 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
89#line 28 "quote.pgc"
90
91if (sqlca.sqlwarn[0] == 'W') sqlprint();
92#line 28 "quote.pgc"
93
94if (sqlca.sqlcode < 0) exit (1);}
95#line 28 "quote.pgc"
96
97 /* this is a\\b */
98 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
99#line 30 "quote.pgc"
100
101if (sqlca.sqlwarn[0] == 'W') sqlprint();
102#line 30 "quote.pgc"
103
104if (sqlca.sqlcode < 0) exit (1);}
105#line 30 "quote.pgc"
106
107
108 { ECPGtrans(__LINE__, NULL, "begin");
109#line 32 "quote.pgc"
110
111if (sqlca.sqlwarn[0] == 'W') sqlprint();
112#line 32 "quote.pgc"
113
114if (sqlca.sqlcode < 0) exit (1);}
115#line 32 "quote.pgc"
116
117 /* declare C cursor for select * from \"My_Table\" */
118#line 33 "quote.pgc"
119
120
121 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
122#line 35 "quote.pgc"
123
124if (sqlca.sqlwarn[0] == 'W') sqlprint();
125#line 35 "quote.pgc"
126
127if (sqlca.sqlcode < 0) exit (1);}
128#line 35 "quote.pgc"
129
130
131 /* exec sql whenever not found break ; */
132#line 37 "quote.pgc"
133
134
135 for (loopcount = 0; loopcount < 100; loopcount++)
136 {
137 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT,
138 ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
139 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
140 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
142#line 41 "quote.pgc"
143
144if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
145#line 41 "quote.pgc"
146
147if (sqlca.sqlwarn[0] == 'W') sqlprint();
148#line 41 "quote.pgc"
149
150if (sqlca.sqlcode < 0) exit (1);}
151#line 41 "quote.pgc"
152
153 printf("value: %d %s\n", i, var);
154 }
155
156 { ECPGtrans(__LINE__, NULL, "rollback");
157#line 45 "quote.pgc"
158
159if (sqlca.sqlwarn[0] == 'W') sqlprint();
160#line 45 "quote.pgc"
161
162if (sqlca.sqlcode < 0) exit (1);}
163#line 45 "quote.pgc"
164
165 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
166#line 46 "quote.pgc"
167
168if (sqlca.sqlwarn[0] == 'W') sqlprint();
169#line 46 "quote.pgc"
170
171if (sqlca.sqlcode < 0) exit (1);}
172#line 46 "quote.pgc"
173
174
175 { ECPGdisconnect(__LINE__, "ALL");
176#line 48 "quote.pgc"
177
178if (sqlca.sqlwarn[0] == 'W') sqlprint();
179#line 48 "quote.pgc"
180
181if (sqlca.sqlcode < 0) exit (1);}
182#line 48 "quote.pgc"
183
184
185 return 0;
186}
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
Definition connect.c:158
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition connect.c:693
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition connect.c:260
#define ECPG_NOT_FOUND
Definition ecpgerrno.h:10
@ 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:2291
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition misc.c:160
int i
Definition isn.c:77
#define printf(...)
Definition port.h:266
static int fb(int x)
#define ECPGdebug(X, Y)
Definition sql-quote.c:7
int main()
Definition sql-quote.c:25
#define sqlca
Definition sqlca.h:59