3 #ifndef _ECPG_LIB_EXTERN_H
4 #define _ECPG_LIB_EXTERN_H
6 #include "postgres_fe.h"
9 #include "ecpg_config.h"
16 ECPG_COMPAT_PGSQL
= 0, ECPG_COMPAT_INFORMIX
, ECPG_COMPAT_INFORMIX_SE
19 extern bool ecpg_internal_regression_mode
;
21 #define INFORMIX_MODE(X) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
25 ECPG_ARRAY_ERROR
, ECPG_ARRAY_NOT_SET
, ECPG_ARRAY_ARRAY
, ECPG_ARRAY_VECTOR
, ECPG_ARRAY_NONE
28 /* A generic varchar type. */
29 struct ECPGgeneric_varchar
36 * type information cache
39 struct ECPGtype_information_cache
41 struct ECPGtype_information_cache
*next
;
46 /* structure to store one statement */
52 struct connection
*connection
;
53 enum COMPAT_MODE compat
;
55 enum ECPG_statement_type statement_type
;
57 struct variable
*inlist
;
58 struct variable
*outlist
;
61 /* structure to store connections */
68 struct ECPGtype_information_cache
*cache_head
;
69 struct prepared_statement
*prep_stmts
;
70 struct connection
*next
;
73 /* structure to store descriptors */
78 struct descriptor
*next
;
80 struct descriptor_item
*items
;
83 struct descriptor_item
92 struct descriptor_item
*next
;
103 enum ECPGttype ind_type
;
106 long ind_varcharsize
;
109 struct variable
*next
;
112 /* Here are some methods used by the lib. */
114 /* Returns a pointer to a string containing a simple type name. */
115 void ecpg_add_mem(void *ptr
, int lineno
);
117 bool ecpg_get_data(const PGresult
*, int, int, int, enum ECPGttype type
,
118 enum ECPGttype
, char *, char *, long, long, long,
119 enum ARRAY_TYPE
, enum COMPAT_MODE
, bool);
121 #ifdef ENABLE_THREAD_SAFETY
122 void ecpg_pthreads_init(void);
124 struct connection
*ecpg_get_connection(const char *);
125 char *ecpg_alloc(long, int);
126 char *ecpg_realloc(void *, long, int);
127 void ecpg_free(void *);
128 bool ecpg_init(const struct connection
*, const char *, const int);
129 char *ecpg_strdup(const char *, int);
130 const char *ecpg_type_name(enum ECPGttype
);
131 int ecpg_dynamic_type(Oid
);
132 void ecpg_free_auto_mem(void);
133 void ecpg_clear_auto_mem(void);
135 struct descriptor
*ecpggetdescp(int, char *);
137 struct descriptor
*ecpg_find_desc(int line
, const char *name
);
139 bool ecpg_store_result(const PGresult
*results
, int act_field
,
140 const struct statement
* stmt
, struct variable
* var
);
141 bool ecpg_store_input(const int, const bool, const struct variable
*, char **, bool);
143 bool ecpg_check_PQresult(PGresult
*, int, PGconn
*, enum COMPAT_MODE
);
144 void ecpg_raise(int line
, int code
, const char *sqlstate
, const char *str
);
145 void ecpg_raise_backend(int line
, PGresult
*result
, PGconn
*conn
, int compat
);
146 char *ecpg_prepared(const char *, struct connection
*, int);
147 bool ecpg_deallocate_all_conn(int lineno
, enum COMPAT_MODE c
, struct connection
* conn
);
148 void ecpg_log(const char *format
,...);
149 bool ecpg_auto_prepare(int, const char *, int, const int, char **, const char *);
150 void ecpg_init_sqlca(struct sqlca_t
* sqlca
);
152 /* SQLSTATE values generated or processed by ecpglib (intentionally
153 * not exported -- users should refer to the codes directly) */
155 #define ECPG_SQLSTATE_NO_DATA "02000"
156 #define ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS "07001"
157 #define ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_TARGETS "07002"
158 #define ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION "07006"
159 #define ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX "07009"
160 #define ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION "08001"
161 #define ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST "08003"
162 #define ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN "08007"
163 #define ECPG_SQLSTATE_CARDINALITY_VIOLATION "21000"
164 #define ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER "22002"
165 #define ECPG_SQLSTATE_ACTIVE_SQL_TRANSACTION "25001"
166 #define ECPG_SQLSTATE_NO_ACTIVE_SQL_TRANSACTION "25P01"
167 #define ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME "26000"
168 #define ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME "33000"
169 #define ECPG_SQLSTATE_INVALID_CURSOR_NAME "34000"
170 #define ECPG_SQLSTATE_SYNTAX_ERROR "42601"
171 #define ECPG_SQLSTATE_DATATYPE_MISMATCH "42804"
172 #define ECPG_SQLSTATE_DUPLICATE_CURSOR "42P03"
174 /* implementation-defined internal errors of ecpg */
175 #define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR "YE000"
176 #define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY "YE001"
178 #endif /* _ECPG_LIB_EXTERN_H */