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 |
|
static |
Definition at line 488 of file execute.c.
References ecpg_alloc(), ecpg_hex_enc_len(), and ecpg_hex_encode().
Referenced by ecpg_build_params().
bool ecpg_autostart_transaction | ( | struct statement * | stmt | ) |
Definition at line 1581 of file execute.c.
References ecpg_check_PQresult(), ecpg_free_params(), PQclear(), PQexec(), PQTRANS_IDLE, PQtransactionStatus(), and stmt.
Referenced by ecpg_do().
bool ecpg_build_params | ( | struct statement * | stmt | ) |
Definition at line 1213 of file execute.c.
References 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, i, if(), INFORMIX_MODE, insert_tobeinserted(), descriptor_item::is_binary, descriptor::items, len, descriptor_item::next, variable::next, next_insert(), descriptor_item::num, variable::pointer, PQparameterStatus(), 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_compat::sqlvar, sqlda_struct::sqlvar, stmt, store_input_from_desc(), str, variable::type, value, and variable::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 2241 of file execute.c.
References generate_unaccent_rules::args, compat, ecpg_autostart_transaction(), ecpg_build_params(), ecpg_do_epilogue(), ecpg_do_prologue(), ecpg_execute(), ecpg_process_output(), force_indicator, statement::lineno, questionmarks, and stmt.
Referenced by ECPGdo().
void ecpg_do_epilogue | ( | struct statement * | stmt | ) |
Definition at line 2214 of file execute.c.
References free_statement(), locale_t, setlocale, and stmt.
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 1944 of file execute.c.
References generate_unaccent_rules::args, variable::arrsize, Assert, statement::command, compat, 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_pthreads_init(), 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, variable::ind_arrsize, variable::ind_offset, variable::ind_pointer, variable::ind_type, variable::ind_value, variable::ind_varcharsize, statement::lineno, sort-test::list, locale_t, connection::name, variable::next, variable::offset, variable::pointer, questionmarks, setlocale, statement::statement_type, stmt, type, variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_do().
bool ecpg_execute | ( | struct statement * | stmt | ) |
Definition at line 1602 of file execute.c.
References ecpg_check_PQresult(), ecpg_free_params(), ecpg_log(), ecpg_register_prepared_stmt(), ECPGst_execute, ECPGst_prepare, PQexec(), PQexecParams(), PQexecPrepared(), and stmt.
Referenced by ecpg_do().
void ecpg_free_params | ( | struct statement * | stmt, |
bool | |||
) |
Definition at line 1106 of file execute.c.
References ecpg_free(), print(), print_param_value(), and stmt.
Referenced by ecpg_autostart_transaction(), ecpg_build_params(), and ecpg_execute().
|
static |
Definition at line 148 of file execute.c.
References ecpg_alloc(), ECPGtype_information_cache::isarray, ECPGtype_information_cache::next, and ECPGtype_information_cache::oid.
Referenced by ecpg_store_result().
bool ecpg_process_output | ( | struct statement * | stmt, |
bool | clear_result | ||
) |
Definition at line 1671 of file execute.c.
References pgNotify::be_pid, 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, variable::next, 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, res, descriptor::result, sqlca, stmt, variable::type, and while().
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 506 of file execute.c.
References 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(), force_indicator, variable::ind_type, variable::ind_value, 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(), 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 303 of file execute.c.
References variable::arrsize, 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, variable::ind_arrsize, variable::ind_offset, variable::ind_pointer, variable::ind_type, variable::ind_value, variable::ind_varcharsize, INFORMIX_MODE, ECPGtype_information_cache::isarray, len, variable::offset, variable::pointer, PQfformat(), PQftype(), PQgetlength(), PQgetvalue(), PQntuples(), stmt, variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_process_output(), and ECPGget_desc().
|
static |
Definition at line 148 of file execute.c.
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 2275 of file execute.c.
References generate_unaccent_rules::args, compat, ecpg_do(), force_indicator, statement::lineno, questionmarks, va_end(), and va_start().
Referenced by check_result_of_insert(), close_cur1(), ECPGdo_descriptor(), execute_test(), fn(), get_record1(), main(), open_cur1(), openit(), test(), and test_thread().
bool ECPGdo_descriptor | ( | int | line, |
const char * | connection, | ||
const char * | descriptor, | ||
const char * | query | ||
) |
Definition at line 2290 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 ecpg_free(), free_variable(), and stmt.
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 1127 of file execute.c.
References ecpg_alloc(), ecpg_free(), and stmt.
Referenced by ecpg_build_params().
|
static |
Definition at line 111 of file execute.c.
References false, i, and questionmarks.
Referenced by ecpg_build_params().
|
static |
Definition at line 1076 of file execute.c.
References ecpg_alloc(), ecpg_free(), ecpg_hex_enc_len(), ecpg_hex_encode(), ecpg_log(), len, 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, PQescapeString(), and res.
Referenced by ecpg_store_input().
|
static |
Definition at line 456 of file execute.c.
References sprintf, and value.
Referenced by ecpg_store_input().
|
static |
Definition at line 472 of file execute.c.
References sprintf, and value.
Referenced by ecpg_store_input().
|
static |
Definition at line 1159 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, 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, variable::offset, variable::pointer, stmt, variable::type, variable::value, and variable::varcharsize.
Referenced by ecpg_build_params().