]> granicus.if.org Git - postgresql/blob - src/interfaces/ecpg/test/expected/sql-parser.c
59ba10a739448737240ba501538e12dd55766c95
[postgresql] / src / interfaces / ecpg / test / expected / sql-parser.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 "parser.pgc"
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 /* test parser addition that merges two tokens into one */
15
16 #line 1 "regression.h"
17
18
19
20
21
22
23 #line 6 "parser.pgc"
24
25
26 int main(int argc, char* argv[]) {
27   /* exec sql begin declare section */
28            
29   
30 #line 10 "parser.pgc"
31  int item [ 3 ] , ind [ 3 ] , i ;
32 /* exec sql end declare section */
33 #line 11 "parser.pgc"
34
35
36   ECPGdebug(1, stderr);
37   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
38 #line 14 "parser.pgc"
39
40
41   { ECPGsetcommit(__LINE__, "on", NULL);}
42 #line 16 "parser.pgc"
43
44   /* exec sql whenever sql_warning  sqlprint ; */
45 #line 17 "parser.pgc"
46
47   /* exec sql whenever sqlerror  sqlprint ; */
48 #line 18 "parser.pgc"
49
50
51   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
52 #line 20 "parser.pgc"
53
54 if (sqlca.sqlwarn[0] == 'W') sqlprint();
55 #line 20 "parser.pgc"
56
57 if (sqlca.sqlcode < 0) sqlprint();}
58 #line 20 "parser.pgc"
59
60
61   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
62 #line 22 "parser.pgc"
63
64 if (sqlca.sqlwarn[0] == 'W') sqlprint();
65 #line 22 "parser.pgc"
66
67 if (sqlca.sqlcode < 0) sqlprint();}
68 #line 22 "parser.pgc"
69
70   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
71 #line 23 "parser.pgc"
72
73 if (sqlca.sqlwarn[0] == 'W') sqlprint();
74 #line 23 "parser.pgc"
75
76 if (sqlca.sqlcode < 0) sqlprint();}
77 #line 23 "parser.pgc"
78
79   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 2 )", ECPGt_EOIT, ECPGt_EORT);
80 #line 24 "parser.pgc"
81
82 if (sqlca.sqlwarn[0] == 'W') sqlprint();
83 #line 24 "parser.pgc"
84
85 if (sqlca.sqlcode < 0) sqlprint();}
86 #line 24 "parser.pgc"
87
88
89   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
90         ECPGt_int,(item),(long)1,(long)3,sizeof(int), 
91         ECPGt_int,(ind),(long)1,(long)3,sizeof(int), ECPGt_EORT);
92 #line 26 "parser.pgc"
93
94 if (sqlca.sqlwarn[0] == 'W') sqlprint();
95 #line 26 "parser.pgc"
96
97 if (sqlca.sqlcode < 0) sqlprint();}
98 #line 26 "parser.pgc"
99
100
101   for (i=0; i<3; i++)
102         printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
103
104   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter Item1 type bigint", ECPGt_EOIT, ECPGt_EORT);
105 #line 31 "parser.pgc"
106
107 if (sqlca.sqlwarn[0] == 'W') sqlprint();
108 #line 31 "parser.pgc"
109
110 if (sqlca.sqlcode < 0) sqlprint();}
111 #line 31 "parser.pgc"
112
113   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter column Item2 set data type smallint", ECPGt_EOIT, ECPGt_EORT);
114 #line 32 "parser.pgc"
115
116 if (sqlca.sqlwarn[0] == 'W') sqlprint();
117 #line 32 "parser.pgc"
118
119 if (sqlca.sqlcode < 0) sqlprint();}
120 #line 32 "parser.pgc"
121
122
123   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
124 #line 34 "parser.pgc"
125
126 if (sqlca.sqlwarn[0] == 'W') sqlprint();
127 #line 34 "parser.pgc"
128
129 if (sqlca.sqlcode < 0) sqlprint();}
130 #line 34 "parser.pgc"
131
132
133   { ECPGdisconnect(__LINE__, "ALL");
134 #line 36 "parser.pgc"
135
136 if (sqlca.sqlwarn[0] == 'W') sqlprint();
137 #line 36 "parser.pgc"
138
139 if (sqlca.sqlcode < 0) sqlprint();}
140 #line 36 "parser.pgc"
141
142
143   return 0;
144 }