PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <math.h>
#include "catalog/pg_type_d.h"
#include "ecpgerrno.h"
#include "ecpglib.h"
#include "ecpglib_extern.h"
#include "ecpgtype.h"
#include "pgtypes_date.h"
#include "pgtypes_interval.h"
#include "pgtypes_numeric.h"
#include "pgtypes_timestamp.h"
#include "sql3types.h"
#include "sqlca.h"
#include "sqlda-compat.h"
#include "sqlda-native.h"
Go to the source code of this file.
Macros | |
#define | POSTGRES_ECPG_INTERNAL |
#define | not_an_array_in_ecpg ECPG_ARRAY_NONE |
Functions | |
static char * | quote_postgres (char *arg, bool quote, int lineno) |
static void | free_variable (struct variable *var) |
static void | free_statement (struct statement *stmt) |
static int | next_insert (char *text, int pos, bool questionmarks, bool std_strings) |
static bool | ecpg_type_infocache_push (struct ECPGtype_information_cache **cache, int oid, enum ARRAY_TYPE isarray, int lineno) |
static enum ARRAY_TYPE | ecpg_is_type_an_array (int type, const struct statement *stmt, const struct variable *var) |
bool | ecpg_store_result (const PGresult *results, int act_field, const struct statement *stmt, struct variable *var) |
static void | sprintf_double_value (char *ptr, double value, const char *delim) |
static void | sprintf_float_value (char *ptr, float value, const char *delim) |
static char * | convert_bytea_to_string (char *from_data, int from_len, int lineno) |
bool | ecpg_store_input (const int lineno, const bool force_indicator, const struct variable *var, char **tobeinserted_p, bool quote) |
static void | print_param_value (char *value, int len, int is_binary, int lineno, int nth) |
void | ecpg_free_params (struct statement *stmt, bool print) |
static bool | insert_tobeinserted (int position, int ph_len, struct statement *stmt, char *tobeinserted) |
static bool | store_input_from_desc (struct statement *stmt, struct descriptor_item *desc_item, char **tobeinserted) |
bool | ecpg_build_params (struct statement *stmt) |
bool | ecpg_autostart_transaction (struct statement *stmt) |
bool | ecpg_execute (struct statement *stmt) |
bool | ecpg_process_output (struct statement *stmt, bool clear_result) |
bool | ecpg_do_prologue (int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, enum ECPG_statement_type statement_type, const char *query, va_list args, struct statement **stmt_out) |
void | ecpg_do_epilogue (struct statement *stmt) |
bool | ecpg_do (const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query, va_list args) |
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,...) |
bool | ECPGdo_descriptor (int line, const char *connection, const char *descriptor, const char *query) |
#define not_an_array_in_ecpg ECPG_ARRAY_NONE |
Referenced by ecpg_is_type_an_array().
|
static |
Definition at line 491 of file execute.c.
References ecpg_alloc(), ecpg_hex_enc_len(), and ecpg_hex_encode().
Referenced by ecpg_build_params().
Definition at line 1585 of file execute.c.
References connection::autocommit, statement::compat, statement::connection, connection::connection, ecpg_check_PQresult(), ecpg_free_params(), statement::lineno, PQclear(), PQexec(), PQTRANS_IDLE, PQtransactionStatus(), and statement::results.
Referenced by ecpg_do().
Definition at line 1216 of file execute.c.
References statement::command, statement::compat, statement::connection, connection::connection, convert_bytea_to_string(), descriptor::count, descriptor_item::data_len, ecpg_alloc(), ecpg_find_desc(), ecpg_free(), ecpg_free_params(), ecpg_raise(), ecpg_realloc(), ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, ecpg_store_input(), ECPG_TOO_FEW_ARGUMENTS, ECPG_TOO_MANY_ARGUMENTS, ECPGst_exec_with_exprlist, ECPGst_prepare, ECPGt_bytea, ECPGt_char, ECPGt_char_variable, ECPGt_descriptor, ECPGt_NO_INDICATOR, ECPGt_short, ECPGt_sqlda, ECPGt_varchar, statement::force_indicator, i, INFORMIX_MODE, statement::inlist, insert_tobeinserted(), descriptor_item::is_binary, descriptor::items, ECPGgeneric_bytea::len, statement::lineno, descriptor_item::next, variable::next, next_insert(), statement::nparams, descriptor_item::num, statement::paramformats, statement::paramlengths, statement::paramvalues, variable::pointer, PQparameterStatus(), statement::questionmarks, snprintf, sprintf, sqlda_compat::sqld, sqlvar_compat::sqldata, sqlvar_struct::sqldata, sqlvar_compat::sqlind, sqlvar_struct::sqlind, sqlda_struct::sqln, sqlvar_compat::sqltype, sqlvar_struct::sqltype, sqlda_struct::sqlvar, sqlda_compat::sqlvar, statement::statement_type, store_input_from_desc(), generate_unaccent_rules::str, variable::type, variable::value, and value.
Referenced by ecpg_do().
bool ecpg_do | ( | const int | lineno, |
const int | compat, | ||
const int | force_indicator, | ||
const char * | connection_name, | ||
const bool | questionmarks, | ||
const int | st, | ||
const char * | query, | ||
va_list | args | ||
) |
Definition at line 2253 of file execute.c.
References ecpg_autostart_transaction(), ecpg_build_params(), ecpg_do_epilogue(), ecpg_do_prologue(), ecpg_execute(), and ecpg_process_output().
Referenced by ECPGdo().
void ecpg_do_epilogue | ( | struct statement * | stmt | ) |
Definition at line 2221 of file execute.c.
References free_statement(), locale_t, statement::oldlocale, and setlocale.
Referenced by ecpg_do(), and ecpg_do_prologue().
bool ecpg_do_prologue | ( | int | lineno, |
const int | compat, | ||
const int | force_indicator, | ||
const char * | connection_name, | ||
const bool | questionmarks, | ||
enum ECPG_statement_type | statement_type, | ||
const char * | query, | ||
va_list | args, | ||
struct statement ** | stmt_out | ||
) |
Definition at line 1949 of file execute.c.
References variable::arrsize, statement::command, compat, statement::compat, statement::connection, connection::connection, ecpg_alloc(), ecpg_auto_prepare(), ecpg_clear_auto_mem(), ecpg_do_epilogue(), ECPG_EMPTY, ecpg_free(), ecpg_get_connection(), ecpg_gettext, ecpg_init(), ECPG_INVALID_STMT, ECPG_NOT_CONN, ecpg_prepared(), ecpg_raise(), ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, ecpg_strdup(), ECPG_TOO_FEW_ARGUMENTS, ECPGst_execute, ECPGst_prepare, ECPGst_prepnormal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_NO_INDICATOR, ECPGt_unsigned_char, force_indicator, statement::force_indicator, variable::ind_arrsize, variable::ind_offset, variable::ind_pointer, variable::ind_type, variable::ind_value, variable::ind_varcharsize, statement::inlist, statement::lineno, sort-test::list, locale_t, statement::name, connection::name, variable::next, variable::offset, statement::oldlocale, statement::outlist, variable::pointer, questionmarks, statement::questionmarks, setlocale, statement::statement_type, variable::type, generate_unaccent_rules::type, variable::value, and variable::varcharsize.
Referenced by ecpg_do().
Definition at line 1606 of file execute.c.
References statement::command, statement::compat, statement::connection, connection::connection, ecpg_check_PQresult(), ecpg_free_params(), ecpg_log(), ecpg_register_prepared_stmt(), ECPGst_execute, ECPGst_prepare, statement::lineno, statement::name, connection::name, statement::nparams, statement::paramformats, statement::paramlengths, statement::paramvalues, PQexec(), PQexecParams(), PQexecPrepared(), statement::results, and statement::statement_type.
Referenced by ecpg_do().
Definition at line 1109 of file execute.c.
References ecpg_free(), statement::lineno, statement::nparams, statement::paramformats, statement::paramlengths, statement::paramvalues, and print_param_value().
Referenced by ecpg_autostart_transaction(), ecpg_build_params(), and ecpg_execute().
|
static |
Definition at line 167 of file execute.c.
References connection::cache_head, statement::compat, statement::connection, connection::connection, ecpg_alloc(), ECPG_ARRAY_ARRAY, ECPG_ARRAY_ERROR, ECPG_ARRAY_NONE, ECPG_ARRAY_NOT_SET, ECPG_ARRAY_VECTOR, ecpg_check_PQresult(), ecpg_dynamic_type(), ecpg_free(), ECPG_IS_ARRAY, ecpg_log(), ecpg_type_infocache_push(), ECPGtype_information_cache::isarray, statement::lineno, ECPGtype_information_cache::next, not_an_array_in_ecpg, ECPGtype_information_cache::oid, PGRES_TUPLES_OK, PQclear(), PQexec(), PQgetvalue(), PQntuples(), PQresultStatus(), sprintf, SQL3_CHARACTER, SQL3_CHARACTER_VARYING, and variable::type.
Referenced by ecpg_store_result().
Definition at line 1675 of file execute.c.
References pgNotify::be_pid, statement::compat, statement::connection, connection::connection, ecpg_build_compat_sqlda(), ecpg_build_native_sqlda(), ECPG_COMPAT_INFORMIX_SE, ecpg_find_desc(), ecpg_log(), ECPG_NOT_FOUND, ECPG_OUT_OF_MEMORY, ecpg_raise(), ecpg_raise_backend(), ecpg_set_compat_sqlda(), ecpg_set_native_sqlda(), ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_NO_DATA, ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_TARGETS, ecpg_store_result(), ECPG_TOO_FEW_ARGUMENTS, ECPG_TOO_MANY_ARGUMENTS, ECPGget_sqlca(), ECPGt_descriptor, ECPGt_sqlda, free, i, INFORMIX_MODE, statement::lineno, variable::next, statement::outlist, PGRES_COMMAND_OK, PGRES_COPY_OUT, PGRES_TUPLES_OK, variable::pointer, PQclear(), PQcmdStatus(), PQcmdTuples(), PQconsumeInput(), PQfreemem(), PQgetCopyData(), PQgetResult(), PQnfields(), PQnotifies(), PQntuples(), PQoidValue(), PQresultErrorMessage(), PQresultStatus(), printf, pgNotify::relname, descriptor::result, statement::results, sqlca, sqlca_t::sqlerrd, status(), and variable::type.
Referenced by ecpg_do().
bool ecpg_store_input | ( | const int | lineno, |
const bool | force_indicator, | ||
const struct variable * | var, | ||
char ** | tobeinserted_p, | ||
bool | quote | ||
) |
Definition at line 509 of file execute.c.
References ECPGgeneric_varchar::arr, ECPGgeneric_bytea::arr, variable::arrsize, numeric::dscale, ecpg_alloc(), ECPG_CONVERT_BOOL, ecpg_free(), ecpg_raise(), ecpg_realloc(), ECPG_SQLSTATE_DATATYPE_MISMATCH, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, ecpg_strdup(), ecpg_type_name(), ECPG_UNSUPPORTED, ECPGis_noind_null(), ECPGt_bool, ECPGt_bytea, ECPGt_char, ECPGt_char_variable, ECPGt_const, ECPGt_date, ECPGt_decimal, ECPGt_descriptor, ECPGt_double, ECPGt_float, ECPGt_int, ECPGt_interval, ECPGt_long, ECPGt_long_long, ECPGt_NO_INDICATOR, ECPGt_numeric, ECPGt_short, ECPGt_sqlda, ECPGt_string, ECPGt_timestamp, ECPGt_unsigned_char, ECPGt_unsigned_int, ECPGt_unsigned_long, ECPGt_unsigned_long_long, ECPGt_unsigned_short, ECPGt_varchar, element(), variable::ind_type, variable::ind_value, ECPGgeneric_varchar::len, ECPGgeneric_bytea::len, variable::offset, PGTYPESdate_to_asc(), PGTYPESinterval_to_asc(), PGTYPESnumeric_copy(), PGTYPESnumeric_free(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_new(), PGTYPESnumeric_to_asc(), PGTYPEStimestamp_to_asc(), quote_postgres(), sprintf, sprintf_double_value(), sprintf_float_value(), generate_unaccent_rules::str, variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_build_params(), ECPGset_desc(), and store_input_from_desc().
bool ecpg_store_result | ( | const PGresult * | results, |
int | act_field, | ||
const struct statement * | stmt, | ||
struct variable * | var | ||
) |
Definition at line 306 of file execute.c.
References variable::arrsize, statement::compat, ECPG_ARRAY_ERROR, ECPG_ARRAY_NONE, ecpg_auto_alloc(), ecpg_get_data(), ECPG_INFORMIX_SUBSELECT_NOT_ONE, ecpg_is_type_an_array(), ecpg_log(), ECPG_NO_ARRAY, ECPG_OUT_OF_MEMORY, ecpg_raise(), ECPG_SQLSTATE_CARDINALITY_VIOLATION, ECPG_SQLSTATE_DATATYPE_MISMATCH, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, ECPG_TOO_MANY_MATCHES, ECPGt_char, ECPGt_string, ECPGt_unsigned_char, ECPGt_varchar, statement::force_indicator, variable::ind_arrsize, variable::ind_offset, variable::ind_pointer, variable::ind_type, variable::ind_value, variable::ind_varcharsize, INFORMIX_MODE, ECPGtype_information_cache::isarray, statement::lineno, variable::offset, variable::pointer, PQfformat(), PQftype(), PQgetlength(), PQgetvalue(), PQntuples(), status(), variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_process_output(), and ECPGget_desc().
|
static |
Definition at line 151 of file execute.c.
References ecpg_alloc(), ECPGtype_information_cache::isarray, ECPGtype_information_cache::next, and ECPGtype_information_cache::oid.
Referenced by ecpg_is_type_an_array().
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 at line 2287 of file execute.c.
References generate_unaccent_rules::args, and ecpg_do().
Referenced by check_result_of_insert(), close_cur1(), ECPGdo_descriptor(), get_record1(), main(), open_cur1(), openit(), and test().
bool ECPGdo_descriptor | ( | int | line, |
const char * | connection, | ||
const char * | descriptor, | ||
const char * | query | ||
) |
Definition at line 2302 of file execute.c.
References ECPG_COMPAT_PGSQL, ECPGdo(), ECPGt_descriptor, ECPGt_EOIT, ECPGt_EORT, and ECPGt_NO_INDICATOR.
|
static |
Definition at line 96 of file execute.c.
References statement::command, ecpg_free(), free_variable(), statement::inlist, statement::name, statement::oldlocale, and statement::outlist.
Referenced by ecpg_do_epilogue().
|
static |
Definition at line 83 of file execute.c.
References ecpg_free(), and variable::next.
Referenced by free_statement().
|
static |
Definition at line 1130 of file execute.c.
References statement::command, ecpg_alloc(), ecpg_free(), and statement::lineno.
Referenced by ecpg_build_params().
|
static |
Definition at line 1079 of file execute.c.
References ecpg_alloc(), ecpg_free(), ecpg_hex_enc_len(), ecpg_hex_encode(), ecpg_log(), and value.
Referenced by ecpg_free_params().
|
static |
Definition at line 40 of file execute.c.
References arg, ecpg_alloc(), ecpg_free(), ESCAPE_STRING_SYNTAX, and PQescapeString().
Referenced by ecpg_store_input().
|
static |
Definition at line 459 of file execute.c.
References sprintf.
Referenced by ecpg_store_input().
|
static |
Definition at line 475 of file execute.c.
References sprintf.
Referenced by ecpg_store_input().
|
static |
Definition at line 1162 of file execute.c.
References variable::arrsize, descriptor_item::data, descriptor_item::data_len, ecpg_alloc(), ecpg_store_input(), ECPGt_char, ECPGt_int, ECPGt_NO_INDICATOR, statement::force_indicator, variable::ind_arrsize, variable::ind_offset, variable::ind_pointer, variable::ind_type, variable::ind_value, variable::ind_varcharsize, descriptor_item::indicator, descriptor_item::is_binary, statement::lineno, variable::offset, variable::pointer, variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_build_params().