6 #define POSTGRES_ECPG_INTERNAL
9 #include "catalog/pg_type_d.h"
102 sqlca->sqlerrd[2] = 1;
103 ecpg_log(
"ECPGget_desc_header: found %d attributes\n", *count);
113 *(
short *) var = (
short)
value;
116 *(
int *) var = (
int)
value;
119 *(
long *) var = (
long)
value;
122 *(
unsigned short *) var = (
unsigned short)
value;
125 *(
unsigned int *) var = (
unsigned int)
value;
128 *(
unsigned long *) var = (
unsigned long)
value;
131 *(
long long int *) var = (
long long int)
value;
134 *(
unsigned long long int *) var = (
unsigned long long int)
value;
137 *(
float *) var = (
float)
value;
140 *(
double *) var = (
double)
value;
156 *target = *(
const short *) var;
159 *target = *(
const int *) var;
162 *target = *(
const long *) var;
165 *target = *(
const unsigned short *) var;
168 *target = *(
const unsigned int *) var;
171 *target = *(
const unsigned long *) var;
174 *target = *(
const long long int *) var;
177 *target = *(
const unsigned long long int *) var;
180 *target = *(
const float *) var;
183 *target = *(
const double *) var;
201 strncpy((
char *) var,
value, varcharsize);
208 if (varcharsize == 0)
214 if (varcharsize > 0 &&
variable->len > varcharsize)
226 #define RETURN_IF_NO_DATA if (ntuples < 1) \
229 ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
269 ecpg_log(
"ECPGget_desc: reading items for tuple %d\n",
index);
274 memset(&data_var, 0,
sizeof data_var);
288 var = va_arg(
args,
void *);
289 varcharsize = va_arg(
args,
long);
290 arrsize = va_arg(
args,
long);
291 offset = va_arg(
args,
long);
310 data_var.
type = vartype;
427 if (arrsize > 0 && ntuples > arrsize)
429 ecpg_log(
"ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %ld\n",
430 lineno, ntuples, arrsize);
436 if (arrsize == 0 && *(
void **) var == NULL)
445 *(
void **) var = mem;
449 for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
456 var = (
char *) var + offset;
481 #ifdef HAVE_USELOCALE
491 stmt.oldlocale = uselocale(ecpg_clocale);
493 #ifdef HAVE__CONFIGTHREADLOCALE
494 stmt.oldthreadlocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
504 #ifdef HAVE_USELOCALE
506 uselocale(
stmt.oldlocale);
513 #ifdef HAVE__CONFIGTHREADLOCALE
514 if (
stmt.oldthreadlocale != -1)
515 (void) _configthreadlocale(
stmt.oldthreadlocale);
533 ecpg_log(
"ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %ld\n",
554 for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
565 sqlca->sqlerrd[2] = ntuples;
570 #undef RETURN_IF_NO_DATA
600 desc_item->
data = (
char *) tobeinserted;
616 for (desc_item = desc->
items; desc_item; desc_item = desc_item->
next)
622 if (desc_item == NULL)
631 desc->
items = desc_item;
642 char *tobeinserted = NULL;
712 snprintf(type_str,
sizeof(type_str),
"%d", itemtype);
732 for (desc_item = desc->
items; desc_item;)
738 desc_item = desc_item->
next;
825 strcpy(new->name,
name);
866 connection_name ? connection_name :
ecpg_gettext(
"NULL"));
890 ptr = va_arg(
args,
void *);
891 (void) va_arg(
args,
long);
892 (void) va_arg(
args,
long);
893 (void) va_arg(
args,
long);
897 (void) va_arg(
args,
void *);
898 (void) va_arg(
args,
long);
899 (void) va_arg(
args,
long);
900 (void) va_arg(
args,
long);
943 sqlda_old = sqlda_old1;
971 sqlda_old = sqlda_old1;
#define Assert(condition)
struct connection * ecpg_get_connection(const char *connection_name)
static void PGresult * res
#define ECPG_UNKNOWN_DESCRIPTOR
#define ECPG_UNKNOWN_DESCRIPTOR_ITEM
#define ECPG_INVALID_DESCRIPTOR_INDEX
#define ECPG_INVALID_STMT
#define ECPG_VAR_NOT_NUMERIC
#define ECPG_VAR_NOT_CHAR
#define ECPG_TOO_MANY_MATCHES
#define ECPG_OUT_OF_MEMORY
bool ECPGdeallocate_desc(int line, const char *name)
bool ECPGget_desc(int lineno, const char *desc_name, int index,...)
static pthread_key_t descriptor_key
static struct descriptor * get_descriptors(void)
bool ECPGallocate_desc(int line, const char *name)
static bool get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int varcharsize)
#define RETURN_IF_NO_DATA
static void set_descriptors(struct descriptor *value)
bool ECPGset_desc_header(int lineno, const char *desc_name, int count)
static void descriptor_free(struct descriptor *desc)
static void descriptor_destructor(void *arg)
static PGresult * ecpg_result_by_descriptor(int line, const char *name)
static void descriptor_key_init(void)
static bool get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
bool ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name,...)
struct descriptor * ecpg_find_desc(int line, const char *name)
bool ECPGset_desc(int lineno, const char *desc_name, int index,...)
static void descriptor_deallocate_all(struct descriptor *list)
static unsigned int ecpg_dynamic_type_DDT(Oid type)
static pthread_once_t descriptor_once
bool ECPGget_desc_header(int lineno, const char *desc_name, int *count)
static bool set_int_item(int lineno, int *target, const void *var, enum ECPGttype vartype)
static void set_desc_attr(struct descriptor_item *desc_item, struct variable *var, char *tobeinserted)
bool ecpg_store_result(const PGresult *results, int act_field, const struct statement *stmt, struct variable *var)
bool ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPAT_MODE compat)
struct sqlda_struct * ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
char * ecpg_auto_alloc(long size, int lineno)
#define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY
#define ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
struct prepared_statement * ecpg_find_prepared_statement(const char *name, struct connection *con, struct prepared_statement **prev_)
bool ecpg_store_input(const int lineno, const bool force_indicator, const struct variable *var, char **tobeinserted_p, bool quote)
void ecpg_log(const char *format,...) pg_attribute_printf(1
char * ecpg_alloc(long size, int lineno)
#define ECPG_SQLSTATE_CARDINALITY_VIOLATION
#define ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME
#define ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX
char * ecpg_strdup(const char *string, int lineno)
void ecpg_init_sqlca(struct sqlca_t *sqlca)
int ecpg_dynamic_type(Oid type)
#define ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST
void ecpg_raise(int line, int code, const char *sqlstate, const char *str)
struct sqlda_compat * ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
void ecpg_free(void *ptr)
#define ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME
@ ECPGt_unsigned_long_long
int PQgetlength(const PGresult *res, int tup_num, int field_num)
Oid PQftype(const PGresult *res, int field_num)
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
int PQntuples(const PGresult *res)
char * PQfname(const PGresult *res, int field_num)
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
int PQfmod(const PGresult *res, int field_num)
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
int PQnfields(const PGresult *res)
int PQfsize(const PGresult *res, int field_num)
struct sqlca_t * ECPGget_sqlca(void)
void * pthread_getspecific(pthread_key_t key)
void pthread_setspecific(pthread_key_t key, void *val)
@ SQL3_DDT_TIME_WITH_TIME_ZONE
@ SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE
struct descriptor_item * next
struct descriptor_item * items
struct sqlda_compat * desc_next
struct sqlda_struct * desc_next