1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-21 10:42:50 +03:00

Cleaned up ecpglib and renamed functions that do not need to be exported.

Created export list for ecpglib.
This commit is contained in:
Michael Meskes
2007-10-03 11:11:12 +00:00
parent c4a6c2f871
commit 7793c6ecca
51 changed files with 1748 additions and 1649 deletions

View File

@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.48 2007/09/27 19:53:44 tgl Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.49 2007/10/03 11:11:12 meskes Exp $
#
#-------------------------------------------------------------------------
@@ -31,6 +31,7 @@ OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
# thread.c is needed only for non-WIN32 implementation of path.c
ifneq ($(PORTNAME), win32)
OBJS += thread.o
DLL_DEFFILE=libecpgdll.def
endif
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) -lm $(PTHREAD_LIBS)
@@ -58,6 +59,52 @@ path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
$(top_builddir)/src/port/pg_config_paths.h:
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
# We need several not-quite-identical variants of .DEF files to build libecpg
# DLLs for Windows. These are made from the single source file exports.txt.
# Since we can't assume that Windows boxes will have sed, the .DEF files are
# always built and included in distribution tarballs.
.PHONY: def-files
def-files: $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
$(srcdir)/libecpgdll.def: exports.txt
echo '; DEF file for MS VC++' > $@
echo 'LIBRARY LIBECPG' >> $@
echo 'EXPORTS' >> $@
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' < $< >> $@
$(srcdir)/blibecpgdll.def: exports.txt
echo '; DEF file for Borland C++ Builder' > $@
echo 'LIBRARY BLIBECPG' >> $@
echo 'EXPORTS' >> $@
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/' < $< >> $@
echo '' >> $@
echo '; Aliases for MS compatible names' >> $@
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@
# Where possible, restrict the symbols exported by the library to just the
# official list, so as to avoid unintentional ABI changes.
ifeq ($(PORTNAME), darwin)
$(shlib): exports.list
exports.list: exports.txt
$(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
exported_symbols_list = -exported_symbols_list exports.list
endif
ifeq ($(PORTNAME), linux)
$(shlib): exports.list
exports.list: exports.txt
echo '{ global:' >$@
$(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
echo ' local: *; };' >>$@
exported_symbols_list = -Wl,--version-script=exports.list
endif
install: all installdirs install-lib
installdirs:
@@ -66,4 +113,4 @@ installdirs:
uninstall: uninstall-lib
clean distclean maintainer-clean: clean-lib
rm -f $(OBJS) path.c snprintf.c strlcpy.c thread.c
rm -f $(OBJS) path.c snprintf.c strlcpy.c thread.c exports.list

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.46 2007/10/03 08:55:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.47 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -71,7 +71,7 @@ ecpg_get_connection_nr(const char *connection_name)
}
struct connection *
ECPGget_connection(const char *connection_name)
ecpg_get_connection(const char *connection_name)
{
struct connection *ret = NULL;
@@ -117,7 +117,7 @@ ecpg_finish(struct connection * act)
struct ECPGtype_information_cache *cache,
*ptr;
ECPGdeallocate_all_conn(0, ECPG_COMPAT_PGSQL, act);
ecpg_deallocate_all_conn(0, ECPG_COMPAT_PGSQL, act);
PQfinish(act->connection);
/*
@@ -144,33 +144,33 @@ ecpg_finish(struct connection * act)
if (actual_connection == act)
actual_connection = all_connections;
ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
ecpg_log("ecpg_finish: Connection %s closed.\n", act->name);
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ECPGfree(ptr));
ECPGfree(act->name);
ECPGfree(act);
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ecpg_free(ptr));
ecpg_free(act->name);
ecpg_free(act);
}
else
ECPGlog("ecpg_finish: called an extra time.\n");
ecpg_log("ecpg_finish: called an extra time.\n");
}
bool
ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
{
struct connection *con = ECPGget_connection(connection_name);
struct connection *con = ecpg_get_connection(connection_name);
PGresult *results;
if (!ECPGinit(con, connection_name, lineno))
if (!ecpg_init(con, connection_name, lineno))
return (false);
ECPGlog("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name);
ecpg_log("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name);
if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0)
{
if (con->committed)
{
results = PQexec(con->connection, "begin transaction");
if (!ECPGcheck_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL))
if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL))
return false;
PQclear(results);
con->committed = false;
@@ -182,7 +182,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
if (!con->committed)
{
results = PQexec(con->connection, "commit");
if (!ECPGcheck_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL))
if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL))
return false;
PQclear(results);
con->committed = true;
@@ -196,9 +196,9 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
bool
ECPGsetconn(int lineno, const char *connection_name)
{
struct connection *con = ECPGget_connection(connection_name);
struct connection *con = ecpg_get_connection(connection_name);
if (!ECPGinit(con, connection_name, lineno))
if (!ecpg_init(con, connection_name, lineno))
return (false);
#ifdef ENABLE_THREAD_SAFETY
@@ -229,7 +229,7 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
if (strncmp(sqlstate, "00", 2) == 0)
return;
ECPGlog("ECPGnoticeReceiver %s\n", message);
ecpg_log("ECPGnoticeReceiver %s\n", message);
/* map to SQLCODE for backward compatibility */
if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0)
@@ -252,7 +252,7 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
sqlca->sqlerrm.sqlerrmc[sizeof(sqlca->sqlerrm.sqlerrmc) - 1] = 0;
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
ECPGlog("raising sqlcode %d\n", sqlcode);
ecpg_log("raising sqlcode %d\n", sqlcode);
}
@@ -263,17 +263,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
struct sqlca_t *sqlca = ECPGget_sqlca();
enum COMPAT_MODE compat = c;
struct connection *this;
char *dbname = name ? ECPGstrdup(name, lineno) : NULL,
char *dbname = name ? ecpg_strdup(name, lineno) : NULL,
*host = NULL,
*tmp,
*port = NULL,
*realname = NULL,
*options = NULL;
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
/* clear auto_mem structure because some error handling functions might access it */
ECPGclear_auto_mem();
ecpg_clear_auto_mem();
if (INFORMIX_MODE(compat))
{
@@ -287,8 +287,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
envname = getenv("PG_DBPATH");
if (envname)
{
ECPGfree(dbname);
dbname = ECPGstrdup(envname, lineno);
ecpg_free(dbname);
dbname = ecpg_strdup(envname, lineno);
}
}
@@ -301,15 +301,15 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
#endif
/* check if the identifier is unique */
if (ECPGget_connection(connection_name))
if (ecpg_get_connection(connection_name))
{
ECPGfree(dbname);
ECPGlog("connect: connection identifier %s is already in use\n",
ecpg_free(dbname);
ecpg_log("ECPGconnect: connection identifier %s is already in use\n",
connection_name);
return false;
}
if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
if ((this = (struct connection *) ecpg_alloc(sizeof(struct connection), lineno)) == NULL)
return false;
if (dbname != NULL)
@@ -341,14 +341,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
tmp = strrchr(dbname + offset, '?');
if (tmp != NULL) /* options given */
{
options = ECPGstrdup(tmp + 1, lineno);
options = ecpg_strdup(tmp + 1, lineno);
*tmp = '\0';
}
tmp = last_dir_separator(dbname + offset);
if (tmp != NULL) /* database name given */
{
realname = ECPGstrdup(tmp + 1, lineno);
realname = ecpg_strdup(tmp + 1, lineno);
*tmp = '\0';
}
@@ -361,53 +361,53 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if ((tmp2 = strchr(tmp + 1, ':')) != NULL)
{
*tmp2 = '\0';
host = ECPGstrdup(tmp + 1, lineno);
host = ecpg_strdup(tmp + 1, lineno);
if (strncmp(dbname, "unix:", 5) != 0)
{
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno);
ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
ecpg_log("ECPGconnect: socketname %s given for TCP connection in line %d\n", host, lineno);
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
if (host)
ECPGfree(host);
ecpg_free(host);
/*
* port not set yet if (port) ECPGfree(port);
* port not set yet if (port) ecpg_free(port);
*/
if (options)
ECPGfree(options);
ecpg_free(options);
if (realname)
ECPGfree(realname);
ecpg_free(realname);
if (dbname)
ECPGfree(dbname);
ecpg_free(dbname);
free(this);
return false;
}
}
else
port = ECPGstrdup(tmp + 1, lineno);
port = ecpg_strdup(tmp + 1, lineno);
}
if (strncmp(dbname, "unix:", 5) == 0)
{
if (strcmp(dbname + offset, "localhost") != 0 && strcmp(dbname + offset, "127.0.0.1") != 0)
{
ECPGlog("connect: non-localhost access via sockets in line %d\n", lineno);
ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
ecpg_log("ECPGconnect: non-localhost access via sockets in line %d\n", lineno);
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
if (host)
ECPGfree(host);
ecpg_free(host);
if (port)
ECPGfree(port);
ecpg_free(port);
if (options)
ECPGfree(options);
ecpg_free(options);
if (realname)
ECPGfree(realname);
ecpg_free(realname);
if (dbname)
ECPGfree(dbname);
ecpg_free(dbname);
free(this);
return false;
}
}
else
host = ECPGstrdup(dbname + offset, lineno);
host = ecpg_strdup(dbname + offset, lineno);
}
}
@@ -417,18 +417,18 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
tmp = strrchr(dbname, ':');
if (tmp != NULL) /* port number given */
{
port = ECPGstrdup(tmp + 1, lineno);
port = ecpg_strdup(tmp + 1, lineno);
*tmp = '\0';
}
tmp = strrchr(dbname, '@');
if (tmp != NULL) /* host name given */
{
host = ECPGstrdup(tmp + 1, lineno);
host = ecpg_strdup(tmp + 1, lineno);
*tmp = '\0';
}
realname = (strlen(dbname) > 0) ? ECPGstrdup(dbname, lineno) : NULL;
realname = (strlen(dbname) > 0) ? ecpg_strdup(dbname, lineno) : NULL;
}
}
else
@@ -439,9 +439,9 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
pthread_mutex_lock(&connections_mutex);
#endif
if (connection_name != NULL)
this->name = ECPGstrdup(connection_name, lineno);
this->name = ecpg_strdup(connection_name, lineno);
else
this->name = ECPGstrdup(realname, lineno);
this->name = ecpg_strdup(realname, lineno);
this->cache_head = NULL;
this->prep_stmts = NULL;
@@ -457,7 +457,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
#endif
actual_connection = all_connections;
ECPGlog("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
realname ? realname : "<DEFAULT>",
host ? host : "<DEFAULT>",
port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>",
@@ -471,7 +471,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
const char *errmsg = PQerrorMessage(this->connection);
const char *db = realname ? realname : "<DEFAULT>";
ECPGlog("connect: could not open database %s on %s port %s %s%s%s%s in line %d\n\t%s\n",
ecpg_log("ECPGconnect: could not open database %s on %s port %s %s%s%s%s in line %d\n\t%s\n",
db,
host ? host : "<DEFAULT>",
port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>",
@@ -484,17 +484,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
pthread_mutex_unlock(&connections_mutex);
#endif
ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db);
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db);
if (host)
ECPGfree(host);
ecpg_free(host);
if (port)
ECPGfree(port);
ecpg_free(port);
if (options)
ECPGfree(options);
ecpg_free(options);
if (realname)
ECPGfree(realname);
ecpg_free(realname);
if (dbname)
ECPGfree(dbname);
ecpg_free(dbname);
return false;
}
#ifdef ENABLE_THREAD_SAFETY
@@ -502,15 +502,15 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
#endif
if (host)
ECPGfree(host);
ecpg_free(host);
if (port)
ECPGfree(port);
ecpg_free(port);
if (options)
ECPGfree(options);
ecpg_free(options);
if (realname)
ECPGfree(realname);
ecpg_free(realname);
if (dbname)
ECPGfree(dbname);
ecpg_free(dbname);
this->committed = true;
this->autocommit = autocommit;
@@ -532,7 +532,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
if (strcmp(connection_name, "ALL") == 0)
{
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
for (con = all_connections; con;)
{
struct connection *f = con;
@@ -545,7 +545,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
{
con = ecpg_get_connection_nr(connection_name);
if (!ECPGinit(con, connection_name, lineno))
if (!ecpg_init(con, connection_name, lineno))
{
#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.38 2007/05/10 14:29:21 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.39 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -39,7 +39,7 @@ garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat
}
bool
ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
enum ECPGttype type, enum ECPGttype ind_type,
char *var, char *ind, long varcharsize, long offset,
long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
@@ -60,7 +60,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else
log_offset = offset;
ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, isarray ? "Yes" : "No");
ecpg_log("ecpg_get_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, isarray ? "Yes" : "No");
/* We will have to decode the value */
@@ -104,7 +104,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR,
ecpg_raise(lineno, ECPG_MISSING_INDICATOR,
ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER,
NULL);
return (false);
@@ -112,9 +112,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
break;
default:
ECPGraise(lineno, ECPG_UNSUPPORTED,
ecpg_raise(lineno, ECPG_UNSUPPORTED,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
ECPGtype_name(ind_type));
ecpg_type_name(ind_type));
return (false);
break;
}
@@ -128,7 +128,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (!pval || *pval != '{')
{
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY,
ecpg_raise(lineno, ECPG_DATA_NOT_ARRAY,
ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL);
return (false);
}
@@ -213,7 +213,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
res = strtol(pval, &scan_length, 10);
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_INT_FORMAT,
ecpg_raise(lineno, ECPG_INT_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -247,7 +247,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ures = strtoul(pval, &scan_length, 10);
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_UINT_FORMAT,
ecpg_raise(lineno, ECPG_UINT_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -281,7 +281,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ecpg_raise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
pval = scan_length;
@@ -299,7 +299,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ecpg_raise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
pval = scan_length;
@@ -325,7 +325,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_FLOAT_FORMAT,
ecpg_raise(lineno, ECPG_FLOAT_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -358,7 +358,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = false;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL,
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
ECPG_SQLSTATE_DATATYPE_MISMATCH,
"different size");
break;
@@ -370,7 +370,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = true;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL,
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
ECPG_SQLSTATE_DATATYPE_MISMATCH,
"different size");
break;
@@ -382,7 +382,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
}
ECPGraise(lineno, ECPG_CONVERT_BOOL,
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
break;
@@ -490,7 +490,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* did we get an error? */
if (nres == NULL)
{
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
lineno, pval ? pval : "", errno);
if (INFORMIX_MODE(compat))
@@ -504,14 +504,14 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ECPGset_noind_null(ECPGt_numeric, nres);
else
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY,
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY,
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return (false);
}
}
else
{
ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -524,7 +524,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
free(nres);
ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -553,7 +553,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* did we get an error? */
if (ires == NULL)
{
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
lineno, pval ? pval : "", errno);
if (INFORMIX_MODE(compat))
@@ -562,7 +562,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
* Informix wants its own NULL value here
* instead of an error
*/
ires = (interval *) ECPGalloc(sizeof(interval), lineno);
ires = (interval *) ecpg_alloc(sizeof(interval), lineno);
if (!ires)
return (false);
@@ -570,7 +570,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -583,7 +583,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
free(ires);
ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -607,7 +607,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* did we get an error? */
if (errno != 0)
{
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
lineno, pval ? pval : "", errno);
if (INFORMIX_MODE(compat))
@@ -620,7 +620,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
ECPGraise(lineno, ECPG_DATE_FORMAT,
ecpg_raise(lineno, ECPG_DATE_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -632,7 +632,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_DATE_FORMAT,
ecpg_raise(lineno, ECPG_DATE_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -654,7 +654,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* did we get an error? */
if (errno != 0)
{
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
lineno, pval ? pval : "", errno);
if (INFORMIX_MODE(compat))
@@ -667,7 +667,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -679,7 +679,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@@ -691,9 +691,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
default:
ECPGraise(lineno, ECPG_UNSUPPORTED,
ecpg_raise(lineno, ECPG_UNSUPPORTED,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
ECPGtype_name(type));
ecpg_type_name(type));
return (false);
break;
}

View File

@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.25 2007/10/03 08:55:22 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.26 2007/10/03 11:11:12 meskes Exp $
*/
#define POSTGRES_ECPG_INTERNAL
@@ -56,16 +56,16 @@ static struct descriptor *all_descriptors = NULL;
/* old internal convenience function that might go away later */
static PGresult *
ECPGresultByDescriptor(int line, const char *name)
ecpg_result_by_descriptor(int line, const char *name)
{
struct descriptor *desc = ECPGfind_desc(line, name);
struct descriptor *desc = ecpg_find_desc(line, name);
if (desc == NULL)
return NULL;
return desc->result;
}
static unsigned int
ECPGDynamicType_DDT(Oid type)
ecpg_dynamic_type_DDT(Oid type)
{
switch (type)
{
@@ -90,14 +90,14 @@ ECPGget_desc_header(int lineno, const char *desc_name, int *count)
PGresult *ECPGresult;
struct sqlca_t *sqlca = ECPGget_sqlca();
ECPGinit_sqlca(sqlca);
ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
ecpg_init_sqlca(sqlca);
ECPGresult = ecpg_result_by_descriptor(lineno, desc_name);
if (!ECPGresult)
return false;
*count = PQnfields(ECPGresult);
sqlca->sqlerrd[2] = 1;
ECPGlog("ECPGget_desc_header: found %d attributes.\n", *count);
ecpg_log("ECPGget_desc_header: found %d attributes.\n", *count);
return true;
}
@@ -139,7 +139,7 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
*(double *) var = (double) value;
break;
default:
ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
ecpg_raise(lineno, ECPG_VAR_NOT_NUMERIC, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
return (false);
}
@@ -184,7 +184,7 @@ set_int_item(int lineno, int *target, const void *var, enum ECPGttype vartype)
*target = *(double *) var;
break;
default:
ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
ecpg_raise(lineno, ECPG_VAR_NOT_NUMERIC, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
return (false);
}
@@ -216,7 +216,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
}
break;
default:
ECPGraise(lineno, ECPG_VAR_NOT_CHAR, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
ecpg_raise(lineno, ECPG_VAR_NOT_CHAR, ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, NULL);
return (false);
}
@@ -235,25 +235,25 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
struct sqlca_t *sqlca = ECPGget_sqlca();
va_start(args, index);
ECPGinit_sqlca(sqlca);
ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
ecpg_init_sqlca(sqlca);
ECPGresult = ecpg_result_by_descriptor(lineno, desc_name);
if (!ECPGresult)
return (false);
ntuples = PQntuples(ECPGresult);
if (ntuples < 1)
{
ECPGraise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
return (false);
}
if (index < 1 || index > PQnfields(ECPGresult))
{
ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX, NULL);
ecpg_raise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX, NULL);
return (false);
}
ECPGlog("ECPGget_desc: reading items for tuple %d\n", index);
ecpg_log("ECPGget_desc: reading items for tuple %d\n", index);
--index;
type = va_arg(args, enum ECPGdtype);
@@ -307,7 +307,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
if (!get_char_item(lineno, var, vartype, PQfname(ECPGresult, index), varcharsize))
return (false);
ECPGlog("ECPGget_desc: NAME = %s\n", PQfname(ECPGresult, index));
ecpg_log("ECPGget_desc: NAME = %s\n", PQfname(ECPGresult, index));
break;
case ECPGd_nullable:
@@ -326,49 +326,49 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
if (!get_int_item(lineno, var, vartype, (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff))
return (false);
ECPGlog("ECPGget_desc: SCALE = %d\n", (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff);
ecpg_log("ECPGget_desc: SCALE = %d\n", (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff);
break;
case ECPGd_precision:
if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) >> 16))
return (false);
ECPGlog("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
ecpg_log("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
break;
case ECPGd_octet:
if (!get_int_item(lineno, var, vartype, PQfsize(ECPGresult, index)))
return (false);
ECPGlog("ECPGget_desc: OCTET_LENGTH = %d\n", PQfsize(ECPGresult, index));
ecpg_log("ECPGget_desc: OCTET_LENGTH = %d\n", PQfsize(ECPGresult, index));
break;
case ECPGd_length:
if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) - VARHDRSZ))
return (false);
ECPGlog("ECPGget_desc: LENGTH = %d\n", PQfmod(ECPGresult, index) - VARHDRSZ);
ecpg_log("ECPGget_desc: LENGTH = %d\n", PQfmod(ECPGresult, index) - VARHDRSZ);
break;
case ECPGd_type:
if (!get_int_item(lineno, var, vartype, ECPGDynamicType(PQftype(ECPGresult, index))))
if (!get_int_item(lineno, var, vartype, ecpg_dynamic_type(PQftype(ECPGresult, index))))
return (false);
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType(PQftype(ECPGresult, index)));
ecpg_log("ECPGget_desc: TYPE = %d\n", ecpg_dynamic_type(PQftype(ECPGresult, index)));
break;
case ECPGd_di_code:
if (!get_int_item(lineno, var, vartype, ECPGDynamicType_DDT(PQftype(ECPGresult, index))))
if (!get_int_item(lineno, var, vartype, ecpg_dynamic_type_DDT(PQftype(ECPGresult, index))))
return (false);
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
ecpg_log("ECPGget_desc: TYPE = %d\n", ecpg_dynamic_type_DDT(PQftype(ECPGresult, index)));
break;
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
ECPGlog("ECPGget_desc: CARDINALITY = %d\n", PQntuples(ECPGresult));
ecpg_log("ECPGget_desc: CARDINALITY = %d\n", PQntuples(ECPGresult));
break;
case ECPGd_ret_length:
@@ -379,20 +379,20 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
*/
if (arrsize > 0 && ntuples > arrsize)
{
ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
ecpg_log("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
return false;
}
/* allocate storage if needed */
if (arrsize == 0 && *(void **) var == NULL)
{
void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
void *mem = (void *) ecpg_alloc(offset * ntuples, lineno);
if (!mem)
return false;
*(void **) var = mem;
ECPGadd_mem(mem, lineno);
ecpg_add_mem(mem, lineno);
var = mem;
}
@@ -401,13 +401,13 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
return (false);
var = (char *) var + offset;
ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index));
ecpg_log("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index));
}
break;
default:
snprintf(type_str, sizeof(type_str), "%d", type);
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
ecpg_raise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
return (false);
}
@@ -421,18 +421,18 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
/* Make sure we do NOT honor the locale for numeric input */
/* since the database gives the standard decimal point */
oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
oldlocale = ecpg_strdup(setlocale(LC_NUMERIC, NULL), lineno);
setlocale(LC_NUMERIC, "C");
memset(&stmt, 0, sizeof stmt);
stmt.lineno = lineno;
/* desparate try to guess something sensible */
stmt.connection = ECPGget_connection(NULL);
ECPGstore_result(ECPGresult, index, &stmt, &data_var);
stmt.connection = ecpg_get_connection(NULL);
ecpg_store_result(ECPGresult, index, &stmt, &data_var);
setlocale(LC_NUMERIC, oldlocale);
ECPGfree(oldlocale);
ecpg_free(oldlocale);
}
else if (data_var.ind_type != ECPGt_NO_INDICATOR && data_var.ind_pointer != NULL)
@@ -448,21 +448,21 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
*/
if (data_var.ind_arrsize > 0 && ntuples > data_var.ind_arrsize)
{
ECPGlog("ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d\n",
ecpg_log("ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d\n",
lineno, ntuples, data_var.ind_arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
return false;
}
/* allocate storage if needed */
if (data_var.ind_arrsize == 0 && data_var.ind_value == NULL)
{
void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
void *mem = (void *) ecpg_alloc(data_var.ind_offset * ntuples, lineno);
if (!mem)
return false;
*(void **) data_var.ind_pointer = mem;
ECPGadd_mem(mem, lineno);
ecpg_add_mem(mem, lineno);
data_var.ind_value = mem;
}
@@ -471,7 +471,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
if (!get_int_item(lineno, data_var.ind_value, data_var.ind_type, -PQgetisnull(ECPGresult, act_tuple, index)))
return (false);
data_var.ind_value = (char *) data_var.ind_value + data_var.ind_offset;
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
ecpg_log("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
}
sqlca->sqlerrd[2] = ntuples;
@@ -481,7 +481,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
bool
ECPGset_desc_header(int lineno, const char *desc_name, int count)
{
struct descriptor *desc = ECPGfind_desc(lineno, desc_name);
struct descriptor *desc = ecpg_find_desc(lineno, desc_name);
if (desc == NULL)
return false;
desc->count = count;
@@ -496,7 +496,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
struct descriptor_item *desc_item;
struct variable *var;
desc = ECPGfind_desc(lineno, desc_name);
desc = ecpg_find_desc(lineno, desc_name);
if (desc == NULL)
return false;
@@ -508,7 +508,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
if (desc_item == NULL)
{
desc_item = (struct descriptor_item *) ECPGalloc(sizeof(*desc_item), lineno);
desc_item = (struct descriptor_item *) ecpg_alloc(sizeof(*desc_item), lineno);
if (!desc_item)
return false;
desc_item->num = index;
@@ -518,7 +518,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
desc->items = desc_item;
}
if (!(var = (struct variable *) ECPGalloc(sizeof(struct variable), lineno)))
if (!(var = (struct variable *) ecpg_alloc(sizeof(struct variable), lineno)))
return false;
va_start(args, index);
@@ -560,13 +560,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
{
case ECPGd_data:
{
if (!ECPGstore_input(lineno, true, var, &tobeinserted, false))
if (!ecpg_store_input(lineno, true, var, &tobeinserted, false))
{
ECPGfree(var);
ecpg_free(var);
return false;
}
ECPGfree(desc_item->data); /* free() takes care of a potential NULL value */
ecpg_free(desc_item->data); /* free() takes care of a potential NULL value */
desc_item->data = (char *) tobeinserted;
tobeinserted = NULL;
break;
@@ -597,13 +597,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
char type_str[20];
snprintf(type_str, sizeof(type_str), "%d", itemtype);
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
ECPGfree(var);
ecpg_raise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
ecpg_free(var);
return false;
}
}
}
ECPGfree(var);
ecpg_free(var);
return true;
}
@@ -618,15 +618,15 @@ descriptor_free(struct descriptor *desc)
{
struct descriptor_item *di;
ECPGfree(desc_item->data);
ecpg_free(desc_item->data);
di = desc_item;
desc_item = desc_item->next;
ECPGfree(di);
ecpg_free(di);
}
ECPGfree(desc->name);
ecpg_free(desc->name);
PQclear(desc->result);
ECPGfree(desc);
ecpg_free(desc);
}
bool
@@ -636,7 +636,7 @@ ECPGdeallocate_desc(int line, const char *name)
struct descriptor *prev;
struct sqlca_t *sqlca = ECPGget_sqlca();
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
for (desc = get_descriptors(), prev = NULL; desc; prev = desc, desc = desc->next)
{
if (!strcmp(name, desc->name))
@@ -649,7 +649,7 @@ ECPGdeallocate_desc(int line, const char *name)
return true;
}
}
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, name);
ecpg_raise(line, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, name);
return false;
}
@@ -671,15 +671,15 @@ ECPGallocate_desc(int line, const char *name)
struct descriptor *new;
struct sqlca_t *sqlca = ECPGget_sqlca();
ECPGinit_sqlca(sqlca);
new = (struct descriptor *) ECPGalloc(sizeof(struct descriptor), line);
ecpg_init_sqlca(sqlca);
new = (struct descriptor *) ecpg_alloc(sizeof(struct descriptor), line);
if (!new)
return false;
new->next = get_descriptors();
new->name = ECPGalloc(strlen(name) + 1, line);
new->name = ecpg_alloc(strlen(name) + 1, line);
if (!new->name)
{
ECPGfree(new);
ecpg_free(new);
return false;
}
new->count = -1;
@@ -687,9 +687,9 @@ ECPGallocate_desc(int line, const char *name)
new->result = PQmakeEmptyPGresult(NULL, 0);
if (!new->result)
{
ECPGfree(new->name);
ECPGfree(new);
ECPGraise(line, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
ecpg_free(new->name);
ecpg_free(new);
ecpg_raise(line, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return false;
}
strcpy(new->name, name);
@@ -699,7 +699,7 @@ ECPGallocate_desc(int line, const char *name)
/* Find descriptor with name in the connection. */
struct descriptor *
ECPGfind_desc(int line, const char *name)
ecpg_find_desc(int line, const char *name)
{
struct descriptor *desc;
@@ -709,13 +709,13 @@ ECPGfind_desc(int line, const char *name)
return desc;
}
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, name);
ecpg_raise(line, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, name);
return NULL; /* not found */
}
bool
ECPGdescribe(int line, bool input, const char *statement,...)
{
ECPGlog("ECPGdescribe called on line %d for %s in %s\n", line, (input) ? "input" : "output", statement);
ecpg_log("ECPGdescribe called on line %d for %s in %s\n", line, (input) ? "input" : "output", statement);
return false;
}

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.17 2007/08/14 10:01:52 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.18 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -10,7 +10,7 @@
#include "sqlca.h"
void
ECPGraise(int line, int code, const char *sqlstate, const char *str)
ecpg_raise(int line, int code, const char *sqlstate, const char *str)
{
struct sqlca_t *sqlca = ECPGget_sqlca();
@@ -146,14 +146,14 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str)
}
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
ECPGlog("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca->sqlerrm.sqlerrmc);
ecpg_log("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca->sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */
ECPGfree_auto_mem();
}
void
ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat)
{
struct sqlca_t *sqlca = ECPGget_sqlca();
char *sqlstate;
@@ -188,7 +188,7 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
else
sqlca->sqlcode = ECPG_PGSQL;
ECPGlog("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n",
ecpg_log("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n",
sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */
@@ -197,12 +197,12 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
/* filter out all error codes */
bool
ECPGcheck_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPAT_MODE compat)
ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPAT_MODE compat)
{
if (results == NULL)
{
ECPGlog("ECPGcheck_PQresult line %d: error: %s", lineno, PQerrorMessage(connection));
ECPGraise_backend(lineno, NULL, connection, compat);
ecpg_log("ecpg_check_PQresult line %d: error: %s", lineno, PQerrorMessage(connection));
ecpg_raise_backend(lineno, NULL, connection, compat);
return (false);
}
@@ -214,7 +214,7 @@ ECPGcheck_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPA
break;
case PGRES_EMPTY_QUERY:
/* do nothing */
ECPGraise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
ecpg_raise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
PQclear(results);
return (false);
break;
@@ -224,8 +224,8 @@ ECPGcheck_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPA
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
case PGRES_BAD_RESPONSE:
ECPGlog("ECPGcheck_PQresult line %d: Error: %s", lineno, PQresultErrorMessage(results));
ECPGraise_backend(lineno, results, connection, compat);
ecpg_log("ecpg_check_PQresult line %d: Error: %s", lineno, PQresultErrorMessage(results));
ecpg_raise_backend(lineno, results, connection, compat);
PQclear(results);
return (false);
break;
@@ -233,15 +233,15 @@ ECPGcheck_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPA
return(true);
break;
case PGRES_COPY_IN:
ECPGlog("ECPGcheck_PQresult line %d: Got PGRES_COPY_IN ... tossing.\n", lineno);
ecpg_log("ecpg_check_PQresult line %d: Got PGRES_COPY_IN ... tossing.\n", lineno);
PQendcopy(connection);
PQclear(results);
return(false);
break;
default:
ECPGlog("ECPGcheck_PQresult line %d: Got something else, postgres error.\n",
ecpg_log("ecpg_check_PQresult line %d: Got something else, postgres error.\n",
lineno);
ECPGraise_backend(lineno, results, connection, compat);
ecpg_raise_backend(lineno, results, connection, compat);
PQclear(results);
return(false);
break;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/exports.txt,v 1.1 2007/10/03 11:11:12 meskes Exp $
# Functions to be exported by libpq DLLs
ECPGallocate_desc 1
ECPGconnect 2
ECPGdeallocate 3
ECPGdeallocate_all 4
ECPGdeallocate_desc 5
ECPGdebug 6
ECPGdescribe 7
ECPGdisconnect 8
ECPGdo 9
ECPGdo_descriptor 10
ECPGfree_auto_mem 11
ECPGget_desc 12
ECPGget_desc_header 13
ECPGget_sqlca 14
ECPGis_noind_null 15
ECPGprepare 16
ECPGprepared_statement 17
ECPGset_desc 18
ECPGset_desc_header 19
ECPGset_noind_null 20
ECPGsetcommit 21
ECPGsetconn 22
ECPGstatus 23
ECPGtrans 24
sqlprint 25

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.30 2007/10/03 08:55:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.31 2007/10/03 11:11:12 meskes Exp $ */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
@@ -25,31 +25,6 @@ enum ARRAY_TYPE
ECPG_ARRAY_ERROR, ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
};
/* Here are some methods used by the lib. */
/* Returns a pointer to a string containing a simple type name. */
void ECPGadd_mem(void *ptr, int lineno);
bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum COMPAT_MODE, bool);
#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
#endif
struct connection *ECPGget_connection(const char *);
char *ECPGalloc(long, int);
char *ECPGrealloc(void *, long, int);
void ECPGfree(void *);
bool ECPGinit(const struct connection *, const char *, const int);
char *ECPGstrdup(const char *, int);
const char *ECPGtype_name(enum ECPGttype);
int ECPGDynamicType(Oid);
void ECPGfree_auto_mem(void);
void ECPGclear_auto_mem(void);
struct descriptor *ecpggetdescp(int, char *);
/* A generic varchar type. */
struct ECPGgeneric_varchar
{
@@ -134,17 +109,45 @@ struct variable
struct variable *next;
};
struct descriptor *ECPGfind_desc(int line, const char *name);
/* Here are some methods used by the lib. */
bool ECPGstore_result(const PGresult *results, int act_field,
/* Returns a pointer to a string containing a simple type name. */
void ecpg_add_mem(void *ptr, int lineno);
bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum COMPAT_MODE, bool);
#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
#endif
struct connection *ecpg_get_connection(const char *);
char *ecpg_alloc(long, int);
char *ecpg_realloc(void *, long, int);
void ecpg_free(void *);
bool ecpg_init(const struct connection *, const char *, const int);
char *ecpg_strdup(const char *, int);
const char *ecpg_type_name(enum ECPGttype);
int ecpg_dynamic_type(Oid);
void ecpg_free_auto_mem(void);
void ecpg_clear_auto_mem(void);
struct descriptor *ecpggetdescp(int, char *);
struct descriptor *ecpg_find_desc(int line, const char *name);
bool ecpg_store_result(const PGresult *results, int act_field,
const struct statement * stmt, struct variable * var);
bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool);
bool ecpg_store_input(const int, const bool, const struct variable *, const char **, bool);
bool ECPGcheck_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
void ECPGraise(int line, int code, const char *sqlstate, const char *str);
void ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat);
char *ECPGprepared(const char *, struct connection *, int);
bool ECPGdeallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *conn);
bool ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
char *ecpg_prepared(const char *, struct connection *, int);
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *conn);
void ecpg_log(const char *format,...);
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t * sqlca);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.10 2007/10/03 08:55:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.11 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -10,19 +10,19 @@
#include "extern.h"
void
ECPGfree(void *ptr)
ecpg_free(void *ptr)
{
free(ptr);
}
char *
ECPGalloc(long size, int lineno)
ecpg_alloc(long size, int lineno)
{
char *new = (char *) calloc(1L, size);
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return NULL;
}
@@ -30,13 +30,13 @@ ECPGalloc(long size, int lineno)
}
char *
ECPGrealloc(void *ptr, long size, int lineno)
ecpg_realloc(void *ptr, long size, int lineno)
{
char *new = (char *) realloc(ptr, size);
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return NULL;
}
@@ -44,7 +44,7 @@ ECPGrealloc(void *ptr, long size, int lineno)
}
char *
ECPGstrdup(const char *string, int lineno)
ecpg_strdup(const char *string, int lineno)
{
char *new;
@@ -54,7 +54,7 @@ ECPGstrdup(const char *string, int lineno)
new = strdup(string);
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return NULL;
}
@@ -104,9 +104,9 @@ static struct auto_mem *auto_allocs = NULL;
#endif
void
ECPGadd_mem(void *ptr, int lineno)
ecpg_add_mem(void *ptr, int lineno)
{
struct auto_mem *am = (struct auto_mem *) ECPGalloc(sizeof(struct auto_mem), lineno);
struct auto_mem *am = (struct auto_mem *) ecpg_alloc(sizeof(struct auto_mem), lineno);
am->pointer = ptr;
am->next = get_auto_allocs();
@@ -125,15 +125,15 @@ ECPGfree_auto_mem(void)
{
struct auto_mem *act = am;
am = am->next;
ECPGfree(act->pointer);
ECPGfree(act);
ecpg_free(act->pointer);
ecpg_free(act);
} while(am);
set_auto_allocs(NULL);
}
}
void
ECPGclear_auto_mem(void)
ecpg_clear_auto_mem(void)
{
struct auto_mem *am = get_auto_allocs();
@@ -144,7 +144,7 @@ ECPGclear_auto_mem(void)
{
struct auto_mem *act = am;
am = am->next;
ECPGfree(act);
ecpg_free(act);
} while(am);
set_auto_allocs(NULL);
}

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.39 2007/10/03 08:55:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.40 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -95,20 +95,20 @@ static int simple_debug = 0;
static FILE *debugstream = NULL;
void
ECPGinit_sqlca(struct sqlca_t * sqlca)
ecpg_init_sqlca(struct sqlca_t * sqlca)
{
memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
}
bool
ECPGinit(const struct connection * con, const char *connection_name, const int lineno)
ecpg_init(const struct connection * con, const char *connection_name, const int lineno)
{
struct sqlca_t *sqlca = ECPGget_sqlca();
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
if (con == NULL)
{
ECPGraise(lineno, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
ecpg_raise(lineno, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
connection_name ? connection_name : "NULL");
return (false);
}
@@ -142,7 +142,7 @@ ECPGget_sqlca(void)
if (sqlca == NULL)
{
sqlca = malloc(sizeof(struct sqlca_t));
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
pthread_setspecific(sqlca_key, sqlca);
}
return (sqlca);
@@ -154,15 +154,15 @@ ECPGget_sqlca(void)
bool
ECPGstatus(int lineno, const char *connection_name)
{
struct connection *con = ECPGget_connection(connection_name);
struct connection *con = ecpg_get_connection(connection_name);
if (!ECPGinit(con, connection_name, lineno))
if (!ecpg_init(con, connection_name, lineno))
return (false);
/* are we connected? */
if (con->connection == NULL)
{
ECPGraise(lineno, ECPG_NOT_CONN, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, con->name);
ecpg_raise(lineno, ECPG_NOT_CONN, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, con->name);
return false;
}
@@ -173,12 +173,12 @@ bool
ECPGtrans(int lineno, const char *connection_name, const char *transaction)
{
PGresult *res;
struct connection *con = ECPGget_connection(connection_name);
struct connection *con = ecpg_get_connection(connection_name);
if (!ECPGinit(con, connection_name, lineno))
if (!ecpg_init(con, connection_name, lineno))
return (false);
ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con ? con->name : "(nil)");
ecpg_log("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con ? con->name : "(nil)");
/* if we have no connection we just simulate the command */
if (con && con->connection)
@@ -192,13 +192,13 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
if (con->committed && !con->autocommit && strncmp(transaction, "begin", 5) != 0 && strncmp(transaction, "start", 5) != 0)
{
res = PQexec(con->connection, "begin transaction");
if (!ECPGcheck_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
return FALSE;
PQclear(res);
}
res = PQexec(con->connection, transaction);
if (!ECPGcheck_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
return FALSE;
PQclear(res);
}
@@ -229,7 +229,7 @@ ECPGdebug(int n, FILE *dbgs)
debugstream = dbgs;
ECPGlog("ECPGdebug: set to %d\n", simple_debug);
ecpg_log("ECPGdebug: set to %d\n", simple_debug);
#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&debug_init_mutex);
@@ -237,7 +237,7 @@ ECPGdebug(int n, FILE *dbgs)
}
void
ECPGlog(const char *format,...)
ecpg_log(const char *format,...)
{
va_list ap;
struct sqlca_t *sqlca = ECPGget_sqlca();

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.21 2007/09/30 11:38:48 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.22 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -77,15 +77,15 @@ replace_variables(char **text, int lineno, bool questionmarks)
int buffersize = sizeof(int) * CHAR_BIT * 10 / 3; /* a rough guess of the size we need */
char *buffer, *newcopy;
if (!(buffer = (char *) ECPGalloc(buffersize, lineno)))
if (!(buffer = (char *) ecpg_alloc(buffersize, lineno)))
return false;
snprintf(buffer, buffersize, "$%d", counter++);
for (len=1; (*text)[ptr+len] && isvarchar((*text)[ptr+len]); len++);
if (!(newcopy = (char *) ECPGalloc(strlen(*text) - len + strlen(buffer) + 1, lineno)))
if (!(newcopy = (char *) ecpg_alloc(strlen(*text) - len + strlen(buffer) + 1, lineno)))
{
ECPGfree(buffer);
ecpg_free(buffer);
return false;
}
@@ -93,8 +93,8 @@ replace_variables(char **text, int lineno, bool questionmarks)
strcpy(newcopy + ptr, buffer);
strcat(newcopy, (*text) + ptr + len);
ECPGfree(*text);
ECPGfree(buffer);
ecpg_free(*text);
ecpg_free(buffer);
*text = newcopy;
@@ -117,9 +117,9 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
struct sqlca_t *sqlca = ECPGget_sqlca();
PGresult *query;
ECPGinit_sqlca(sqlca);
ecpg_init_sqlca(sqlca);
con = ECPGget_connection(connection_name);
con = ecpg_get_connection(connection_name);
/* check if we already have prepared this statement */
this = find_prepared_statement(name, con, &prev);
@@ -127,21 +127,21 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
return false;
/* allocate new statement */
this = (struct prepared_statement *) ECPGalloc(sizeof(struct prepared_statement), lineno);
this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno);
if (!this)
return false;
stmt = (struct statement *) ECPGalloc(sizeof(struct statement), lineno);
stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno);
if (!stmt)
{
ECPGfree(this);
ecpg_free(this);
return false;
}
/* create statement */
stmt->lineno = lineno;
stmt->connection = con;
stmt->command = ECPGstrdup(variable, lineno);
stmt->command = ecpg_strdup(variable, lineno);
stmt->inlist = stmt->outlist = NULL;
/* if we have C variables in our statment replace them with '?' */
@@ -153,15 +153,15 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
/* and finally really prepare the statement */
query = PQprepare(stmt->connection->connection, name, stmt->command, 0, NULL);
if (!ECPGcheck_PQresult(query, stmt->lineno, stmt->connection->connection, stmt->compat))
if (!ecpg_check_PQresult(query, stmt->lineno, stmt->connection->connection, stmt->compat))
{
ECPGfree(stmt->command);
ECPGfree(this);
ECPGfree(stmt);
ecpg_free(stmt->command);
ecpg_free(this);
ecpg_free(stmt);
return false;
}
ECPGlog("ECPGprepare line %d: NAME: %s QUERY: %s\n", stmt->lineno, name, stmt->command);
ecpg_log("ECPGprepare line %d: NAME: %s QUERY: %s\n", stmt->lineno, name, stmt->command);
PQclear(query);
this->prepared = true;
@@ -197,7 +197,7 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection *con, struct pr
{
bool r = false;
ECPGlog("ECPGdeallocate line %d: NAME: %s\n", lineno, this->name);
ecpg_log("ECPGdeallocate line %d: NAME: %s\n", lineno, this->name);
/* first deallocate the statement in the backend */
if (this->prepared)
@@ -205,13 +205,13 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection *con, struct pr
char *text;
PGresult *query;
text = (char *) ECPGalloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
text = (char *) ecpg_alloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
if (text)
{
sprintf(text, "deallocate \"%s\"", this->name);
query = PQexec(this->stmt->connection->connection, text);
ECPGfree(text);
if (ECPGcheck_PQresult(query, lineno, this->stmt->connection->connection, this->stmt->compat))
ecpg_free(text);
if (ecpg_check_PQresult(query, lineno, this->stmt->connection->connection, this->stmt->compat))
{
PQclear(query);
r = true;
@@ -225,19 +225,19 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection *con, struct pr
*/
if (!r && !INFORMIX_MODE(c))
{
ECPGraise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, this->name);
ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, this->name);
return false;
}
/* okay, free all the resources */
ECPGfree(this->stmt->command);
ECPGfree(this->stmt);
ecpg_free(this->stmt->command);
ecpg_free(this->stmt);
if (prev != NULL)
prev->next = this->next;
else
con->prep_stmts = this->next;
ECPGfree(this);
ecpg_free(this);
return true;
}
@@ -249,7 +249,7 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
struct prepared_statement *this,
*prev;
con = ECPGget_connection(connection_name);
con = ecpg_get_connection(connection_name);
this = find_prepared_statement(name, con, &prev);
if (this)
@@ -258,12 +258,12 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
/* prepared statement is not found */
if (INFORMIX_MODE(c))
return true;
ECPGraise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, name);
ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, name);
return false;
}
bool
ECPGdeallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *con)
ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *con)
{
/* deallocate all prepared statements */
while (con->prep_stmts)
@@ -278,11 +278,11 @@ ECPGdeallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *con)
bool
ECPGdeallocate_all(int lineno, int compat, const char *connection_name)
{
return ECPGdeallocate_all_conn(lineno, compat, ECPGget_connection(connection_name));
return ecpg_deallocate_all_conn(lineno, compat, ecpg_get_connection(connection_name));
}
char *
ECPGprepared(const char *name, struct connection *con, int lineno)
ecpg_prepared(const char *name, struct connection *con, int lineno)
{
struct prepared_statement *this;
this = find_prepared_statement(name, con, NULL);
@@ -293,7 +293,7 @@ ECPGprepared(const char *name, struct connection *con, int lineno)
char *
ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
{
return ECPGprepared(name, ECPGget_connection(connection_name), lineno);
return ecpg_prepared(name, ecpg_get_connection(connection_name), lineno);
}
/*
@@ -362,7 +362,7 @@ SearchStmtCache(const char *ecpgQuery)
* OR negative error code
*/
static int
ECPGfreeStmtCacheEntry(int entNo) /* entry # to free */
ecpg_freeStmtCacheEntry(int entNo) /* entry # to free */
{
stmtCacheEntry *entry;
PGresult *results;
@@ -373,13 +373,13 @@ ECPGfreeStmtCacheEntry(int entNo) /* entry # to free */
if(!entry->stmtID[0]) /* return if the entry isn't in use */
return(0);
con = ECPGget_connection(entry->connection);
con = ecpg_get_connection(entry->connection);
/* free the server resources for the statement */
ECPGlog("ECPGfreeStmtCacheEntry line %d: deallocate %s, cache entry #%d\n", entry->lineno, entry->stmtID, entNo);
ecpg_log("ecpg_freeStmtCacheEntry line %d: deallocate %s, cache entry #%d\n", entry->lineno, entry->stmtID, entNo);
sprintf(deallocText, "DEALLOCATE PREPARE %s", entry->stmtID);
results = PQexec(con->connection, deallocText);
if (!ECPGcheck_PQresult(results, entry->lineno, con->connection, ECPG_COMPAT_PGSQL))
if (!ecpg_check_PQresult(results, entry->lineno, con->connection, ECPG_COMPAT_PGSQL))
return(-1);
PQclear(results);
@@ -388,7 +388,7 @@ ECPGfreeStmtCacheEntry(int entNo) /* entry # to free */
/* free the memory used by the cache entry */
if(entry->ecpgQuery)
{
ECPGfree(entry->ecpgQuery);
ecpg_free(entry->ecpgQuery);
entry->ecpgQuery = 0;
}
@@ -429,13 +429,13 @@ AddStmtToCache(int lineno, /* line # of statement */
entNo = luEntNo; /* re-use the 'least used' entry */
/* 'entNo' is the entry to use - make sure its free */
if (ECPGfreeStmtCacheEntry(entNo) < 0)
if (ecpg_freeStmtCacheEntry(entNo) < 0)
return (-1);
/* add the query to the entry */
entry = &stmtCacheEntries[entNo];
entry->lineno = lineno;
entry->ecpgQuery = ECPGstrdup(ecpgQuery, lineno);
entry->ecpgQuery = ecpg_strdup(ecpgQuery, lineno);
entry->connection = (char *)connection;
entry->execs = 0;
memcpy(entry->stmtID, stmtID, sizeof(entry->stmtID));
@@ -445,7 +445,7 @@ AddStmtToCache(int lineno, /* line # of statement */
/* handle cache and preparation of statments in auto-prepare mode */
bool
ECPGauto_prepare(int lineno, const char *connection_name, const int questionmarks, char **name, const char *query)
ecpg_auto_prepare(int lineno, const char *connection_name, const int questionmarks, char **name, const char *query)
{
int entNo;
@@ -455,18 +455,18 @@ ECPGauto_prepare(int lineno, const char *connection_name, const int questionmark
/* if not found - add the statement to the cache */
if(entNo)
{
ECPGlog("ECPGauto_prepare line %d: stmt found in cache, entry %d\n", lineno, entNo);
*name = ECPGstrdup(stmtCacheEntries[entNo].stmtID, lineno);
ecpg_log("ecpg_auto_prepare line %d: stmt found in cache, entry %d\n", lineno, entNo);
*name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno);
}
else
{
ECPGlog("ECPGauto_prepare line %d: stmt not in cache; inserting\n", lineno);
ecpg_log("ecpg_auto_prepare line %d: stmt not in cache; inserting\n", lineno);
/* generate a statement ID */
*name = (char *) ECPGalloc(STMTID_SIZE, lineno);
*name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
sprintf(*name, "ecpg%d", nextStmtID++);
if (!ECPGprepare(lineno, connection_name, questionmarks, ECPGstrdup(*name, lineno), query))
if (!ECPGprepare(lineno, connection_name, questionmarks, ecpg_strdup(*name, lineno), query))
return(false);
if (AddStmtToCache(lineno, *name, connection_name, query) < 0)
return(false);

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.12 2007/02/02 09:31:10 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.13 2007/10/03 11:11:12 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -14,7 +14,7 @@
* This function is used to generate the correct type names.
*/
const char *
ECPGtype_name(enum ECPGttype typ)
ecpg_type_name(enum ECPGttype typ)
{
switch (typ)
{
@@ -67,7 +67,7 @@ ECPGtype_name(enum ECPGttype typ)
}
int
ECPGDynamicType(Oid type)
ecpg_dynamic_type(Oid type)
{
switch (type)
{