1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

pgindent run for 9.0

This commit is contained in:
Bruce Momjian
2010-02-26 02:01:40 +00:00
parent 16040575a0
commit 65e806cba1
403 changed files with 6786 additions and 6530 deletions

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.63 2010/01/26 09:07:31 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.64 2010/02/26 02:01:29 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -767,7 +767,7 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
size_t fmt_len = strlen(fmt);
size_t temp_len;
int i,
j, /* position in temp */
j, /* position in temp */
k,
dotpos;
int leftalign = 0,

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.49 2010/02/04 09:41:34 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.50 2010/02/26 02:01:29 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -26,7 +26,7 @@ array_delimiter(enum ARRAY_TYPE isarray, char c)
if (isarray == ECPG_ARRAY_VECTOR && c == ' ')
return true;
return false;
}
@@ -39,7 +39,7 @@ array_boundary(enum ARRAY_TYPE isarray, char c)
if (isarray == ECPG_ARRAY_VECTOR && c == '\0')
return true;
return false;
}
@@ -86,7 +86,7 @@ static double
get_float8_nan(void)
{
#ifdef NAN
return (double) NAN;
return (double) NAN;
#else
return (double) (0.0 / 0.0);
#endif
@@ -142,11 +142,11 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ecpg_log("ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, ECPG_IS_ARRAY(isarray) ? "yes" : "no");
/* pval is a pointer to the value */
if (!pval)
if (!pval)
{
/*
* This should never happen because we already checked that we
* found at least one tuple, but let's play it safe.
* This should never happen because we already checked that we found
* at least one tuple, but let's play it safe.
*/
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
return (false);
@@ -365,7 +365,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long_long:
*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
|| (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ecpg_raise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
@@ -449,14 +449,16 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_char:
case ECPGt_string:
{
char *str = (char *) (var + offset * act_tuple);
char *str = (char *) (var + offset * act_tuple);
if (varcharsize == 0 || varcharsize > size)
{
strncpy(str, pval, size + 1);
/* do the rtrim() */
if (type == ECPGt_string)
{
char *last = str + size;
char *last = str + size;
while (last > str && (*last == ' ' || *last == '\0'))
{
*last = '\0';
@@ -564,8 +566,8 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (INFORMIX_MODE(compat))
{
/*
* Informix wants its own NULL value here
* instead of an error
* Informix wants its own NULL value here instead
* of an error
*/
nres = PGTYPESnumeric_new();
if (nres)
@@ -573,14 +575,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else
{
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY,
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
return (false);
}
}
else
{
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -593,7 +595,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
free(nres);
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -622,8 +624,8 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (INFORMIX_MODE(compat))
{
/*
* Informix wants its own NULL value here
* instead of an error
* Informix wants its own NULL value here instead
* of an error
*/
ires = (interval *) ecpg_alloc(sizeof(interval), lineno);
if (!ires)
@@ -634,7 +636,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else
{
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -647,7 +649,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
free(ires);
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -672,15 +674,15 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (INFORMIX_MODE(compat))
{
/*
* Informix wants its own NULL value here
* instead of an error
* Informix wants its own NULL value here instead
* of an error
*/
ECPGset_noind_null(ECPGt_date, &ddres);
}
else
{
ecpg_raise(lineno, ECPG_DATE_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -692,7 +694,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
ecpg_raise(lineno, ECPG_DATE_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -716,15 +718,15 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (INFORMIX_MODE(compat))
{
/*
* Informix wants its own NULL value here
* instead of an error
* Informix wants its own NULL value here instead
* of an error
*/
ECPGset_noind_null(ECPGt_timestamp, &tres);
}
else
{
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -736,7 +738,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
}
@@ -760,7 +762,11 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
++act_tuple;
/* set pval to the next entry */
/* *pval != '\0' should not be needed, but is used as a safety guard */
/*
* *pval != '\0' should not be needed, but is used as a safety
* guard
*/
for (; *pval != '\0' && (string || (!array_delimiter(isarray, *pval) && !array_boundary(isarray, *pval))); ++pval)
if (*pval == '"')
string = string ? false : true;

View File

@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.35 2010/01/15 13:19:12 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.36 2010/02/26 02:01:30 momjian Exp $
*/
#define POSTGRES_ECPG_INTERNAL
@@ -382,6 +382,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
case ECPGd_ret_octet:
RETURN_IF_NO_DATA;
/*
* this is like ECPGstore_result
*/
@@ -485,6 +486,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
sqlca->sqlerrd[2] = ntuples;
return (true);
}
#undef RETURN_IF_NO_DATA
bool
@@ -729,7 +731,7 @@ ecpg_find_desc(int line, const char *name)
}
bool
ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name, ...)
ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name,...)
{
bool ret = false;
struct connection *con;
@@ -748,7 +750,7 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
if (!con)
{
ecpg_raise(line, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
connection_name ? connection_name : ecpg_gettext("NULL"));
connection_name ? connection_name : ecpg_gettext("NULL"));
return ret;
}
prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
@@ -762,8 +764,10 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
for (;;)
{
enum ECPGttype type, dummy_type;
void *ptr, *dummy_ptr;
enum ECPGttype type,
dummy_type;
void *ptr,
*dummy_ptr;
long dummy;
/* variable type */
@@ -772,7 +776,7 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
if (type == ECPGt_EORT)
break;
/* rest of variable parameters*/
/* rest of variable parameters */
ptr = va_arg(args, void *);
dummy = va_arg(args, long);
dummy = va_arg(args, long);
@@ -788,84 +792,84 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
switch (type)
{
case ECPGt_descriptor:
{
char *name = ptr;
struct descriptor *desc = ecpg_find_desc(line, name);
{
char *name = ptr;
struct descriptor *desc = ecpg_find_desc(line, name);
if (desc == NULL)
if (desc == NULL)
break;
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
if (desc->result != NULL)
PQclear(desc->result);
desc->result = res;
ret = true;
break;
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
if (desc->result != NULL)
PQclear(desc->result);
desc->result = res;
ret = true;
break;
}
}
case ECPGt_sqlda:
{
if (INFORMIX_MODE(compat))
{
struct sqlda_compat **_sqlda = ptr;
struct sqlda_compat *sqlda;
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
sqlda = ecpg_build_compat_sqlda(line, res, -1, compat);
if (sqlda)
if (INFORMIX_MODE(compat))
{
struct sqlda_compat *sqlda_old = *_sqlda;
struct sqlda_compat *sqlda_old1;
struct sqlda_compat **_sqlda = ptr;
struct sqlda_compat *sqlda;
while (sqlda_old)
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
sqlda = ecpg_build_compat_sqlda(line, res, -1, compat);
if (sqlda)
{
sqlda_old1 = sqlda_old->desc_next;
free(sqlda_old);
sqlda_old = sqlda_old1;
struct sqlda_compat *sqlda_old = *_sqlda;
struct sqlda_compat *sqlda_old1;
while (sqlda_old)
{
sqlda_old1 = sqlda_old->desc_next;
free(sqlda_old);
sqlda_old = sqlda_old1;
}
*_sqlda = sqlda;
ret = true;
}
*_sqlda = sqlda;
ret = true;
PQclear(res);
}
PQclear(res);
}
else
{
struct sqlda_struct **_sqlda = ptr;
struct sqlda_struct *sqlda;
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
sqlda = ecpg_build_native_sqlda(line, res, -1, compat);
if (sqlda)
else
{
struct sqlda_struct *sqlda_old = *_sqlda;
struct sqlda_struct *sqlda_old1;
struct sqlda_struct **_sqlda = ptr;
struct sqlda_struct *sqlda;
while (sqlda_old)
res = PQdescribePrepared(con->connection, stmt_name);
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
sqlda = ecpg_build_native_sqlda(line, res, -1, compat);
if (sqlda)
{
sqlda_old1 = sqlda_old->desc_next;
free(sqlda_old);
sqlda_old = sqlda_old1;
struct sqlda_struct *sqlda_old = *_sqlda;
struct sqlda_struct *sqlda_old1;
while (sqlda_old)
{
sqlda_old1 = sqlda_old->desc_next;
free(sqlda_old);
sqlda_old = sqlda_old1;
}
*_sqlda = sqlda;
ret = true;
}
*_sqlda = sqlda;
ret = true;
PQclear(res);
}
PQclear(res);
break;
}
break;
}
default:
/* nothing else may come */
;

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.94 2010/02/16 18:41:23 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.95 2010/02/26 02:01:30 momjian Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -505,8 +505,8 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
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 0
if (var->arrsize > 1 &&...)
@@ -1213,9 +1213,9 @@ ecpg_execute(struct statement * stmt)
{
if (INFORMIX_MODE(stmt->compat))
{
struct sqlda_compat *sqlda = *(struct sqlda_compat **)var->pointer;
struct variable desc_inlist;
int i;
struct sqlda_compat *sqlda = *(struct sqlda_compat **) var->pointer;
struct variable desc_inlist;
int i;
if (sqlda == NULL)
return false;
@@ -1268,9 +1268,9 @@ ecpg_execute(struct statement * stmt)
}
else
{
struct sqlda_struct *sqlda = *(struct sqlda_struct **)var->pointer;
struct variable desc_inlist;
int i;
struct sqlda_struct *sqlda = *(struct sqlda_struct **) var->pointer;
struct variable desc_inlist;
int i;
if (sqlda == NULL)
return false;
@@ -1508,12 +1508,15 @@ ecpg_execute(struct statement * stmt)
{
if (INFORMIX_MODE(stmt->compat))
{
struct sqlda_compat **_sqlda = (struct sqlda_compat **)var->pointer;
struct sqlda_compat *sqlda = *_sqlda;
struct sqlda_compat *sqlda_new;
int i;
struct sqlda_compat **_sqlda = (struct sqlda_compat **) var->pointer;
struct sqlda_compat *sqlda = *_sqlda;
struct sqlda_compat *sqlda_new;
int i;
/* If we are passed in a previously existing sqlda (chain) then free it. */
/*
* If we are passed in a previously existing sqlda (chain)
* then free it.
*/
while (sqlda)
{
sqlda_new = sqlda->desc_next;
@@ -1523,7 +1526,10 @@ ecpg_execute(struct statement * stmt)
*_sqlda = sqlda = sqlda_new = NULL;
for (i = ntuples - 1; i >= 0; i--)
{
/* Build a new sqlda structure. Note that only fetching 1 record is supported */
/*
* Build a new sqlda structure. Note that only
* fetching 1 record is supported
*/
sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, results, i, stmt->compat);
if (!sqlda_new)
@@ -1549,7 +1555,7 @@ ecpg_execute(struct statement * stmt)
ecpg_set_compat_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
stmt->lineno, PQnfields(results));
stmt->lineno, PQnfields(results));
sqlda_new->desc_next = sqlda;
sqlda = sqlda_new;
@@ -1558,12 +1564,15 @@ ecpg_execute(struct statement * stmt)
}
else
{
struct sqlda_struct **_sqlda = (struct sqlda_struct **)var->pointer;
struct sqlda_struct *sqlda = *_sqlda;
struct sqlda_struct *sqlda_new;
int i;
struct sqlda_struct **_sqlda = (struct sqlda_struct **) var->pointer;
struct sqlda_struct *sqlda = *_sqlda;
struct sqlda_struct *sqlda_new;
int i;
/* If we are passed in a previously existing sqlda (chain) then free it. */
/*
* If we are passed in a previously existing sqlda (chain)
* then free it.
*/
while (sqlda)
{
sqlda_new = sqlda->desc_next;
@@ -1573,7 +1582,10 @@ ecpg_execute(struct statement * stmt)
*_sqlda = sqlda = sqlda_new = NULL;
for (i = ntuples - 1; i >= 0; i--)
{
/* Build a new sqlda structure. Note that only fetching 1 record is supported */
/*
* Build a new sqlda structure. Note that only
* fetching 1 record is supported
*/
sqlda_new = ecpg_build_native_sqlda(stmt->lineno, results, i, stmt->compat);
if (!sqlda_new)
@@ -1599,7 +1611,7 @@ ecpg_execute(struct statement * stmt)
ecpg_set_native_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
stmt->lineno, PQnfields(results));
stmt->lineno, PQnfields(results));
sqlda_new->desc_next = sqlda;
sqlda = sqlda_new;

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.38 2010/02/04 09:41:34 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.39 2010/02/26 02:01:30 momjian Exp $ */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
@@ -151,7 +151,7 @@ struct descriptor *ecpggetdescp(int, char *);
struct descriptor *ecpg_find_desc(int line, const char *name);
struct prepared_statement *ecpg_find_prepared_statement(const char *,
struct connection *, struct prepared_statement **);
struct connection *, struct prepared_statement **);
bool ecpg_store_result(const PGresult *results, int act_field,
const struct statement * stmt, struct variable * var);

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.55 2010/02/02 16:09:11 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.56 2010/02/26 02:01:30 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -176,7 +176,8 @@ ECPGtransactionStatus(const char *connection_name)
const struct connection *con;
con = ecpg_get_connection(connection_name);
if (con == NULL) {
if (con == NULL)
{
/* transaction status is unknown */
return PQTRANS_UNKNOWN;
}
@@ -503,15 +504,14 @@ ecpg_gettext(const char *msgid)
return dgettext(PG_TEXTDOMAIN("ecpg"), msgid);
}
#endif /* ENABLE_NLS */
static struct var_list
{
int number;
int number;
void *pointer;
struct var_list *next;
} *ivlist = NULL;
} *ivlist = NULL;
void
ECPGset_var(int number, void *pointer, int lineno)
@@ -533,6 +533,7 @@ ECPGset_var(int number, void *pointer, int lineno)
if (!ptr)
{
struct sqlca_t *sqlca = ECPGget_sqlca();
sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
@@ -555,5 +556,5 @@ ECPGget_var(int number)
struct var_list *ptr;
for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
return (ptr) ? ptr->pointer : NULL;
return (ptr) ? ptr->pointer : NULL;
}

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.36 2010/01/22 14:19:27 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.37 2010/02/26 02:01:30 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -100,7 +100,7 @@ replace_variables(char **text, int lineno)
}
static bool
prepare_common(int lineno, struct connection *con, const bool questionmarks, const char *name, const char *variable)
prepare_common(int lineno, struct connection * con, const bool questionmarks, const char *name, const char *variable)
{
struct statement *stmt;
struct prepared_statement *this;
@@ -414,7 +414,7 @@ ecpg_freeStmtCacheEntry(int lineno, int compat, int entNo) /* entry # to free *
*/
static int
AddStmtToCache(int lineno, /* line # of statement */
const char *stmtID, /* statement ID */
const char *stmtID, /* statement ID */
const char *connection, /* connection */
int compat, /* compatibility level */
const char *ecpgQuery) /* query */
@@ -491,7 +491,7 @@ ecpg_auto_prepare(int lineno, const char *connection_name, const int compat, cha
}
else
{
char stmtID[STMTID_SIZE];
char stmtID[STMTID_SIZE];
ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno);

View File

@@ -23,7 +23,7 @@
/*
* Compute the next variable's offset with
* the current variable's size and alignment.
*
*
*
* Returns:
* - the current variable's offset in *current
@@ -44,9 +44,9 @@ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, l
static long
sqlda_compat_empty_size(const PGresult *res)
{
long offset;
int i;
int sqld = PQnfields(res);
long offset;
int i;
int sqld = PQnfields(res);
/* Initial size to store main structure and field structures */
offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
@@ -64,14 +64,15 @@ sqlda_compat_empty_size(const PGresult *res)
static long
sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
{
int sqld = PQnfields(res);
int i;
long next_offset;
int sqld = PQnfields(res);
int i;
long next_offset;
/* Add space for the field values */
for (i = 0; i < sqld; i++)
{
enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
switch (type)
{
case ECPGt_short:
@@ -103,16 +104,17 @@ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, l
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
break;
case ECPGt_numeric:
/*
* Let's align both the numeric struct and the digits array to int
* Unfortunately we need to do double work here to compute the size
* of the space needed for the numeric structure.
* Let's align both the numeric struct and the digits array to
* int Unfortunately we need to do double work here to compute
* the size of the space needed for the numeric structure.
*/
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
if (!PQgetisnull(res, row, i))
{
char *val = PQgetvalue(res, row, i);
numeric *num;
numeric *num;
num = PGTYPESnumeric_from_asc(val, NULL);
if (!num)
@@ -134,11 +136,12 @@ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, l
case ECPGt_unsigned_char:
case ECPGt_string:
default:
{
long datalen = strlen(PQgetvalue(res, row, i)) + 1;
ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
break;
}
{
long datalen = strlen(PQgetvalue(res, row, i)) + 1;
ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
break;
}
}
offset = next_offset;
}
@@ -149,7 +152,7 @@ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, l
static long
sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
{
long offset;
long offset;
offset = sqlda_compat_empty_size(res);
@@ -163,8 +166,8 @@ sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
static long
sqlda_native_empty_size(const PGresult *res)
{
long offset;
int sqld = PQnfields(res);
long offset;
int sqld = PQnfields(res);
/* Initial size to store main structure and field structures */
offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
@@ -178,7 +181,7 @@ sqlda_native_empty_size(const PGresult *res)
static long
sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
{
long offset;
long offset;
offset = sqlda_native_empty_size(res);
@@ -201,22 +204,22 @@ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
struct sqlvar_compat *sqlvar;
char *fname;
long size;
int sqld;
int i;
int sqld;
int i;
size = sqlda_compat_total_size(res, row, compat);
sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
sqlda = (struct sqlda_compat *) ecpg_alloc(size, line);
if (!sqlda)
return NULL;
memset(sqlda, 0, size);
sqlvar = (struct sqlvar_compat *)(sqlda + 1);
sqlvar = (struct sqlvar_compat *) (sqlda + 1);
sqld = PQnfields(res);
fname = (char *)(sqlvar + sqld);
fname = (char *) (sqlvar + sqld);
sqlda->sqld = sqld;
ecpg_log("ecpg_build_compat_sqlda on line %d sqld = %d\n", line, sqld);
sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
sqlda->sqlvar = sqlvar;
for (i = 0; i < sqlda->sqld; i++)
@@ -225,7 +228,7 @@ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
strcpy(fname, PQfname(res, i));
sqlda->sqlvar[i].sqlname = fname;
fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
sqlda->sqlvar[i].sqlformat = (char *) (long) PQfformat(res, i);
sqlda->sqlvar[i].sqlxid = PQftype(res, i);
sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
}
@@ -236,15 +239,16 @@ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
/*
* Sets values from PGresult.
*/
static int2 value_is_null = -1;
static int2 value_is_not_null = 0;
static int2 value_is_null = -1;
static int2 value_is_not_null = 0;
void
ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
ecpg_set_compat_sqlda(int lineno, struct sqlda_compat ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
{
struct sqlda_compat *sqlda = (*_sqlda);
int i;
long offset, next_offset;
int i;
long offset,
next_offset;
if (row < 0)
return;
@@ -257,106 +261,106 @@ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *
*/
for (i = 0; i < sqlda->sqld; i++)
{
int isnull;
int datalen;
bool set_data = true;
int isnull;
int datalen;
bool set_data = true;
switch (sqlda->sqlvar[i].sqltype)
{
case ECPGt_short:
case ECPGt_unsigned_short:
ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(short);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(int);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(long);
break;
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(long long);
break;
case ECPGt_bool:
ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(bool);
break;
case ECPGt_float:
ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(float);
break;
case ECPGt_double:
ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(double);
break;
case ECPGt_decimal:
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(decimal);
break;
case ECPGt_numeric:
{
numeric *num;
char *val;
set_data = false;
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(numeric);
if (PQgetisnull(res, row, i))
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
numeric *num;
char *val;
set_data = false;
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(numeric);
if (PQgetisnull(res, row, i))
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
val = PQgetvalue(res, row, i);
num = PGTYPESnumeric_from_asc(val, NULL);
if (!num)
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);
((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
PGTYPESnumeric_free(num);
break;
}
val = PQgetvalue(res, row, i);
num = PGTYPESnumeric_from_asc(val, NULL);
if (!num)
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
PGTYPESnumeric_free(num);
break;
}
case ECPGt_date:
ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(date);
break;
case ECPGt_timestamp:
ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(timestamp);
break;
case ECPGt_interval:
ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(interval);
break;
case ECPGt_char:
@@ -365,7 +369,7 @@ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *
default:
datalen = strlen(PQgetvalue(res, row, i)) + 1;
ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = datalen;
if (datalen > 32768)
sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
@@ -381,9 +385,9 @@ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *
{
if (set_data)
ecpg_get_data(res, row, i, lineno,
sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
ECPG_ARRAY_NONE, compat, false);
sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
ECPG_ARRAY_NONE, compat, false);
}
else
ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
@@ -397,10 +401,10 @@ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
{
struct sqlda_struct *sqlda;
long size;
int i;
int i;
size = sqlda_native_total_size(res, row, compat);
sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
sqlda = (struct sqlda_struct *) ecpg_alloc(size, line);
if (!sqlda)
return NULL;
@@ -425,11 +429,12 @@ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
}
void
ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
ecpg_set_native_sqlda(int lineno, struct sqlda_struct ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
{
struct sqlda_struct *sqlda = (*_sqlda);
int i;
long offset, next_offset;
int i;
long offset,
next_offset;
if (row < 0)
return;
@@ -442,106 +447,106 @@ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *
*/
for (i = 0; i < sqlda->sqld; i++)
{
int isnull;
int datalen;
bool set_data = true;
int isnull;
int datalen;
bool set_data = true;
switch (sqlda->sqlvar[i].sqltype)
{
case ECPGt_short:
case ECPGt_unsigned_short:
ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(short);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(int);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(long);
break;
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(long long);
break;
case ECPGt_bool:
ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(bool);
break;
case ECPGt_float:
ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(float);
break;
case ECPGt_double:
ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(double);
break;
case ECPGt_decimal:
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(decimal);
break;
case ECPGt_numeric:
{
numeric *num;
char *val;
set_data = false;
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(numeric);
if (PQgetisnull(res, row, i))
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
numeric *num;
char *val;
set_data = false;
ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(numeric);
if (PQgetisnull(res, row, i))
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
val = PQgetvalue(res, row, i);
num = PGTYPESnumeric_from_asc(val, NULL);
if (!num)
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);
((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
PGTYPESnumeric_free(num);
break;
}
val = PQgetvalue(res, row, i);
num = PGTYPESnumeric_from_asc(val, NULL);
if (!num)
{
ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
break;
}
memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
PGTYPESnumeric_free(num);
break;
}
case ECPGt_date:
ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(date);
break;
case ECPGt_timestamp:
ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(timestamp);
break;
case ECPGt_interval:
ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = sizeof(interval);
break;
case ECPGt_char:
@@ -550,7 +555,7 @@ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *
default:
datalen = strlen(PQgetvalue(res, row, i)) + 1;
ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
sqlda->sqlvar[i].sqllen = datalen;
break;
}
@@ -562,9 +567,9 @@ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *
{
if (set_data)
ecpg_get_data(res, row, i, lineno,
sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
ECPG_ARRAY_NONE, compat, false);
sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
ECPG_ARRAY_NONE, compat, false);
}
offset = next_offset;

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.18 2010/01/13 09:06:51 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.19 2010/02/26 02:01:30 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -136,7 +136,7 @@ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
#ifdef HAVE_LONG_INT_64
return ECPGt_long;
#endif
/* Unhandled types always return a string */
/* Unhandled types always return a string */
default:
return ECPGt_char;
}

View File

@@ -1,6 +1,6 @@
/*
* This file contains stuff needed to be as compatible to Informix as possible.
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.23 2009/08/14 13:28:22 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.24 2010/02/26 02:01:31 momjian Exp $
*/
#ifndef _ECPG_INFORMIX_H
#define _ECPG_INFORMIX_H
@@ -34,7 +34,7 @@ extern "C"
#endif
extern int rdatestr(date, char *);
extern void rtoday(date *);
extern void rtoday(date *);
extern int rjulmdy(date, short *);
extern int rdefmtdate(date *, char *, char *);
extern int rfmtdate(date, char *, char *);
@@ -49,7 +49,7 @@ extern int rsetnull(int, char *);
extern int rtypalign(int, int);
extern int rtypmsize(int, int);
extern int rtypwidth(int, int);
extern void rupshift(char *);
extern void rupshift(char *);
extern int byleng(char *, int);
extern void ldchar(char *, int, char *);

View File

@@ -1,7 +1,7 @@
/*
* this is a small part of c.h since we don't want to leak all postgres
* definitions into ecpg programs
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.82 2010/01/26 09:07:31 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.83 2010/02/26 02:01:31 momjian Exp $
*/
#ifndef _ECPGLIB_H
@@ -83,7 +83,7 @@ bool ECPGset_desc(int, const char *, int,...);
void ECPGset_noind_null(enum ECPGttype, void *);
bool ECPGis_noind_null(enum ECPGttype, void *);
bool ECPGdescribe(int, int, bool, const char *, const char *, ...);
bool ECPGdescribe(int, int, bool, const char *, const char *,...);
void ECPGset_var(int, void *, int);
void *ECPGget_var(int number);

View File

@@ -5,7 +5,7 @@
* All types that can be handled for host variable declarations has to
* be handled eventually.
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.39 2010/01/05 16:38:23 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.40 2010/02/26 02:01:31 momjian Exp $
*/
/*
@@ -63,7 +63,7 @@ enum ECPGttype
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR, /* no indicator */
ECPGt_string, /* trimmed (char *) type */
ECPGt_sqlda /* C struct descriptor */
ECPGt_sqlda /* C struct descriptor */
};
/* descriptor items */

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.15 2010/01/07 04:53:35 tgl Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.16 2010/02/26 02:01:31 momjian Exp $ */
#ifndef PGTYPES_INTERVAL
#define PGTYPES_INTERVAL
@@ -23,7 +23,6 @@ typedef long long int int64;
#ifdef USE_INTEGER_DATETIMES
#define HAVE_INT64_TIMESTAMP
#endif
#endif /* C_H */
typedef struct

View File

@@ -7,41 +7,41 @@
struct sqlvar_compat
{
short sqltype; /* variable type */
int sqllen; /* length in bytes */
char *sqldata; /* pointer to data */
short *sqlind; /* pointer to indicator */
char *sqlname; /* variable name */
char *sqlformat; /* reserved for future use */
short sqlitype; /* ind variable type */
short sqlilen; /* ind length in bytes */
char *sqlidata; /* ind data pointer */
int sqlxid; /* extended id type */
char *sqltypename; /* extended type name */
short sqltypelen; /* length of extended type name */
short sqlownerlen; /* length of owner name */
short sqlsourcetype; /* source type for distinct of built-ins */
char *sqlownername; /* owner name */
int sqlsourceid; /* extended id of source type */
short sqltype; /* variable type */
int sqllen; /* length in bytes */
char *sqldata; /* pointer to data */
short *sqlind; /* pointer to indicator */
char *sqlname; /* variable name */
char *sqlformat; /* reserved for future use */
short sqlitype; /* ind variable type */
short sqlilen; /* ind length in bytes */
char *sqlidata; /* ind data pointer */
int sqlxid; /* extended id type */
char *sqltypename; /* extended type name */
short sqltypelen; /* length of extended type name */
short sqlownerlen; /* length of owner name */
short sqlsourcetype; /* source type for distinct of built-ins */
char *sqlownername; /* owner name */
int sqlsourceid; /* extended id of source type */
/*
* sqlilongdata is new. It supports data that exceeds the 32k
* limit. sqlilen and sqlidata are for backward compatibility
* and they have maximum value of <32K.
* sqlilongdata is new. It supports data that exceeds the 32k limit.
* sqlilen and sqlidata are for backward compatibility and they have
* maximum value of <32K.
*/
char *sqlilongdata; /* for data field beyond 32K */
int sqlflags; /* for internal use only */
void *sqlreserved; /* reserved for future use */
char *sqlilongdata; /* for data field beyond 32K */
int sqlflags; /* for internal use only */
void *sqlreserved; /* reserved for future use */
};
struct sqlda_compat
{
short sqld;
struct sqlvar_compat *sqlvar;
char desc_name[19]; /* descriptor name */
short desc_occ; /* size of sqlda structure */
struct sqlda_compat *desc_next; /* pointer to next sqlda struct */
void *reserved; /* reserved for future use */
char desc_name[19]; /* descriptor name */
short desc_occ; /* size of sqlda structure */
struct sqlda_compat *desc_next; /* pointer to next sqlda struct */
void *reserved; /* reserved for future use */
};
#endif /* ECPG_SQLDA_COMPAT_H */
#endif /* ECPG_SQLDA_COMPAT_H */

View File

@@ -1,5 +1,5 @@
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda-native.h,v 1.2 2010/01/06 15:10:21 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda-native.h,v 1.3 2010/02/26 02:01:31 momjian Exp $
*/
#ifndef ECPG_SQLDA_NATIVE_H
@@ -11,7 +11,7 @@
* because the length must include a trailing zero byte.
*
* This should be at least as much as NAMEDATALEN of the database the
* applications run against.
* applications run against.
*/
#define NAMEDATALEN 64
@@ -37,7 +37,7 @@ struct sqlda_struct
short sqln;
short sqld;
struct sqlda_struct *desc_next;
struct sqlvar_struct sqlvar[1];
struct sqlvar_struct sqlvar[1];
};
#endif /* ECPG_SQLDA_NATIVE_H */
#endif /* ECPG_SQLDA_NATIVE_H */

View File

@@ -4,15 +4,13 @@
#ifdef _ECPG_INFORMIX_H
#include "sqlda-compat.h"
typedef struct sqlvar_compat sqlvar_t;
typedef struct sqlda_compat sqlda_t;
typedef struct sqlvar_compat sqlvar_t;
typedef struct sqlda_compat sqlda_t;
#else
#include "sqlda-native.h"
typedef struct sqlvar_struct sqlvar_t;
typedef struct sqlda_struct sqlda_t;
typedef struct sqlvar_struct sqlvar_t;
typedef struct sqlda_struct sqlda_t;
#endif
#endif /* ECPG_SQLDA_H */
#endif /* ECPG_SQLDA_H */

View File

@@ -32,26 +32,26 @@
/*
* Values used in sqlda->sqlvar[i]->sqltype
*/
#define SQLCHAR ECPGt_char
#define SQLSMINT ECPGt_short
#define SQLINT ECPGt_int
#define SQLFLOAT ECPGt_double
#define SQLSMFLOAT ECPGt_float
#define SQLDECIMAL ECPGt_decimal
#define SQLSERIAL ECPGt_int
#define SQLDATE ECPGt_date
#define SQLDTIME ECPGt_timestamp
#define SQLTEXT ECPGt_char
#define SQLVCHAR ECPGt_char
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
#define SQLCHAR ECPGt_char
#define SQLSMINT ECPGt_short
#define SQLINT ECPGt_int
#define SQLFLOAT ECPGt_double
#define SQLSMFLOAT ECPGt_float
#define SQLDECIMAL ECPGt_decimal
#define SQLSERIAL ECPGt_int
#define SQLDATE ECPGt_date
#define SQLDTIME ECPGt_timestamp
#define SQLTEXT ECPGt_char
#define SQLVCHAR ECPGt_char
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
#ifdef HAVE_LONG_LONG_INT_64
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
#define SQLINT8 ECPGt_long
#define SQLSERIAL8 ECPGt_long
#define SQLINT8 ECPGt_long
#define SQLSERIAL8 ECPGt_long
#endif
#endif /* ndef ECPG_SQLTYPES_H */

View File

@@ -3,7 +3,7 @@
* c_keywords.c
* lexical token lookup for reserved words in postgres embedded SQL
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.24 2009/07/14 20:24:10 tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.25 2010/02/26 02:01:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,7 +57,7 @@ static const ScanKeyword ScanCKeywords[] = {
/*
* Do a binary search using plain strcmp() comparison. This is much like
* Do a binary search using plain strcmp() comparison. This is much like
* ScanKeywordLookup(), except we want case-sensitive matching.
*/
const ScanKeyword *

View File

@@ -1,7 +1,7 @@
/*
* functions needed for descriptor handling
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.30 2010/01/26 09:07:31 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.31 2010/02/26 02:01:31 momjian Exp $
*
* since descriptor might be either a string constant or a string var
* we need to check for a constant if we expect a constant
@@ -344,4 +344,3 @@ sqlda_variable(const char *name)
return p;
}

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.113 2010/01/26 09:07:31 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.114 2010/02/26 02:01:31 momjian Exp $ */
/* Main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* Copyright (c) 1996-2010, PostgreSQL Global Development Group */
@@ -419,7 +419,10 @@ main(int argc, char *const argv[])
/* and structure member lists */
memset(struct_member_list, 0, sizeof(struct_member_list));
/* and our variable counter for out of scope cursors' variables */
/*
* and our variable counter for out of scope cursors'
* variables
*/
ecpg_internal_var = 0;
/* finally the actual connection */

View File

@@ -1,5 +1,5 @@
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.52 2010/01/26 09:07:31 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.53 2010/02/26 02:01:31 momjian Exp $
*/
#ifndef _ECPG_PREPROC_TYPE_H
#define _ECPG_PREPROC_TYPE_H
@@ -17,7 +17,8 @@ struct ECPGstruct_member
struct ECPGtype
{
enum ECPGttype type;
char *type_name; /* For struct and union types it is the struct name */
char *type_name; /* For struct and union types it is the struct
* name */
char *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

View File

@@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.52 2010/01/26 09:07:31 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.53 2010/02/26 02:01:31 momjian Exp $ */
#include "postgres_fe.h"
@@ -404,8 +404,9 @@ add_variable_to_tail(struct arguments ** list, struct variable * var, struct var
void
remove_variable_from_list(struct arguments ** list, struct variable * var)
{
struct arguments *p, *prev = NULL;
bool found = false;
struct arguments *p,
*prev = NULL;
bool found = false;
for (p = *list; p; p = p->next)
{

View File

@@ -1,18 +1,20 @@
struct mytype {
int id;
char t[64];
double d1; /* dec_t */
double d2;
char c[30];
struct mytype
{
int id;
char t[64];
double d1; /* dec_t */
double d2;
char c[30];
};
typedef struct mytype MYTYPE;
struct mynulltype {
int id;
int t;
int d1;
int d2;
int c;
struct mynulltype
{
int id;
int t;
int d1;
int d2;
int c;
};
typedef struct mynulltype MYNULLTYPE;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.387 2010/02/17 04:19:41 tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.388 2010/02/26 02:01:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -228,7 +228,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
#endif
{"replication", NULL, NULL, NULL,
"Replication", "D", 5},
"Replication", "D", 5},
/* Terminating entry --- MUST BE LAST */
{NULL, NULL, NULL, NULL,
@@ -268,8 +268,8 @@ static void closePGconn(PGconn *conn);
static PQconninfoOption *conninfo_parse(const char *conninfo,
PQExpBuffer errorMessage, bool use_defaults);
static PQconninfoOption *conninfo_array_parse(const char **keywords,
const char **values, PQExpBuffer errorMessage,
bool use_defaults, int expand_dbname);
const char **values, PQExpBuffer errorMessage,
bool use_defaults, int expand_dbname);
static char *conninfo_getval(PQconninfoOption *connOptions,
const char *keyword);
static void defaultNoticeReceiver(void *arg, const PGresult *res);
@@ -277,10 +277,10 @@ static void defaultNoticeProcessor(void *arg, const char *message);
static int parseServiceInfo(PQconninfoOption *options,
PQExpBuffer errorMessage);
static int parseServiceFile(const char *serviceFile,
const char *service,
PQconninfoOption *options,
PQExpBuffer errorMessage,
bool *group_found);
const char *service,
PQconninfoOption *options,
PQExpBuffer errorMessage,
bool *group_found);
static char *pwdfMatchesString(char *buf, char *token);
static char *PasswordFromFile(char *hostname, char *port, char *dbname,
char *username);
@@ -306,7 +306,7 @@ pgthreadlock_t pg_g_threadlock = default_threadlock;
* terminated arrays instead.
*
* To connect in an asynchronous (non-blocking) manner, use the functions
* PQconnectStart or PQconnectStartParams (which differ in the same way as
* PQconnectStart or PQconnectStartParams (which differ in the same way as
* PQconnectdb and PQconnectdbParams) and PQconnectPoll.
*
* Internally, the static functions connectDBStart, connectDBComplete
@@ -406,8 +406,8 @@ PQconnectStartParams(const char **keywords,
const char **values,
int expand_dbname)
{
PGconn *conn;
PQconninfoOption *connOptions;
PGconn *conn;
PQconninfoOption *connOptions;
/*
* Allocate memory for the conn structure
@@ -432,7 +432,7 @@ PQconnectStartParams(const char **keywords,
/*
* Move option values into conn structure
*/
fillPGconn(conn, connOptions);
fillPGconn(conn, connOptions);
/*
* Free the option info - all is in conn now
@@ -609,7 +609,7 @@ connectOptions1(PGconn *conn, const char *conninfo)
/*
* Move option values into conn structure
*/
fillPGconn(conn, connOptions);
fillPGconn(conn, connOptions);
/*
* Free the option info - all is in conn now
@@ -1326,9 +1326,9 @@ keep_going: /* We will come back to here until there is
* We have three methods of blocking SIGPIPE during
* send() calls to this socket:
*
* - setsockopt(sock, SO_NOSIGPIPE)
* - send(sock, ..., MSG_NOSIGNAL)
* - setting the signal mask to SIG_IGN during send()
* - setsockopt(sock, SO_NOSIGPIPE)
* - send(sock, ..., MSG_NOSIGNAL)
* - setting the signal mask to SIG_IGN during send()
*
* The third method requires three syscalls per send,
* so we prefer either of the first two, but they are
@@ -1350,7 +1350,7 @@ keep_going: /* We will come back to here until there is
conn->sigpipe_flag = true;
#else
conn->sigpipe_flag = false;
#endif /* MSG_NOSIGNAL */
#endif /* MSG_NOSIGNAL */
#ifdef SO_NOSIGPIPE
optval = 1;
@@ -1360,7 +1360,7 @@ keep_going: /* We will come back to here until there is
conn->sigpipe_so = true;
conn->sigpipe_flag = false;
}
#endif /* SO_NOSIGPIPE */
#endif /* SO_NOSIGPIPE */
/*
* Start/make connection. This should not block, since we
@@ -2034,7 +2034,7 @@ keep_going: /* We will come back to here until there is
/*
* If we tried to send application_name, check to see
* if the error is about that --- pre-9.0 servers will
* reject it at this stage of the process. If so,
* reject it at this stage of the process. If so,
* close the connection and retry without sending
* application_name. We could possibly get a false
* SQLSTATE match here and retry uselessly, but there
@@ -2124,7 +2124,7 @@ keep_going: /* We will come back to here until there is
default:
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("invalid connection state %d, "
"probably indicative of memory corruption\n"),
"probably indicative of memory corruption\n"),
conn->status);
goto error_return;
}
@@ -3266,6 +3266,7 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
return status;
next_file:
/*
* This could be used by any application so we can't use the binary
* location to find our config files.
@@ -3284,7 +3285,7 @@ last_file:
if (!group_found)
{
printfPQExpBuffer(errorMessage,
libpq_gettext("definition of service \"%s\" not found\n"), service);
libpq_gettext("definition of service \"%s\" not found\n"), service);
return 3;
}
@@ -3297,7 +3298,7 @@ parseServiceFile(const char *serviceFile,
PQconninfoOption *options,
PQExpBuffer errorMessage,
bool *group_found)
{
{
int linenr = 0,
i;
FILE *f;
@@ -3320,7 +3321,7 @@ parseServiceFile(const char *serviceFile,
{
fclose(f);
printfPQExpBuffer(errorMessage,
libpq_gettext("line %d too long in service file \"%s\"\n"),
libpq_gettext("line %d too long in service file \"%s\"\n"),
linenr,
serviceFile);
return 2;
@@ -3359,8 +3360,7 @@ parseServiceFile(const char *serviceFile,
if (*group_found)
{
/*
* Finally, we are in the right group and can parse
* the line
* Finally, we are in the right group and can parse the line
*/
char *key,
*val;
@@ -3745,20 +3745,20 @@ conninfo_array_parse(const char **keywords, const char **values,
PQExpBuffer errorMessage, bool use_defaults,
int expand_dbname)
{
char *tmp;
PQconninfoOption *options;
PQconninfoOption *str_options = NULL;
PQconninfoOption *option;
int i = 0;
char *tmp;
PQconninfoOption *options;
PQconninfoOption *str_options = NULL;
PQconninfoOption *option;
int i = 0;
/*
* If expand_dbname is non-zero, check keyword "dbname"
* to see if val is actually a conninfo string
* If expand_dbname is non-zero, check keyword "dbname" to see if val is
* actually a conninfo string
*/
while(expand_dbname && keywords[i])
while (expand_dbname && keywords[i])
{
const char *pname = keywords[i];
const char *pvalue = values[i];
const char *pvalue = values[i];
/* first find "dbname" if any */
if (strcmp(pname, "dbname") == 0)
@@ -3767,10 +3767,9 @@ conninfo_array_parse(const char **keywords, const char **values,
if (pvalue && strchr(pvalue, '='))
{
/*
* Must be a conninfo string, so parse it, but do not
* use defaults here -- those get picked up later.
* We only want to override for those parameters actually
* passed.
* Must be a conninfo string, so parse it, but do not use
* defaults here -- those get picked up later. We only want to
* override for those parameters actually passed.
*/
str_options = conninfo_parse(pvalue, errorMessage, false);
if (str_options == NULL)
@@ -3793,10 +3792,10 @@ conninfo_array_parse(const char **keywords, const char **values,
i = 0;
/* Parse the keywords/values arrays */
while(keywords[i])
while (keywords[i])
{
const char *pname = keywords[i];
const char *pvalue = values[i];
const char *pvalue = values[i];
if (pvalue != NULL)
{
@@ -3811,7 +3810,7 @@ conninfo_array_parse(const char **keywords, const char **values,
if (option->keyword == NULL)
{
printfPQExpBuffer(errorMessage,
libpq_gettext("invalid connection option \"%s\"\n"),
libpq_gettext("invalid connection option \"%s\"\n"),
pname);
PQconninfoFree(options);
return NULL;
@@ -3819,8 +3818,8 @@ conninfo_array_parse(const char **keywords, const char **values,
/*
* If we are on the dbname parameter, and we have a parsed
* conninfo string, copy those parameters across, overriding
* any existing previous settings
* conninfo string, copy those parameters across, overriding any
* existing previous settings
*/
if (strcmp(pname, "dbname") == 0 && str_options)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.210 2010/02/17 04:19:41 tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.211 2010/02/26 02:01:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3070,13 +3070,13 @@ static char *
PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
{
const char *s;
char *result;
char *rp;
int num_quotes = 0; /* single or double, depending on as_ident */
int num_backslashes = 0;
int input_len;
int result_size;
char quote_char = as_ident ? '"' : '\'';
char *result;
char *rp;
int num_quotes = 0; /* single or double, depending on as_ident */
int num_backslashes = 0;
int input_len;
int result_size;
char quote_char = as_ident ? '"' : '\'';
/* We must have a connection, else fail immediately. */
if (!conn)
@@ -3091,7 +3091,7 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
++num_backslashes;
else if (IS_HIGHBIT_SET(*s))
{
int charlen;
int charlen;
/* Slow path for possible multibyte characters */
charlen = pg_encoding_mblen(conn->client_encoding, s);
@@ -3111,7 +3111,7 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
/* Allocate output buffer. */
input_len = s - str;
result_size = input_len + num_quotes + 3; /* two quotes, plus a NUL */
result_size = input_len + num_quotes + 3; /* two quotes, plus a NUL */
if (!as_ident && num_backslashes > 0)
result_size += num_backslashes + 2;
result = rp = (char *) malloc(result_size);
@@ -3125,7 +3125,7 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
/*
* If we are escaping a literal that contains backslashes, we use the
* escape string syntax so that the result is correct under either value
* of standard_conforming_strings. We also emit a leading space in this
* of standard_conforming_strings. We also emit a leading space in this
* case, to guard against the possibility that the result might be
* interpolated immediately following an identifier.
*/
@@ -3143,8 +3143,8 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
*
* We've already verified that the input string is well-formed in the
* current encoding. If it contains no quotes and, in the case of
* literal-escaping, no backslashes, then we can just copy it directly
* to the output buffer, adding the necessary quotes.
* literal-escaping, no backslashes, then we can just copy it directly to
* the output buffer, adding the necessary quotes.
*
* If not, we must rescan the input and process each character
* individually.
@@ -3167,13 +3167,14 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
*rp++ = *s;
else
{
int i = pg_encoding_mblen(conn->client_encoding, s);
int i = pg_encoding_mblen(conn->client_encoding, s);
while (1)
{
*rp++ = *s;
if (--i == 0)
break;
++s; /* for loop will provide the final increment */
++s; /* for loop will provide the final increment */
}
}
}
@@ -3391,9 +3392,9 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
if (strtext[0] == '\\' && strtext[1] == 'x')
{
const unsigned char *s;
unsigned char *p;
unsigned char *p;
buflen = (strtextlen - 2)/2;
buflen = (strtextlen - 2) / 2;
/* Avoid unportable malloc(0) */
buffer = (unsigned char *) malloc(buflen > 0 ? buflen : 1);
if (buffer == NULL)
@@ -3403,8 +3404,8 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
p = buffer;
while (*s)
{
char v1,
v2;
char v1,
v2;
/*
* Bad input is silently ignored. Note that this includes
@@ -3422,52 +3423,52 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
}
else
{
/*
* Length of input is max length of output, but add one to avoid
* unportable malloc(0) if input is zero-length.
*/
buffer = (unsigned char *) malloc(strtextlen + 1);
if (buffer == NULL)
return NULL;
/*
* Length of input is max length of output, but add one to avoid
* unportable malloc(0) if input is zero-length.
*/
buffer = (unsigned char *) malloc(strtextlen + 1);
if (buffer == NULL)
return NULL;
for (i = j = 0; i < strtextlen;)
{
switch (strtext[i])
for (i = j = 0; i < strtextlen;)
{
case '\\':
i++;
if (strtext[i] == '\\')
buffer[j++] = strtext[i++];
else
{
if ((ISFIRSTOCTDIGIT(strtext[i])) &&
(ISOCTDIGIT(strtext[i + 1])) &&
(ISOCTDIGIT(strtext[i + 2])))
switch (strtext[i])
{
case '\\':
i++;
if (strtext[i] == '\\')
buffer[j++] = strtext[i++];
else
{
int byte;
if ((ISFIRSTOCTDIGIT(strtext[i])) &&
(ISOCTDIGIT(strtext[i + 1])) &&
(ISOCTDIGIT(strtext[i + 2])))
{
int byte;
byte = OCTVAL(strtext[i++]);
byte = (byte <<3) +OCTVAL(strtext[i++]);
byte = (byte <<3) +OCTVAL(strtext[i++]);
buffer[j++] = byte;
byte = OCTVAL(strtext[i++]);
byte = (byte <<3) +OCTVAL(strtext[i++]);
byte = (byte <<3) +OCTVAL(strtext[i++]);
buffer[j++] = byte;
}
}
}
/*
* Note: if we see '\' followed by something that isn't a
* recognized escape sequence, we loop around having done
* nothing except advance i. Therefore the something will be
* emitted as ordinary data on the next cycle. Corner case:
* '\' at end of string will just be discarded.
*/
break;
/*
* Note: if we see '\' followed by something that isn't a
* recognized escape sequence, we loop around having done
* nothing except advance i. Therefore the something will
* be emitted as ordinary data on the next cycle. Corner
* case: '\' at end of string will just be discarded.
*/
break;
default:
buffer[j++] = strtext[i++];
break;
default:
buffer[j++] = strtext[i++];
break;
}
}
}
buflen = j; /* buflen is the length of the dequoted data */
buflen = j; /* buflen is the length of the dequoted data */
}
/* Shrink the buffer to be no larger than necessary */

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.131 2010/01/02 16:58:12 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.132 2010/02/26 02:01:33 momjian Exp $
*
* NOTES
*
@@ -159,8 +159,7 @@ struct sigpipe_info
pq_reset_sigpipe(&(spinfo).oldsigmask, (spinfo).sigpipe_pending, \
(spinfo).got_epipe); \
} while (0)
#else /* !ENABLE_THREAD_SAFETY */
#else /* !ENABLE_THREAD_SAFETY */
#define DECLARE_SIGPIPE_INFO(spinfo) pqsigfunc spinfo = NULL
@@ -177,17 +176,14 @@ struct sigpipe_info
if (!SIGPIPE_MASKED(conn)) \
pqsignal(SIGPIPE, spinfo); \
} while (0)
#endif /* ENABLE_THREAD_SAFETY */
#else /* WIN32 */
#endif /* ENABLE_THREAD_SAFETY */
#else /* WIN32 */
#define DECLARE_SIGPIPE_INFO(spinfo)
#define DISABLE_SIGPIPE(conn, spinfo, failaction)
#define REMEMBER_EPIPE(spinfo, cond)
#define RESTORE_SIGPIPE(conn, spinfo)
#endif /* WIN32 */
#endif /* WIN32 */
/* ------------------------------------------------------------ */
/* Procedures common to all secure sessions */
@@ -318,6 +314,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
if (conn->ssl)
{
int err;
DECLARE_SIGPIPE_INFO(spinfo);
/* SSL_read can write to the socket, so we need to disable SIGPIPE */
@@ -401,6 +398,7 @@ ssize_t
pqsecure_write(PGconn *conn, const void *ptr, size_t len)
{
ssize_t n;
DECLARE_SIGPIPE_INFO(spinfo);
#ifdef USE_SSL
@@ -473,15 +471,14 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
else
#endif
{
int flags = 0;
int flags = 0;
#ifdef MSG_NOSIGNAL
if (conn->sigpipe_flag)
flags |= MSG_NOSIGNAL;
retry_masked:
#endif /* MSG_NOSIGNAL */
#endif /* MSG_NOSIGNAL */
DISABLE_SIGPIPE(conn, spinfo, return -1);
@@ -501,7 +498,7 @@ retry_masked:
flags = 0;
goto retry_masked;
}
#endif /* MSG_NOSIGNAL */
#endif /* MSG_NOSIGNAL */
REMEMBER_EPIPE(spinfo, SOCK_ERRNO == EPIPE);
}
@@ -764,7 +761,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not initialize SSL engine \"%s\": %s\n"),
libpq_gettext("could not initialize SSL engine \"%s\": %s\n"),
engine_str, err);
SSLerrfree(err);
ENGINE_free(conn->engine);
@@ -1268,8 +1265,8 @@ open_client_SSL(PGconn *conn)
conn->peer_dn[sizeof(conn->peer_dn) - 1] = '\0';
r = X509_NAME_get_text_by_NID(X509_get_subject_name(conn->peer),
NID_commonName, conn->peer_cn, SM_USER);
conn->peer_cn[SM_USER] = '\0'; /* buffer is SM_USER+1 chars! */
NID_commonName, conn->peer_cn, SM_USER);
conn->peer_cn[SM_USER] = '\0'; /* buffer is SM_USER+1 chars! */
if (r == -1)
{
/* Unable to get the CN, set it to blank so it can't be used */
@@ -1278,8 +1275,8 @@ open_client_SSL(PGconn *conn)
else
{
/*
* Reject embedded NULLs in certificate common name to prevent attacks like
* CVE-2009-4034.
* Reject embedded NULLs in certificate common name to prevent attacks
* like CVE-2009-4034.
*/
if (r != strlen(conn->peer_cn))
{

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.151 2010/02/05 03:09:05 joe Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.152 2010/02/26 02:01:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -227,13 +227,13 @@ typedef struct pgresAttDesc
/* Asynchronous (non-blocking) */
extern PGconn *PQconnectStart(const char *conninfo);
extern PGconn *PQconnectStartParams(const char **keywords,
const char **values, int expand_dbname);
const char **values, int expand_dbname);
extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
/* Synchronous (blocking) */
extern PGconn *PQconnectdb(const char *conninfo);
extern PGconn *PQconnectdbParams(const char **keywords,
const char **values, int expand_dbname);
const char **values, int expand_dbname);
extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
const char *pgoptions, const char *pgtty,
const char *dbName,

View File

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.148 2010/01/15 09:19:10 heikki Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.149 2010/02/26 02:01:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -80,8 +80,7 @@ typedef struct
#if (SSLEAY_VERSION_NUMBER >= 0x00907000L) && !defined(OPENSSL_NO_ENGINE)
#define USE_SSL_ENGINE
#endif
#endif /* USE_SSL */
#endif /* USE_SSL */
/*
* POSTGRES backend dependent Constants.
@@ -397,10 +396,10 @@ struct pg_conn
#ifdef USE_SSL_ENGINE
ENGINE *engine; /* SSL engine, if any */
#else
void *engine; /* dummy field to keep struct the same
if OpenSSL version changes */
void *engine; /* dummy field to keep struct the same if
* OpenSSL version changes */
#endif
#endif /* USE_SSL */
#endif /* USE_SSL */
#ifdef ENABLE_GSS
gss_ctx_id_t gctx; /* GSS context */