Commit 32a4c300 authored by Michael Meskes's avatar Michael Meskes

Added Christof's patches.

parent ebb93323
...@@ -1146,5 +1146,9 @@ Sun Oct 21 14:19:42 CEST 2001 ...@@ -1146,5 +1146,9 @@ Sun Oct 21 14:19:42 CEST 2001
Fri Nov 2 16:16:25 CET 2001 Fri Nov 2 16:16:25 CET 2001
- Synced preproc.y with gram.y. - Synced preproc.y with gram.y.
Wed Nov 14 11:50:27 CET 2001
- Added several patches by Christof Petig <christof.petig@wtal.de>.
- Set ecpg version to 2.9.0. - Set ecpg version to 2.9.0.
- Set library version to 3.3.0. - Set library version to 3.3.0.
descriptor statements have the following shortcomings descriptor statements have the following shortcomings
- up to now the only reasonable statement is - input descriptors (USING DESCRIPTOR <name>) are not supported
FETCH ... INTO SQL DESCRIPTOR <name>
no input variables allowed!
Reason: to fully support dynamic SQL the frontend/backend communication Reason: to fully support dynamic SQL the frontend/backend communication
should change to recognize input parameters. should change to recognize input parameters.
Since this is not likely to happen in the near future and you Since this is not likely to happen in the near future and you
can cover the same functionality with the existing infrastructure can cover the same functionality with the existing infrastructure
I'll leave the work to someone else. (using s[n]printf), I'll leave the work to someone else.
- string buffer overflow does not always generate warnings
(beware: terminating 0 may be missing because strncpy is used)
:var=data sets sqlwarn accordingly (but not indicator)
- char variables pointing to NULL are not allocated on demand
- string truncation does not show up in indicator
...@@ -67,6 +67,8 @@ void ECPGraise(int line, int code, const char *str); ...@@ -67,6 +67,8 @@ void ECPGraise(int line, int code, const char *str);
bool ECPGget_desc_header(int, char *, int *); bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...); bool ECPGget_desc(int, char *, int,...);
/* dynamic result allocation */
void ECPGfree_auto_mem(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.14 2001/10/31 04:49:44 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.15 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -12,7 +12,7 @@ static struct connection *all_connections = NULL, ...@@ -12,7 +12,7 @@ static struct connection *all_connections = NULL,
*actual_connection = NULL; *actual_connection = NULL;
struct connection * struct connection *
get_connection(const char *connection_name) ECPGget_connection(const char *connection_name)
{ {
struct connection *con = all_connections; struct connection *con = all_connections;
...@@ -63,10 +63,10 @@ ecpg_finish(struct connection * act) ...@@ -63,10 +63,10 @@ ecpg_finish(struct connection * act)
bool bool
ECPGsetcommit(int lineno, const char *mode, const char *connection_name) ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
{ {
struct connection *con = get_connection(connection_name); struct connection *con = ECPGget_connection(connection_name);
PGresult *results; PGresult *results;
if (!ecpg_init(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
return (false); return (false);
ECPGlog("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name); ECPGlog("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name);
...@@ -106,9 +106,9 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name) ...@@ -106,9 +106,9 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
bool bool
ECPGsetconn(int lineno, const char *connection_name) ECPGsetconn(int lineno, const char *connection_name)
{ {
struct connection *con = get_connection(connection_name); struct connection *con = ECPGget_connection(connection_name);
if (!ecpg_init(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
return (false); return (false);
actual_connection = con; actual_connection = con;
...@@ -269,9 +269,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, ...@@ -269,9 +269,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
*realname = NULL, *realname = NULL,
*options = NULL; *options = NULL;
init_sqlca(); ECPGinit_sqlca();
if ((this = (struct connection *) ecpg_alloc(sizeof(struct connection), lineno)) == NULL) if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
return false; return false;
if (dbname == NULL && connection_name == NULL) if (dbname == NULL && connection_name == NULL)
...@@ -393,9 +393,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, ...@@ -393,9 +393,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
/* add connection to our list */ /* add connection to our list */
if (connection_name != NULL) if (connection_name != NULL)
this->name = ecpg_strdup(connection_name, lineno); this->name = ECPGstrdup(connection_name, lineno);
else else
this->name = ecpg_strdup(realname, lineno); this->name = ECPGstrdup(realname, lineno);
this->cache_head = NULL; this->cache_head = NULL;
...@@ -465,7 +465,7 @@ ECPGdisconnect(int lineno, const char *connection_name) ...@@ -465,7 +465,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
if (strcmp(connection_name, "ALL") == 0) if (strcmp(connection_name, "ALL") == 0)
{ {
init_sqlca(); ECPGinit_sqlca();
for (con = all_connections; con;) for (con = all_connections; con;)
{ {
struct connection *f = con; struct connection *f = con;
...@@ -476,9 +476,9 @@ ECPGdisconnect(int lineno, const char *connection_name) ...@@ -476,9 +476,9 @@ ECPGdisconnect(int lineno, const char *connection_name)
} }
else else
{ {
con = get_connection(connection_name); con = ECPGget_connection(connection_name);
if (!ecpg_init(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
return (false); return (false);
else else
ecpg_finish(con); ecpg_finish(con);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.18 2001/11/05 17:46:37 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.19 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
#include "sqlca.h" #include "sqlca.h"
bool bool
get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
enum ECPGttype type, enum ECPGttype ind_type, enum ECPGttype type, enum ECPGttype ind_type,
void *var, void *ind, long varcharsize, long offset, void *var, void *ind, long varcharsize, long offset,
bool isarray) bool isarray)
{ {
char *pval = (char *) PQgetvalue(results, act_tuple, act_field); char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
ECPGlog("get_data line %d: RESULT: %s\n", lineno, pval ? pval : ""); ECPGlog("ECPGget_data line %d: RESULT: %s\n", lineno, pval ? pval : "");
/* pval is a pointer to the value */ /* pval is a pointer to the value */
/* let's check is it really is an array if it should be one */ /* let's check is it really is an array if it should be one */
......
/* dynamic SQL support routines /* dynamic SQL support routines
* *
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.18 2001/11/05 17:46:37 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.19 2001/11/14 11:11:49 meskes Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "pg_type.h"
#include "ecpgtype.h" #include "ecpgtype.h"
#include "ecpglib.h" #include "ecpglib.h"
...@@ -30,14 +31,16 @@ ECPGDynamicType_DDT(Oid type) ...@@ -30,14 +31,16 @@ ECPGDynamicType_DDT(Oid type)
{ {
switch (type) switch (type)
{ {
case 1082: case DATEOID:
return SQL3_DDT_DATE; /* date */ return SQL3_DDT_DATE;
case 1083: case TIMEOID:
return SQL3_DDT_TIME; /* time */ return SQL3_DDT_TIME;
case 1184: case TIMESTAMPOID:
return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE; /* datetime */ return SQL3_DDT_TIMESTAMP;
case 1296: case TIMESTAMPTZOID:
return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE; /* timestamp */ return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE;
case TIMETZOID:
return SQL3_DDT_TIME_WITH_TIME_ZONE;
default: default:
return SQL3_DDT_ILLEGAL; return SQL3_DDT_ILLEGAL;
} }
...@@ -139,11 +142,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -139,11 +142,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
va_list args; va_list args;
PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name); PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
enum ECPGdtype type; enum ECPGdtype type;
bool Indicator_seen = false,
Data_seen = false;
int ntuples, int ntuples,
act_tuple; act_tuple;
struct variable data_var;
va_start(args, index); va_start(args, index);
if (!ECPGresult) if (!ECPGresult)
return (false); return (false);
...@@ -165,7 +167,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -165,7 +167,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
--index; --index;
type = va_arg(args, enum ECPGdtype); type = va_arg(args, enum ECPGdtype);
memset (&data_var, 0, sizeof data_var);
data_var.type=ECPGt_EORT;
data_var.ind_type=ECPGt_NO_INDICATOR;
while (type != ECPGd_EODT) while (type != ECPGd_EODT)
{ {
char type_str[20]; char type_str[20];
...@@ -184,26 +190,27 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -184,26 +190,27 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
switch (type) switch (type)
{ {
case (ECPGd_indicator): case (ECPGd_indicator):
data_var.ind_type=vartype;
data_var.ind_pointer=var;
data_var.ind_varcharsize=varcharsize;
data_var.ind_arrsize=arrsize;
data_var.ind_offset=offset;
if (data_var.ind_arrsize == 0 || data_var.ind_varcharsize == 0)
data_var.ind_value = *((void **) (data_var.ind_pointer));
else
data_var.ind_value = data_var.ind_pointer;
break;
/* case ECPGd_data:
* this is like ECPGexecute missing : allocate arrays, data_var.type=vartype;
* perhaps this should go into a common function !! data_var.pointer=var;
*/ data_var.varcharsize=varcharsize;
if (ntuples > arrsize) data_var.arrsize=arrsize;
{ data_var.offset=offset;
ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", if (data_var.arrsize == 0 || data_var.varcharsize == 0)
lineno, ntuples, arrsize); data_var.value = *((void **) (data_var.pointer));
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); else
return false; data_var.value = data_var.pointer;
}
Indicator_seen = true;
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index)))
return (false);
var = (char *) var + offset;
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
break; break;
case ECPGd_name: case ECPGd_name:
...@@ -239,29 +246,6 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -239,29 +246,6 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16); ECPGlog("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
break; break;
case ECPGd_ret_length:
case ECPGd_ret_octet:
/*
* this is like ECPGexecute missing : allocate arrays,
* perhaps this should go into a common function !!
*/
if (ntuples > arrsize)
{
ECPGlog("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, NULL);
return false;
}
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
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));
}
break;
case ECPGd_octet: case ECPGd_octet:
if (!get_int_item(lineno, var, vartype, PQfsize(ECPGresult, index))) if (!get_int_item(lineno, var, vartype, PQfsize(ECPGresult, index)))
return (false); return (false);
...@@ -289,38 +273,45 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -289,38 +273,45 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index))); ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
break; break;
case ECPGd_data:
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
ECPGlog("ECPGget_desc: CARDINALITY = %d\n", PQntuples(ECPGresult));
break;
case ECPGd_ret_length:
case ECPGd_ret_octet:
/* /*
* this is like ECPGexecute missing : allocate arrays, * this is like ECPGstore_result
* perhaps this should go into a common function !!
*/ */
if (ntuples > arrsize) if (arrsize > 0 && ntuples > arrsize)
{ {
ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize); lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false; return false;
} }
Data_seen = true; /* allocate storage if needed */
if (arrsize == 0 && var != NULL && *(void**)var == NULL)
{
void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
*(void **)var = mem;
ECPGadd_mem(mem, lineno);
var = mem;
}
for (act_tuple = 0; act_tuple < ntuples; act_tuple++) for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{ {
if (PQgetisnull(ECPGresult, act_tuple, index)) if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
continue; /* do not touch data on null value */
if (!get_data(ECPGresult, act_tuple, index, lineno,
vartype, ECPGt_NO_INDICATOR, var, NULL,
varcharsize, offset, false))
return (false); return (false);
var = (char *) var + offset;
ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index));
} }
break; break;
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
ECPGlog("ECPGget_desc: CARDINALITY = %d\n", PQntuples(ECPGresult));
break;
default: default:
snprintf(type_str, sizeof(type_str), "%d", type); snprintf(type_str, sizeof(type_str), "%d", type);
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str); ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str);
...@@ -330,18 +321,45 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ...@@ -330,18 +321,45 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type = va_arg(args, enum ECPGdtype); type = va_arg(args, enum ECPGdtype);
} }
if (Data_seen && !Indicator_seen) if (data_var.type!=ECPGt_EORT)
{ {
struct statement stmt;
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);
}
else if (data_var.ind_type!=ECPGt_NO_INDICATOR)
{
/*
* this is like ECPGstore_result
* but since we don't have a data variable at hand, we can't call it
*/
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",
lineno, ntuples, data_var.ind_arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
/* allocate storage if needed */
if (data_var.ind_arrsize == 0 && data_var.ind_pointer != NULL && data_var.ind_value == NULL)
{
void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
*(void **)data_var.ind_pointer = mem;
ECPGadd_mem(mem, lineno);
data_var.ind_value = mem;
}
for (act_tuple = 0; act_tuple < ntuples; act_tuple++) for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{ {
if (PQgetisnull(ECPGresult, act_tuple, index)) if (!get_int_item(lineno, data_var.ind_value, data_var.ind_type, -PQgetisnull(ECPGresult, act_tuple, index)))
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
return (false); 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));
} }
} }
return (true); return (true);
} }
...@@ -369,10 +387,10 @@ ECPGdeallocate_desc(int line, const char *name) ...@@ -369,10 +387,10 @@ ECPGdeallocate_desc(int line, const char *name)
bool bool
ECPGallocate_desc(int line, const char *name) ECPGallocate_desc(int line, const char *name)
{ {
struct descriptor *new = (struct descriptor *) ecpg_alloc(sizeof(struct descriptor), line); struct descriptor *new = (struct descriptor *) ECPGalloc(sizeof(struct descriptor), line);
new->next = all_descriptors; new->next = all_descriptors;
new->name = ecpg_alloc(strlen(name) + 1, line); new->name = ECPGalloc(strlen(name) + 1, line);
new->result = PQmakeEmptyPGresult(NULL, 0); new->result = PQmakeEmptyPGresult(NULL, 0);
strcpy(new->name, name); strcpy(new->name, name);
all_descriptors = new; all_descriptors = new;
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.12 2001/10/18 20:32:58 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.13 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -154,7 +154,7 @@ ECPGraise(int line, int code, const char *str) ...@@ -154,7 +154,7 @@ ECPGraise(int line, int code, const char *str)
ECPGlog("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca.sqlerrm.sqlerrmc); ECPGlog("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca.sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */ /* free all memory we have allocated for the user */
free_auto_mem(); ECPGfree_auto_mem();
} }
/* print out an error message */ /* print out an error message */
......
This diff is collapsed.
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
/* Here are some methods used by the lib. */ /* Here are some methods used by the lib. */
/* Returns a pointer to a string containing a simple type name. */ /* Returns a pointer to a string containing a simple type name. */
void free_auto_mem(void); void ECPGadd_mem(void *ptr, int lineno);
bool get_data(const PGresult *, int, int, int, enum ECPGttype type,
bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, void *, void *, long, long, bool); enum ECPGttype, void *, void *, long, long, bool);
struct connection *get_connection(const char *); struct connection *ECPGget_connection(const char *);
void init_sqlca(void); void ECPGinit_sqlca(void);
char *ecpg_alloc(long, int); char *ECPGalloc(long, int);
bool ecpg_init(const struct connection *, const char *, const int); bool ECPGinit(const struct connection *, const char *, const int);
char *ecpg_strdup(const char *, int); char *ECPGstrdup(const char *, int);
const char *ECPGtype_name(enum ECPGttype); const char *ECPGtype_name(enum ECPGttype);
unsigned int ECPGDynamicType(Oid); unsigned int ECPGDynamicType(Oid);
...@@ -62,6 +63,23 @@ struct descriptor ...@@ -62,6 +63,23 @@ struct descriptor
struct descriptor *next; struct descriptor *next;
}; };
struct variable
{
enum ECPGttype type;
void *value;
void *pointer;
long varcharsize;
long arrsize;
long offset;
enum ECPGttype ind_type;
void *ind_value;
void *ind_pointer;
long ind_varcharsize;
long ind_arrsize;
long ind_offset;
struct variable *next;
};
PGresult ** PGresult **
ECPGdescriptor_lvalue(int line, const char *descriptor); ECPGdescriptor_lvalue(int line, const char *descriptor);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.7 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "extern.h" #include "extern.h"
char * char *
ecpg_alloc(long size, int lineno) ECPGalloc(long size, int lineno)
{ {
char *new = (char *) calloc(1L, size); char *new = (char *) calloc(1L, size);
...@@ -23,7 +23,7 @@ ecpg_alloc(long size, int lineno) ...@@ -23,7 +23,7 @@ ecpg_alloc(long size, int lineno)
} }
char * char *
ecpg_strdup(const char *string, int lineno) ECPGstrdup(const char *string, int lineno)
{ {
char *new = strdup(string); char *new = strdup(string);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.9 2001/10/30 05:38:56 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.10 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -40,15 +40,15 @@ static int simple_debug = 0; ...@@ -40,15 +40,15 @@ static int simple_debug = 0;
static FILE *debugstream = NULL; static FILE *debugstream = NULL;
void void
init_sqlca(void) ECPGinit_sqlca(void)
{ {
memcpy((char *) &sqlca, (char *) &sqlca_init, sizeof(sqlca)); memcpy((char *) &sqlca, (char *) &sqlca_init, sizeof(sqlca));
} }
bool bool
ecpg_init(const struct connection * con, const char *connection_name, const int lineno) ECPGinit(const struct connection * con, const char *connection_name, const int lineno)
{ {
init_sqlca(); ECPGinit_sqlca();
if (con == NULL) if (con == NULL)
{ {
ECPGraise(lineno, ECPG_NO_CONN, connection_name ? connection_name : "NULL"); ECPGraise(lineno, ECPG_NO_CONN, connection_name ? connection_name : "NULL");
...@@ -61,9 +61,9 @@ ecpg_init(const struct connection * con, const char *connection_name, const int ...@@ -61,9 +61,9 @@ ecpg_init(const struct connection * con, const char *connection_name, const int
bool bool
ECPGstatus(int lineno, const char *connection_name) ECPGstatus(int lineno, const char *connection_name)
{ {
struct connection *con = get_connection(connection_name); struct connection *con = ECPGget_connection(connection_name);
if (!ecpg_init(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
return (false); return (false);
/* are we connected? */ /* are we connected? */
...@@ -80,9 +80,9 @@ bool ...@@ -80,9 +80,9 @@ bool
ECPGtrans(int lineno, const char *connection_name, const char *transaction) ECPGtrans(int lineno, const char *connection_name, const char *transaction)
{ {
PGresult *res; PGresult *res;
struct connection *con = get_connection(connection_name); struct connection *con = ECPGget_connection(connection_name);
if (!ecpg_init(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
return (false); return (false);
ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con->name); ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con->name);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_type.h,v 1.5 2001/11/05 17:46:37 momjian Exp $ * $Id: pg_type.h,v 1.6 2001/11/14 11:11:49 meskes Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -62,7 +62,8 @@ ...@@ -62,7 +62,8 @@
#define VARCHAROID 1043 #define VARCHAROID 1043
#define DATEOID 1082 #define DATEOID 1082
#define TIMEOID 1083 #define TIMEOID 1083
#define TIMESTAMPOID 1184 #define TIMESTAMPOID 1114
#define TIMESTAMPTZOID 1184
#define INTERVALOID 1186 #define INTERVALOID 1186
#define TIMETZOID 1266 #define TIMETZOID 1266
#define ZPBITOID 1560 #define ZPBITOID 1560
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.10 2001/11/05 17:46:37 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.11 2001/11/14 11:11:49 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -69,11 +69,11 @@ ECPGprepare(int lineno, char *name, char *variable) ...@@ -69,11 +69,11 @@ ECPGprepare(int lineno, char *name, char *variable)
return false; return false;
} }
this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno); this = (struct prepared_statement *) ECPGalloc(sizeof(struct prepared_statement), lineno);
if (!this) if (!this)
return false; return false;
stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno); stmt = (struct statement *) ECPGalloc(sizeof(struct statement), lineno);
if (!stmt) if (!stmt)
{ {
free(this); free(this);
...@@ -83,14 +83,14 @@ ECPGprepare(int lineno, char *name, char *variable) ...@@ -83,14 +83,14 @@ ECPGprepare(int lineno, char *name, char *variable)
/* create statement */ /* create statement */
stmt->lineno = lineno; stmt->lineno = lineno;
stmt->connection = NULL; stmt->connection = NULL;
stmt->command = ecpg_strdup(variable, lineno); stmt->command = ECPGstrdup(variable, lineno);
stmt->inlist = stmt->outlist = NULL; stmt->inlist = stmt->outlist = NULL;
/* if we have C variables in our statment replace them with '?' */ /* if we have C variables in our statment replace them with '?' */
replace_variables(stmt->command); replace_variables(stmt->command);
/* add prepared statement to our list */ /* add prepared statement to our list */
this->name = ecpg_strdup(name, lineno); this->name = ECPGstrdup(name, lineno);
this->stmt = stmt; this->stmt = stmt;
if (prep_stmts == NULL) if (prep_stmts == NULL)
......
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.31 2001/08/11 10:52:09 petere Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.32 2001/11/14 11:11:49 meskes Exp $
subdir = src/interfaces/ecpg/test subdir = src/interfaces/ecpg/test
top_builddir = ../../../.. top_builddir = ../../../..
...@@ -8,7 +8,7 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS) ...@@ -8,7 +8,7 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS)
ECPG = ../preproc/ecpg -I$(srcdir)/../include ECPG = ../preproc/ecpg -I$(srcdir)/../include
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc
all: $(TESTS) all: $(TESTS)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
* *
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.8 2001/08/11 10:52:09 petere Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.9 2001/11/14 11:11:49 meskes Exp $
*/ */
#include <stdio.h> #include <stdio.h>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
* *
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.2 2001/08/11 10:52:09 petere Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.3 2001/11/14 11:11:49 meskes Exp $
*/ */
#include <stdio.h> #include <stdio.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment