PostgreSQL Source Code git master
Loading...
Searching...
No Matches
sql-sqljson_jsontable.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
Include dependency graph for sql-sqljson_jsontable.c:

Go to the source code of this file.

Data Structures

struct  sqlca_t
 

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 
#define POSTGRES_SQLCA_H
 
#define PGDLLIMPORT
 
#define SQLERRMC_LEN   150
 
#define sqlca   (*ECPGget_sqlca())
 

Functions

struct sqlca_tECPGget_sqlca (void)
 
int main ()
 

Macro Definition Documentation

◆ ECPGdebug

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

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

◆ PGDLLIMPORT

#define PGDLLIMPORT

Definition at line 21 of file sql-sqljson_jsontable.c.

◆ POSTGRES_SQLCA_H

#define POSTGRES_SQLCA_H

Definition at line 15 of file sql-sqljson_jsontable.c.

◆ sqlca

#define sqlca   (*ECPGget_sqlca())

Definition at line 72 of file sql-sqljson_jsontable.c.

◆ SQLERRMC_LEN

#define SQLERRMC_LEN   150

Definition at line 25 of file sql-sqljson_jsontable.c.

Function Documentation

◆ ECPGget_sqlca()

struct sqlca_t * ECPGget_sqlca ( void  )

Definition at line 108 of file misc.c.

109{
110 struct sqlca_t *sqlca;
111
113
115 if (sqlca == NULL)
116 {
117 sqlca = malloc(sizeof(struct sqlca_t));
118 if (sqlca == NULL)
119 return NULL;
122 }
123 return sqlca;
124}
static pthread_key_t sqlca_key
Definition misc.c:58
void ecpg_init_sqlca(struct sqlca_t *sqlca)
Definition misc.c:67
static void ecpg_sqlca_key_init(void)
Definition misc.c:102
static pthread_once_t sqlca_key_once
Definition misc.c:59
static int fb(int x)
void pthread_setspecific(pthread_key_t key, void *val)
void * pthread_getspecific(pthread_key_t key)
#define malloc(a)
#define sqlca
Definition sqlca.h:59

◆ main()

int main ( void  )

Definition at line 99 of file sql-sqljson_jsontable.c.

100{
101/* exec sql begin declare section */
102
103
104#line 12 "sqljson_jsontable.pgc"
105 int foo ;
106/* exec sql end declare section */
107#line 13 "sqljson_jsontable.pgc"
108
109
110 ECPGdebug (1, stderr);
111
112 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
113#line 17 "sqljson_jsontable.pgc"
114
115if (sqlca.sqlcode < 0) sqlprint();}
116#line 17 "sqljson_jsontable.pgc"
117
118 { ECPGsetcommit(__LINE__, "on", NULL);
119#line 18 "sqljson_jsontable.pgc"
120
121if (sqlca.sqlcode < 0) sqlprint();}
122#line 18 "sqljson_jsontable.pgc"
123
124
125 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select foo from json_table ( jsonb '[{\"foo\":1}]' , '$[*]' as p0 columns ( foo int ) ) jt ( foo )", ECPGt_EOIT,
126 ECPGt_int,&(foo),(long)1,(long)1,sizeof(int),
128#line 23 "sqljson_jsontable.pgc"
129
130if (sqlca.sqlcode < 0) sqlprint();}
131#line 23 "sqljson_jsontable.pgc"
132
133 printf("Found foo=%d\n", foo);
134
135 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select foo from json_table ( jsonb '[{\"foo\":\"1\"}]' , '$[*]' as p0 columns ( nested '$' as p1 columns ( nested path '$' as p11 columns ( foo int ) ) ) ) jt ( foo )", ECPGt_EOIT,
136 ECPGt_int,&(foo),(long)1,(long)1,sizeof(int),
138#line 31 "sqljson_jsontable.pgc"
139
140if (sqlca.sqlcode < 0) sqlprint();}
141#line 31 "sqljson_jsontable.pgc"
142
143 printf("Found foo=%d\n", foo);
144
145 { ECPGdisconnect(__LINE__, "CURRENT");
146#line 34 "sqljson_jsontable.pgc"
147
148if (sqlca.sqlcode < 0) sqlprint();}
149#line 34 "sqljson_jsontable.pgc"
150
151
152 return 0;
153}
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
@ 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
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
#define printf(...)
Definition port.h:266
#define sqlca
#define ECPGdebug(X, Y)

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