]> granicus.if.org Git - postgresql/blob - src/interfaces/ecpg/test/expected/sql-quote.c
More variables gcc moans about
[postgresql] / src / interfaces / ecpg / test / expected / sql-quote.c
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
25 int 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 ;
35 /* exec sql end declare section */
36 #line 11 "quote.pgc"
37
38
39   ECPGdebug(1, stderr);
40   { ECPGconnect(__LINE__, 0, "regress1" , 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  sqlprint ; */
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
57 if (sqlca.sqlwarn[0] == 'W') sqlprint();
58 #line 20 "quote.pgc"
59
60 if (sqlca.sqlcode < 0) sqlprint();}
61 #line 20 "quote.pgc"
62
63
64   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, 
65         ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
66         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
67 #line 22 "quote.pgc"
68
69 if (sqlca.sqlwarn[0] == 'W') sqlprint();
70 #line 22 "quote.pgc"
71
72 if (sqlca.sqlcode < 0) sqlprint();}
73 #line 22 "quote.pgc"
74
75   printf("Standard conforming strings: %s\n", var);
76
77   /* this is a\\b actually */
78   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
79 #line 26 "quote.pgc"
80
81 if (sqlca.sqlwarn[0] == 'W') sqlprint();
82 #line 26 "quote.pgc"
83
84 if (sqlca.sqlcode < 0) sqlprint();}
85 #line 26 "quote.pgc"
86
87   /* this is a\\b */
88   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
89 #line 28 "quote.pgc"
90
91 if (sqlca.sqlwarn[0] == 'W') sqlprint();
92 #line 28 "quote.pgc"
93
94 if (sqlca.sqlcode < 0) sqlprint();}
95 #line 28 "quote.pgc"
96
97
98   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
99 #line 30 "quote.pgc"
100
101 if (sqlca.sqlwarn[0] == 'W') sqlprint();
102 #line 30 "quote.pgc"
103
104 if (sqlca.sqlcode < 0) sqlprint();}
105 #line 30 "quote.pgc"
106
107
108   /* this is a\\\\b actually */
109   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
110 #line 33 "quote.pgc"
111
112 if (sqlca.sqlwarn[0] == 'W') sqlprint();
113 #line 33 "quote.pgc"
114
115 if (sqlca.sqlcode < 0) sqlprint();}
116 #line 33 "quote.pgc"
117
118   /* this is a\\b */
119   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
120 #line 35 "quote.pgc"
121
122 if (sqlca.sqlwarn[0] == 'W') sqlprint();
123 #line 35 "quote.pgc"
124
125 if (sqlca.sqlcode < 0) sqlprint();}
126 #line 35 "quote.pgc"
127
128
129   { ECPGtrans(__LINE__, NULL, "begin");
130 #line 37 "quote.pgc"
131
132 if (sqlca.sqlwarn[0] == 'W') sqlprint();
133 #line 37 "quote.pgc"
134
135 if (sqlca.sqlcode < 0) sqlprint();}
136 #line 37 "quote.pgc"
137
138   /* declare C cursor for select * from \"My_Table\" */
139 #line 38 "quote.pgc"
140
141
142   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
143 #line 40 "quote.pgc"
144
145 if (sqlca.sqlwarn[0] == 'W') sqlprint();
146 #line 40 "quote.pgc"
147
148 if (sqlca.sqlcode < 0) sqlprint();}
149 #line 40 "quote.pgc"
150
151
152   /* exec sql whenever not found  break ; */
153 #line 42 "quote.pgc"
154
155
156   while (true)
157   {
158         { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, 
159         ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
160         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
161         ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
162         ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
163 #line 46 "quote.pgc"
164
165 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
166 #line 46 "quote.pgc"
167
168 if (sqlca.sqlwarn[0] == 'W') sqlprint();
169 #line 46 "quote.pgc"
170
171 if (sqlca.sqlcode < 0) sqlprint();}
172 #line 46 "quote.pgc"
173
174         printf("value: %d %s\n", i, var);
175   }
176
177   { ECPGtrans(__LINE__, NULL, "rollback");
178 #line 50 "quote.pgc"
179
180 if (sqlca.sqlwarn[0] == 'W') sqlprint();
181 #line 50 "quote.pgc"
182
183 if (sqlca.sqlcode < 0) sqlprint();}
184 #line 50 "quote.pgc"
185
186   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
187 #line 51 "quote.pgc"
188
189 if (sqlca.sqlwarn[0] == 'W') sqlprint();
190 #line 51 "quote.pgc"
191
192 if (sqlca.sqlcode < 0) sqlprint();}
193 #line 51 "quote.pgc"
194
195
196   { ECPGdisconnect(__LINE__, "ALL");
197 #line 53 "quote.pgc"
198
199 if (sqlca.sqlwarn[0] == 'W') sqlprint();
200 #line 53 "quote.pgc"
201
202 if (sqlca.sqlcode < 0) sqlprint();}
203 #line 53 "quote.pgc"
204
205
206   return 0;
207 }