PostgreSQL Source Code  git master
ecpglib.h
Go to the documentation of this file.
1 /*
2  * Client-visible declarations for ecpglib
3  *
4  * src/interfaces/ecpg/include/ecpglib.h
5  */
6 
7 #ifndef _ECPGLIB_H
8 #define _ECPGLIB_H
9 
10 #include <string.h>
11 
12 #include "ecpg_config.h"
13 #include "ecpgtype.h"
14 #include "libpq-fe.h"
15 #include "sqlca.h"
16 
17 /*
18  * This is a small extract from c.h since we don't want to leak all postgres
19  * definitions into ecpg programs; but we need to know what bool is.
20  */
21 #ifndef __cplusplus
22 
23 #ifdef PG_USE_STDBOOL
24 #include <stdbool.h>
25 #else
26 
27 /*
28  * We assume bool has been defined if true and false are. This avoids
29  * duplicate-typedef errors if this file is included after c.h.
30  */
31 #if !(defined(true) && defined(false))
32 typedef unsigned char bool;
33 #endif
34 
35 #ifndef true
36 #define true ((bool) 1)
37 #endif
38 
39 #ifndef false
40 #define false ((bool) 0)
41 #endif
42 
43 #endif /* not PG_USE_STDBOOL */
44 #endif /* not C++ */
45 
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52 void ECPGdebug(int n, FILE *dbgs);
53 bool ECPGstatus(int lineno, const char *connection_name);
54 bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name);
55 bool ECPGsetconn(int lineno, const char *connection_name);
56 bool ECPGconnect(int lineno, int c, const char *name, const char *user,
57  const char *passwd, const char *connection_name, int autocommit);
58 bool ECPGdo(const int lineno, const int compat, const int force_indicator,
59  const char *connection_name, const bool questionmarks,
60  const int st, const char *query,...);
61 bool ECPGtrans(int lineno, const char *connection_name, const char *transaction);
62 bool ECPGdisconnect(int lineno, const char *connection_name);
63 bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks,
64  const char *name, const char *variable);
65 bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name);
66 bool ECPGdeallocate_all(int lineno, int compat, const char *connection_name);
67 char *ECPGprepared_statement(const char *connection_name, const char *name, int lineno);
68 PGconn *ECPGget_PGconn(const char *connection_name);
69 PGTransactionStatusType ECPGtransactionStatus(const char *connection_name);
70 
71  /* print an error message */
72 void sqlprint(void);
73 
74 /* define this for simplicity as well as compatibility */
75 
76 #define SQLCODE sqlca.sqlcode
77 #define SQLSTATE sqlca.sqlstate
78 
79 /* dynamic SQL */
80 
81 bool ECPGdo_descriptor(int line, const char *connection,
82  const char *descriptor, const char *query);
83 bool ECPGdeallocate_desc(int line, const char *name);
84 bool ECPGallocate_desc(int line, const char *name);
85 bool ECPGget_desc_header(int lineno, const char *desc_name, int *count);
86 bool ECPGget_desc(int lineno, const char *desc_name, int index,...);
87 bool ECPGset_desc_header(int lineno, const char *desc_name, int count);
88 bool ECPGset_desc(int lineno, const char *desc_name, int index,...);
89 
90 void ECPGset_noind_null(enum ECPGttype type, void *ptr);
91 bool ECPGis_noind_null(enum ECPGttype type, const void *ptr);
92 bool ECPGdescribe(int line, int compat, bool input,
93  const char *connection_name, const char *stmt_name,...);
94 
95 void ECPGset_var(int number, void *pointer, int lineno);
96 void *ECPGget_var(int number);
97 
98 /* dynamic result allocation */
99 void ECPGfree_auto_mem(void);
100 
101 #ifdef ENABLE_THREAD_SAFETY
102 void ecpg_pthreads_init(void);
103 #endif
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _ECPGLIB_H */
bool autocommit
Definition: ecpg.c:15
enum COMPAT_MODE compat
Definition: ecpg.c:25
bool force_indicator
Definition: ecpg.c:18
bool questionmarks
Definition: ecpg.c:19
void ECPGset_var(int number, void *pointer, int lineno)
Definition: misc.c:532
void sqlprint(void)
Definition: error.c:334
PGTransactionStatusType ECPGtransactionStatus(const char *connection_name)
Definition: misc.c:182
bool ECPGdeallocate_desc(int line, const char *name)
Definition: descriptor.c:755
bool ECPGdeallocate_all(int lineno, int compat, const char *connection_name)
Definition: prepare.c:350
bool ECPGget_desc(int lineno, const char *desc_name, int index,...)
Definition: descriptor.c:241
void ECPGdebug(int n, FILE *dbgs)
Definition: misc.c:241
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
Definition: misc.c:318
bool ECPGsetconn(int lineno, const char *connection_name)
Definition: connect.c:208
void ECPGfree_auto_mem(void)
Definition: memory.c:138
PGconn * ECPGget_PGconn(const char *connection_name)
Definition: connect.c:757
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:197
bool ECPGallocate_desc(int line, const char *name)
Definition: descriptor.c:802
bool ECPGis_noind_null(enum ECPGttype type, const void *ptr)
Definition: misc.c:387
void * ECPGget_var(int number)
Definition: misc.c:587
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
Definition: connect.c:171
bool ECPGstatus(int lineno, const char *connection_name)
Definition: misc.c:164
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
Definition: prepare.c:217
bool ECPGset_desc_header(int lineno, const char *desc_name, int count)
Definition: descriptor.c:580
unsigned char bool
Definition: ecpglib.h:32
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:707
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
Definition: prepare.c:368
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:277
bool ECPGdo_descriptor(int line, const char *connection, const char *descriptor, const char *query)
Definition: execute.c:2294
bool ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name,...)
Definition: descriptor.c:857
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
Definition: prepare.c:315
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:2279
bool ECPGset_desc(int lineno, const char *desc_name, int index,...)
Definition: descriptor.c:612
bool ECPGget_desc_header(int lineno, const char *desc_name, int *count)
Definition: descriptor.c:91
ECPGttype
Definition: ecpgtype.h:42
const char * name
Definition: encode.c:561
PGTransactionStatusType
Definition: libpq-fe.h:117
static PgChecksumMode mode
Definition: pg_checksums.c:65
static char * user
Definition: pg_regress.c:93
char * c
Definition: type.h:95