PostgreSQL Source Code git master
sql-parser.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for sql-parser.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Functions

int main ()
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file sql-parser.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 26 of file sql-parser.c.

26 {
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, "ecpg1_regression" , 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
54if (sqlca.sqlwarn[0] == 'W') sqlprint();
55#line 20 "parser.pgc"
56
57if (sqlca.sqlcode < 0) sqlprint();}
58#line 20 "parser.pgc"
59
60
61 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t select 1 , nullif ( y - 1 , 0 ) from generate_series ( 1 , 3 ) with ordinality as series ( x , y )", ECPGt_EOIT, ECPGt_EORT);
62#line 24 "parser.pgc"
63
64if (sqlca.sqlwarn[0] == 'W') sqlprint();
65#line 24 "parser.pgc"
66
67if (sqlca.sqlcode < 0) sqlprint();}
68#line 24 "parser.pgc"
69
70
71 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT,
72 ECPGt_int,(item),(long)1,(long)3,sizeof(int),
73 ECPGt_int,(ind),(long)1,(long)3,sizeof(int), ECPGt_EORT);
74#line 26 "parser.pgc"
75
76if (sqlca.sqlwarn[0] == 'W') sqlprint();
77#line 26 "parser.pgc"
78
79if (sqlca.sqlcode < 0) sqlprint();}
80#line 26 "parser.pgc"
81
82
83 for (i=0; i<3; i++)
84 printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
85
86 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter Item1 type bigint", ECPGt_EOIT, ECPGt_EORT);
87#line 31 "parser.pgc"
88
89if (sqlca.sqlwarn[0] == 'W') sqlprint();
90#line 31 "parser.pgc"
91
92if (sqlca.sqlcode < 0) sqlprint();}
93#line 31 "parser.pgc"
94
95 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter column Item2 set data type smallint", ECPGt_EOIT, ECPGt_EORT);
96#line 32 "parser.pgc"
97
98if (sqlca.sqlwarn[0] == 'W') sqlprint();
99#line 32 "parser.pgc"
100
101if (sqlca.sqlcode < 0) sqlprint();}
102#line 32 "parser.pgc"
103
104
105 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
106#line 34 "parser.pgc"
107
108if (sqlca.sqlwarn[0] == 'W') sqlprint();
109#line 34 "parser.pgc"
110
111if (sqlca.sqlcode < 0) sqlprint();}
112#line 34 "parser.pgc"
113
114
115 { ECPGdisconnect(__LINE__, "ALL");
116#line 36 "parser.pgc"
117
118if (sqlca.sqlwarn[0] == 'W') sqlprint();
119#line 36 "parser.pgc"
120
121if (sqlca.sqlcode < 0) sqlprint();}
122#line 36 "parser.pgc"
123
124
125 return 0;
126}
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
Definition: connect.c:153
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_EORT
Definition: ecpgtype.h:63
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:2275
int i
Definition: isn.c:72
#define printf(...)
Definition: port.h:245
#define ECPGdebug(X, Y)
Definition: sql-parser.c:7
#define sqlca
Definition: sqlca.h:59

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGsetcommit(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, i, printf, sqlca, and sqlprint().