PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
sql-copystdout.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
Include dependency graph for sql-copystdout.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

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

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

Referenced by main().

#define PGDLLIMPORT

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

#define POSTGRES_SQLCA_H

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

#define sqlca   (*ECPGget_sqlca())

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

Referenced by main().

#define SQLERRMC_LEN   150

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

Function Documentation

struct sqlca_t* ECPGget_sqlca ( void  )

Definition at line 142 of file misc.c.

143 {
144 #ifdef ENABLE_THREAD_SAFETY
145  struct sqlca_t *sqlca;
146 
147  pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);
148 
149  sqlca = pthread_getspecific(sqlca_key);
150  if (sqlca == NULL)
151  {
152  sqlca = malloc(sizeof(struct sqlca_t));
153  if (sqlca == NULL)
154  return NULL;
155  ecpg_init_sqlca(sqlca);
156  pthread_setspecific(sqlca_key, sqlca);
157  }
158  return sqlca;
159 #else
160  return &sqlca;
161 #endif
162 }
void ecpg_init_sqlca(struct sqlca_t *sqlca)
Definition: misc.c:99
#define malloc(a)
Definition: header.h:50
Definition: sqlca.h:19
void * pthread_getspecific(pthread_key_t key)
Definition: pthread-win32.c:29
static struct sqlca_t sqlca
Definition: misc.c:63
void pthread_setspecific(pthread_key_t key, void *val)
Definition: pthread-win32.c:24
int main ( void  )

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

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, sqlca, and sqlprint().

100 {
101  ECPGdebug (1, stderr);
102 
103  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
104 #line 13 "copystdout.pgc"
105 
106 if (sqlca.sqlcode < 0) sqlprint();}
107 #line 13 "copystdout.pgc"
108 
109  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table foo ( a int , b varchar )", ECPGt_EOIT, ECPGt_EORT);
110 #line 14 "copystdout.pgc"
111 
112 if (sqlca.sqlcode < 0) sqlprint();}
113 #line 14 "copystdout.pgc"
114 
115  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 5 , 'abc' )", ECPGt_EOIT, ECPGt_EORT);
116 #line 15 "copystdout.pgc"
117 
118 if (sqlca.sqlcode < 0) sqlprint();}
119 #line 15 "copystdout.pgc"
120 
121  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 6 , 'def' )", ECPGt_EOIT, ECPGt_EORT);
122 #line 16 "copystdout.pgc"
123 
124 if (sqlca.sqlcode < 0) sqlprint();}
125 #line 16 "copystdout.pgc"
126 
127  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 7 , 'ghi' )", ECPGt_EOIT, ECPGt_EORT);
128 #line 17 "copystdout.pgc"
129 
130 if (sqlca.sqlcode < 0) sqlprint();}
131 #line 17 "copystdout.pgc"
132 
133 
134  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT);
135 #line 19 "copystdout.pgc"
136 
137 if (sqlca.sqlcode < 0) sqlprint();}
138 #line 19 "copystdout.pgc"
139 
140  printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
141 
142  { ECPGdisconnect(__LINE__, "CURRENT");
143 #line 22 "copystdout.pgc"
144 
145 if (sqlca.sqlcode < 0) sqlprint();}
146 #line 22 "copystdout.pgc"
147 
148 
149  return 0;
150 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
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:2030
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
#define sqlca
void sqlprint(void)
Definition: error.c:336
#define ECPGdebug(X, Y)
Definition: sql-copystdout.c:7