1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

pgindent run.

This commit is contained in:
Bruce Momjian
2002-09-04 20:31:48 +00:00
parent c91ceec21d
commit e50f52a074
446 changed files with 14942 additions and 13363 deletions

View File

@@ -54,12 +54,12 @@
*/
#define ECPG_WARNING_QUERY_IGNORED -601
/* WARNING: PerformPortalClose: portal "*" not found */
#define ECPG_WARNING_UNKNOWN_PORTAL -602
#define ECPG_WARNING_UNKNOWN_PORTAL -602
/* WARNING: BEGIN: already a transaction in progress */
#define ECPG_WARNING_IN_TRANSACTION -603
#define ECPG_WARNING_IN_TRANSACTION -603
/* WARNING: AbortTransaction and not in in-progress state */
/* WARNING: COMMIT: no transaction in progress */
#define ECPG_WARNING_NO_TRANSACTION -604
#define ECPG_WARNING_NO_TRANSACTION -604
/* WARNING: BlankPortalAssignName: portal * already exists */
#define ECPG_WARNING_PORTAL_EXISTS -605

View File

@@ -68,8 +68,9 @@ bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...);
/* dynamic result allocation */
void ECPGfree_auto_mem(void);
void ECPGfree_auto_mem(void);
#ifdef __cplusplus
}
#endif

View File

@@ -76,4 +76,5 @@ enum ECPGdtype
#ifdef __cplusplus
}
#endif

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.18 2002/03/06 06:10:35 momjian Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.19 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -154,10 +154,10 @@ ECPGnoticeProcessor(void *arg, const char *message)
message++;
ECPGlog("WARNING: %s", message);
/* WARNING: (transaction aborted): queries ignored until END */
/* WARNING: (transaction aborted): queries ignored until END */
/*
* WARNING: current transaction is aborted, queries ignored until end
* WARNING: current transaction is aborted, queries ignored until end
* of transaction block
*/
if (strstr(message, "queries ignored") && strstr(message, "transaction")
@@ -167,7 +167,7 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
/* WARNING: PerformPortalClose: portal "*" not found */
/* WARNING: PerformPortalClose: portal "*" not found */
if ((!strncmp(message, "PerformPortalClose: portal", 26)
|| !strncmp(message, "PerformPortalFetch: portal", 26))
&& strstr(message + 26, "not found"))
@@ -176,16 +176,16 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
/* WARNING: BEGIN: already a transaction in progress */
/* WARNING: BEGIN: already a transaction in progress */
if (!strncmp(message, "BEGIN: already a transaction in progress", 40))
{
ECPGnoticeProcessor_raise(ECPG_WARNING_IN_TRANSACTION, message);
return;
}
/* WARNING: AbortTransaction and not in in-progress state */
/* WARNING: COMMIT: no transaction in progress */
/* WARNING: ROLLBACK: no transaction in progress */
/* WARNING: AbortTransaction and not in in-progress state */
/* WARNING: COMMIT: no transaction in progress */
/* WARNING: ROLLBACK: no transaction in progress */
if (!strncmp(message, "AbortTransaction and not in in-progress state", 45)
|| !strncmp(message, "COMMIT: no transaction in progress", 34)
|| !strncmp(message, "ROLLBACK: no transaction in progress", 36))
@@ -194,7 +194,7 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
/* WARNING: BlankPortalAssignName: portal * already exists */
/* WARNING: BlankPortalAssignName: portal * already exists */
if (!strncmp(message, "BlankPortalAssignName: portal", 29)
&& strstr(message + 29, "already exists"))
{
@@ -205,54 +205,54 @@ ECPGnoticeProcessor(void *arg, const char *message)
/* these are harmless - do nothing */
/*
* WARNING: CREATE TABLE / PRIMARY KEY will create implicit index '*'
* WARNING: CREATE TABLE / PRIMARY KEY will create implicit index '*'
* for table '*'
*/
/*
* WARNING: ALTER TABLE ... ADD CONSTRAINT will create implicit
* WARNING: ALTER TABLE ... ADD CONSTRAINT will create implicit
* trigger(s) for FOREIGN KEY check(s)
*/
/*
* WARNING: CREATE TABLE will create implicit sequence '*' for SERIAL
* WARNING: CREATE TABLE will create implicit sequence '*' for SERIAL
* column '*.*'
*/
/*
* WARNING: CREATE TABLE will create implicit trigger(s) for FOREIGN
* WARNING: CREATE TABLE will create implicit trigger(s) for FOREIGN
* KEY check(s)
*/
if ((!strncmp(message, "CREATE TABLE", 12) || !strncmp(message, "ALTER TABLE", 11))
&& strstr(message + 11, "will create implicit"))
return;
/* WARNING: QUERY PLAN: */
/* WARNING: QUERY PLAN: */
if (!strncmp(message, "QUERY PLAN:", 11)) /* do we really see these? */
return;
/*
* WARNING: DROP TABLE implicitly drops referential integrity trigger
* WARNING: DROP TABLE implicitly drops referential integrity trigger
* from table "*"
*/
if (!strncmp(message, "DROP TABLE implicitly drops", 27))
return;
/*
* WARNING: Caution: DROP INDEX cannot be rolled back, so don't abort
* WARNING: Caution: DROP INDEX cannot be rolled back, so don't abort
* now
*/
if (strstr(message, "cannot be rolled back"))
return;
/* these and other unmentioned should set sqlca.sqlwarn[2] */
/* WARNING: The ':' operator is deprecated. Use exp(x) instead. */
/* WARNING: Rel *: Uninitialized page 0 - fixing */
/* WARNING: PortalHeapMemoryFree: * not in alloc set! */
/* WARNING: Too old parent tuple found - can't continue vc_repair_frag */
/* WARNING: identifier "*" will be truncated to "*" */
/* WARNING: InvalidateSharedInvalid: cache state reset */
/* WARNING: RegisterSharedInvalid: SI buffer overflow */
/* WARNING: The ':' operator is deprecated. Use exp(x) instead. */
/* WARNING: Rel *: Uninitialized page 0 - fixing */
/* WARNING: PortalHeapMemoryFree: * not in alloc set! */
/* WARNING: Too old parent tuple found - can't continue vc_repair_frag */
/* WARNING: identifier "*" will be truncated to "*" */
/* WARNING: InvalidateSharedInvalid: cache state reset */
/* WARNING: RegisterSharedInvalid: SI buffer overflow */
sqlca.sqlwarn[2] = 'W';
sqlca.sqlwarn[0] = 'W';
}
@@ -388,9 +388,7 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
}
else
{
realname = strdup(dbname);
}
}
else
realname = strdup(dbname);

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.23 2002/01/08 23:34:47 tgl Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.24 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -13,9 +13,9 @@
bool
ECPGget_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, bool isarray)
enum ECPGttype type, enum ECPGttype ind_type,
char *var, char *ind, long varcharsize, long offset,
long ind_offset, bool isarray)
{
char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
@@ -54,23 +54,23 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
*((short *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
*((short *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
*((int *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
*((int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
*((long *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
*((long *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
/* ((long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
*((long long int *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
*((long long int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
/* case ECPGt_unsigned_long_long:
((unsigned long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);
@@ -118,15 +118,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_short:
/* ((short *) var)[act_tuple] = (short) res;*/
*((short *) (var + offset*act_tuple)) = (short) res;
*((short *) (var + offset * act_tuple)) = (short) res;
break;
case ECPGt_int:
/* ((int *) var)[act_tuple] = (int) res;*/
*((int *) (var + offset*act_tuple)) = (int) res;
*((int *) (var + offset * act_tuple)) = (int) res;
break;
case ECPGt_long:
/* ((long *) var)[act_tuple] = res;*/
*((long *) (var + offset*act_tuple)) = (long) res;
*((long *) (var + offset * act_tuple)) = (long) res;
break;
default:
/* Cannot happen */
@@ -154,15 +154,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_unsigned_short:
/* ((unsigned short *) var)[act_tuple] = (unsigned short) ures;*/
*((unsigned short *) (var + offset*act_tuple)) = (unsigned short) ures;
*((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
break;
case ECPGt_unsigned_int:
/* ((unsigned int *) var)[act_tuple] = (unsigned int) ures;*/
*((unsigned int *) (var + offset*act_tuple)) = (unsigned int) ures;
*((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
break;
case ECPGt_unsigned_long:
/* ((unsigned long *) var)[act_tuple] = ures;*/
*((unsigned long *) (var + offset*act_tuple)) = (unsigned long) ures;
*((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
break;
default:
/* Cannot happen */
@@ -176,7 +176,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (pval)
{
/* ((long long int *) var)[act_tuple] = strtoll(pval, &scan_length, 10);*/
*((long long int *) (var + offset*act_tuple)) = strtoll(pval, &scan_length, 10);
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0')) /* Garbage left */
{
@@ -186,7 +186,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
/* ((long long int *) var)[act_tuple] = (long long) 0;*/
*((long long int *) (var + offset*act_tuple)) = (long long) 0;
*((long long int *) (var + offset * act_tuple)) = (long long) 0;
break;
#endif /* HAVE_STRTOLL */
@@ -195,7 +195,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (pval)
{
/* ((unsigned long long int *) var)[act_tuple] = strtoull(pval, &scan_length, 10);*/
*((unsigned long long int *) (var + offset*act_tuple)) = strtoull(pval, &scan_length, 10);
*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0')) /* Garbage left */
{
@@ -205,7 +205,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
/* ((unsigned long long int *) var)[act_tuple] = (long long) 0;*/
*((unsigned long long int *) (var + offset*act_tuple)) = (long long) 0;
*((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
break;
#endif /* HAVE_STRTOULL */
@@ -237,11 +237,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_float:
/* ((float *) var)[act_tuple] = dres;*/
*((float *) (var + offset*act_tuple)) = dres;
*((float *) (var + offset * act_tuple)) = dres;
break;
case ECPGt_double:
/* ((double *) var)[act_tuple] = dres;*/
*((double *) (var + offset*act_tuple)) = dres;
*((double *) (var + offset * act_tuple)) = dres;
break;
default:
/* Cannot happen */
@@ -256,10 +256,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (offset == sizeof(char))
/* ((char *) var)[act_tuple] = false;*/
*((char *) (var + offset*act_tuple)) = false;
*((char *) (var + offset * act_tuple)) = false;
else if (offset == sizeof(int))
/* ((int *) var)[act_tuple] = false;*/
*((int *) (var + offset*act_tuple)) = false;
*((int *) (var + offset * act_tuple)) = false;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
break;
@@ -268,10 +268,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (offset == sizeof(char))
/* ((char *) var)[act_tuple] = true;*/
*((char *) (var + offset*act_tuple)) = true;
*((char *) (var + offset * act_tuple)) = true;
else if (offset == sizeof(int))
/* ((int *) var)[act_tuple] = true;*/
*((int *) (var + offset*act_tuple)) = true;
*((int *) (var + offset * act_tuple)) = true;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
break;
@@ -299,22 +299,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = strlen(pval);*/
*((short *) (ind + ind_offset*act_tuple)) = strlen(pval);
*((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = strlen(pval);*/
*((int *) (ind + ind_offset*act_tuple)) = strlen(pval);
*((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = strlen(pval);*/
*((long *) (ind + ind_offset*act_tuple)) = strlen(pval);
*((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset*act_tuple)) = strlen(pval);
*((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
#endif /* HAVE_LONG_LONG_INT_64 */
default:
@@ -344,22 +344,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = variable->len;*/
*((short *) (ind + offset*act_tuple)) = variable->len;
*((short *) (ind + offset * act_tuple)) = variable->len;
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = variable->len;*/
*((int *) (ind + offset*act_tuple)) = variable->len;
*((int *) (ind + offset * act_tuple)) = variable->len;
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = variable->len;*/
*((long *) (ind + offset*act_tuple)) = variable->len;
*((long *) (ind + offset * act_tuple)) = variable->len;
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset*act_tuple)) = variable->len;
*((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
break;
#endif /* HAVE_LONG_LONG_INT_64 */
default:

View File

@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.22 2002/01/23 16:34:06 meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.23 2002/09/04 20:31:46 momjian Exp $
*/
#include "postgres_fe.h"
@@ -58,7 +58,7 @@ ECPGget_desc_header(int lineno, char *desc_name, int *count)
return false;
*count = PQnfields(ECPGresult);
sqlca.sqlerrd[2]=1;
sqlca.sqlerrd[2] = 1;
ECPGlog("ECPGget_desc_header: found %d attributes.\n", *count);
return true;
}
@@ -149,7 +149,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
int ntuples,
act_tuple;
struct variable data_var;
va_start(args, index);
ECPGinit_sqlca();
ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
@@ -173,11 +173,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
--index;
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;
memset(&data_var, 0, sizeof data_var);
data_var.type = ECPGt_EORT;
data_var.ind_type = ECPGt_NO_INDICATOR;
while (type != ECPGd_EODT)
{
char type_str[20];
@@ -196,11 +196,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
switch (type)
{
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;
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
@@ -208,11 +208,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
break;
case ECPGd_data:
data_var.type=vartype;
data_var.pointer=var;
data_var.varcharsize=varcharsize;
data_var.arrsize=arrsize;
data_var.offset=offset;
data_var.type = vartype;
data_var.pointer = var;
data_var.varcharsize = varcharsize;
data_var.arrsize = arrsize;
data_var.offset = offset;
if (data_var.arrsize == 0 || data_var.varcharsize == 0)
data_var.value = *((void **) (data_var.pointer));
else
@@ -279,7 +279,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
break;
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
@@ -301,14 +301,15 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
return false;
}
/* allocate storage if needed */
if (arrsize == 0 && var != NULL && *(void**)var == NULL)
if (arrsize == 0 && var != NULL && *(void **) var == NULL)
{
void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
*(void **)var = mem;
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++)
{
if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
@@ -327,31 +328,31 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type = va_arg(args, enum ECPGdtype);
}
if (data_var.type!=ECPGt_EORT)
if (data_var.type != ECPGt_EORT)
{
struct statement stmt;
char *oldlocale;
char *oldlocale;
/* Make sure we do NOT honor the locale for numeric input */
/* since the database gives the standard decimal point */
oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
memset (&stmt, 0, sizeof stmt);
stmt.lineno=lineno;
memset(&stmt, 0, sizeof stmt);
stmt.lineno = lineno;
/* desparate try to guess something sensible */
stmt.connection=ECPGget_connection(NULL);
stmt.connection = ECPGget_connection(NULL);
ECPGstore_result(ECPGresult, index, &stmt, &data_var);
setlocale(LC_NUMERIC, oldlocale);
ECPGfree(oldlocale);
}
else if (data_var.ind_type!=ECPGt_NO_INDICATOR)
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
* 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)
{
@@ -363,8 +364,9 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
/* 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;
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;
}
@@ -376,7 +378,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
}
sqlca.sqlerrd[2]=ntuples;
sqlca.sqlerrd[2] = ntuples;
return (true);
}
@@ -409,16 +411,17 @@ ECPGallocate_desc(int line, const char *name)
ECPGinit_sqlca();
new = (struct descriptor *) ECPGalloc(sizeof(struct descriptor), line);
if (!new) return false;
if (!new)
return false;
new->next = all_descriptors;
new->name = ECPGalloc(strlen(name) + 1, line);
if (!new->name)
if (!new->name)
{
ECPGfree(new);
return false;
}
new->result = PQmakeEmptyPGresult(NULL, 0);
if (!new->result)
if (!new->result)
{
ECPGfree(new->name);
ECPGfree(new);

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.15 2002/01/07 02:29:15 petere Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.16 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -84,7 +84,7 @@ ECPGraise(int line, int code, const char *str)
case ECPG_ARRAY_INSERT:
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
"Trying to insert an array of variables in line %d.", line);
"Trying to insert an array of variables in line %d.", line);
break;
case ECPG_NO_CONN:

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.38 2002/07/20 08:24:18 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.39 2002/09/04 20:31:46 momjian Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -89,7 +89,7 @@ quote_postgres(char *arg, int lineno)
res[ri++] = '\'';
res[ri] = '\0';
return res;
}
@@ -168,7 +168,7 @@ create_statement(int lineno, struct connection * connection, struct statement **
var->next = NULL;
if (var->ind_type != ECPGt_NO_INDICATOR
&& (var->ind_arrsize == 0 || var->ind_varcharsize == 0))
&& (var->ind_arrsize == 0 || var->ind_varcharsize == 0))
var->ind_value = *((char **) (var->ind_pointer));
else
var->ind_value = var->ind_pointer;
@@ -390,14 +390,12 @@ ECPGstore_result(const PGresult *results, int act_field,
{
/* special mode for handling char**foo=0 */
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
len += strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
}
len *= var->offset; /* should be 1, but YMNK */
len += (ntuples+1) * sizeof(char *);
len += (ntuples + 1) * sizeof(char *);
ECPGlog("ECPGstore_result: line %d: allocating %d bytes for %d tuples (char**=0)",
stmt->lineno,len, ntuples);
stmt->lineno, len, ntuples);
}
else
{
@@ -405,7 +403,7 @@ ECPGstore_result(const PGresult *results, int act_field,
/* check strlen for each tuple */
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
if (len > var->varcharsize)
var->varcharsize = len;
@@ -427,31 +425,34 @@ ECPGstore_result(const PGresult *results, int act_field,
}
/* allocate indicator variable if needed */
if ((var->ind_arrsize == 0 || var->ind_varcharsize == 0) && var->ind_value == NULL && var->ind_pointer!=NULL)
if ((var->ind_arrsize == 0 || var->ind_varcharsize == 0) && var->ind_value == NULL && var->ind_pointer != NULL)
{
int len = var->ind_offset * ntuples;
int len = var->ind_offset * ntuples;
var->ind_value = (char *) ECPGalloc(len, stmt->lineno);
*((char **) var->ind_pointer) = var->ind_value;
ECPGadd_mem(var->ind_value, stmt->lineno);
}
/* fill the variable with the tuple(s) */
if (!var->varcharsize && !var->arrsize &&
(var->type==ECPGt_char || var->type==ECPGt_unsigned_char))
if (!var->varcharsize && !var->arrsize &&
(var->type == ECPGt_char || var->type == ECPGt_unsigned_char))
{
/* special mode for handling char**foo=0 */
/* filling the array of (char*)s */
char **current_string = (char**) var->value;
char **current_string = (char **) var->value;
/* storing the data (after the last array element) */
char *current_data_location = (char*) &current_string[ntuples+1];
char *current_data_location = (char *) &current_string[ntuples + 1];
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
{
int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
var->type, var->ind_type, current_data_location,
var->ind_value, len, 0, 0, isarray))
var->type, var->ind_type, current_data_location,
var->ind_value, len, 0, 0, isarray))
status = false;
else
{
@@ -460,7 +461,7 @@ ECPGstore_result(const PGresult *results, int act_field,
current_string++;
}
}
/* terminate the list */
*current_string = NULL;
}
@@ -469,8 +470,8 @@ ECPGstore_result(const PGresult *results, int act_field,
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
{
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
var->type, var->ind_type, var->value,
var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray))
var->type, var->ind_type, var->value,
var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray))
status = false;
}
}
@@ -484,9 +485,9 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
char *mallocedval = NULL;
char *newcopy = NULL;
/*
* arrays are not possible unless the attribute is an array too
* FIXME: we do not know if the attribute is an array here
/*
* arrays are not possible unless the attribute is an array too FIXME:
* we do not know if the attribute is an array here
*/
/* if (var->arrsize > 1 && ...)
@@ -494,7 +495,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL);
return false;
}*/
/*
* Some special treatment is needed for records since we want their
* contents to arrive in a comma-separated list on insert (I think).
@@ -1116,7 +1117,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
/* initialize auto_mem struct */
ECPGclear_auto_mem();
status = ECPGexecute(stmt);
free_statement(stmt);

View File

@@ -6,7 +6,7 @@
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, bool);
enum ECPGttype, char *, char *, long, long, long, bool);
struct connection *ECPGget_connection(const char *);
void ECPGinit_sqlca(void);
char *ECPGalloc(long, int);

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.8 2001/12/23 12:17:41 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.9 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -53,6 +53,7 @@ void
ECPGadd_mem(void *ptr, int lineno)
{
struct auto_mem *am = (struct auto_mem *) ECPGalloc(sizeof(struct auto_mem), lineno);
am->pointer = ptr;
am->next = auto_allocs;
auto_allocs = am;

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.12 2002/01/18 15:51:00 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.13 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -90,8 +90,10 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
/* if we have no connection we just simulate the command */
if (con && con->connection)
{
/* if we are not in autocommit mode, already have committed
* the transaction and get another commit, just ignore it */
/*
* if we are not in autocommit mode, already have committed the
* transaction and get another commit, just ignore it
*/
if (!con->committed || con->autocommit)
{
if ((res = PQexec(con->connection, transaction)) == NULL)

View File

@@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.56 2002/04/28 17:20:03 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.57 2002/09/04 20:31:46 momjian Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -32,7 +32,7 @@ help(const char *progname)
/* printf is a macro some places; don't #ifdef inside its arguments */
#ifdef YYDEBUG
printf("Usage:\n"
" %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
" %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
progname);
#else
printf("Usage:\n"
@@ -61,7 +61,7 @@ add_include_path(char *path)
include_paths = mm_alloc(sizeof(struct _include_path));
include_paths->path = path;
include_paths->next = ip;
}
static void

View File

@@ -18,7 +18,8 @@ extern char *descriptor_index;
extern char *descriptor_name;
extern char *connection;
extern char *input_filename;
extern char *yytext, *token_start,
extern char *yytext,
*token_start,
errortext[128];
#ifdef YYDEBUG

View File

@@ -26,7 +26,7 @@ mm_strdup(const char *string)
if (new == NULL)
mmerror(OUT_OF_MEMORY, ET_FATAL, "Out of memory\n");
return new;
}
@@ -183,7 +183,7 @@ get_type(enum ECPGttype type)
/* Dump a type.
The type is dumped as:
type-tag <comma> - enum ECPGttype
reference-to-variable <comma> - char *
reference-to-variable <comma> - char *
size <comma> - long size of this field (if varchar)
arrsize <comma> - long number of elements in the arr
offset <comma> - offset to the next element
@@ -208,7 +208,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
case ECPGt_array:
if (indicator_set && ind_type->type != ECPGt_array)
mmerror(INDICATOR_NOT_ARRAY, ET_FATAL, "Indicator for array/pointer has to be array/pointer.\n");
switch (type->u.element->type)
{
case ECPGt_array:
@@ -223,7 +223,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
ECPGdump_a_simple(o, name, type->u.element->type,
type->u.element->size, type->size, NULL, prefix);
type->u.element->size, type->size, NULL, prefix);
if (ind_type != NULL)
{
if (ind_type->type == ECPGt_NO_INDICATOR)
@@ -325,7 +325,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use the pointer except for arrays with given
* bounds
*/
if (arrsize > 0 && siz== NULL)
if (arrsize > 0 && siz == NULL)
sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
@@ -376,24 +376,22 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
else
sprintf(pbuf, "%s%s->", prefix ? prefix : "", name);
prefix = pbuf;
if (ind_type == &ecpg_no_indicator)
{
ind_p = &struct_no_indicator;
}
else if (ind_type != NULL)
{
if (arrsiz == 1)
sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
else
sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name);
ind_prefix = ind_pbuf;
ind_p = ind_type->u.members;
}
for (p = type->u.members; p; p = p->next)
{
ECPGdump_a_type(o, p->name, p->type, (ind_p != NULL) ? ind_p->name : NULL, (ind_p != NULL) ? ind_p->type : NULL, prefix, ind_prefix, arrsiz, type->struct_sizeof, (ind_p != NULL) ? ind_type->struct_sizeof : NULL);

View File

@@ -14,7 +14,8 @@ struct ECPGtype
long size; /* For array it is the number of elements.
* For varchar it is the maxsize of the
* area. */
char *struct_sizeof; /* For a struct this is the sizeof() type as string */
char *struct_sizeof; /* For a struct this is the sizeof() type
* as string */
union
{
struct ECPGtype *element; /* For an array this is the type
@@ -90,7 +91,7 @@ struct this_type
char *type_str;
int type_dimension;
int type_index;
char * type_sizeof;
char *type_sizeof;
};
struct _include_path

View File

@@ -242,7 +242,7 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
list->indicator->name, list->indicator->type, NULL, NULL, 0, NULL, NULL);
list->indicator->name, list->indicator->type, NULL, NULL, 0, NULL, NULL);
/* Then release the list element. */
if (mode != 0)
@@ -318,16 +318,17 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
*dimension = type_dimension;
}
if (pointer_len>2)
{ snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d",pointer_len);
mmerror(PARSE_ERROR, ET_FATAL, errortext);
if (pointer_len > 2)
{
snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d", pointer_len);
mmerror(PARSE_ERROR, ET_FATAL, errortext);
/* mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
}
if (pointer_len>1 && type_enum!=ECPGt_char && type_enum!=ECPGt_unsigned_char)
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
mmerror(PARSE_ERROR, ET_FATAL, "No pointer to pointer supported for this type");
if (pointer_len>1 && (*length >= 0 || *dimension >= 0))
if (pointer_len > 1 && (*length >= 0 || *dimension >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (*length >= 0 && *dimension >= 0 && pointer_len)
@@ -364,14 +365,14 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
case ECPGt_char:
case ECPGt_unsigned_char:
/* char ** */
if (pointer_len==2)
if (pointer_len == 2)
{
*length = *dimension = 0;
break;
}
/* pointer has to get length 0 */
if (pointer_len==1)
if (pointer_len == 1)
*length = 0;
/* one index is the string length */