summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorBruce Momjian2004-08-29 05:07:03 +0000
committerBruce Momjian2004-08-29 05:07:03 +0000
commitb6b71b85bc45b49005b5aec87cba2c33fc8baf49 (patch)
treec23dbd1dbc43972a8e48327c8a771baf36952f3d /src/interfaces
parent90cb9c305140684b2b00c739b724f67915e11404 (diff)
Pgindent run for 8.0.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/ecpg/compatlib/informix.c164
-rw-r--r--src/interfaces/ecpg/ecpglib/connect.c11
-rw-r--r--src/interfaces/ecpg/ecpglib/data.c38
-rw-r--r--src/interfaces/ecpg/ecpglib/descriptor.c54
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c88
-rw-r--r--src/interfaces/ecpg/ecpglib/extern.h138
-rw-r--r--src/interfaces/ecpg/ecpglib/misc.c15
-rw-r--r--src/interfaces/ecpg/include/datetime.h2
-rw-r--r--src/interfaces/ecpg/include/decimal.h2
-rw-r--r--src/interfaces/ecpg/include/ecpg_informix.h48
-rw-r--r--src/interfaces/ecpg/include/pgtypes_date.h3
-rw-r--r--src/interfaces/ecpg/include/pgtypes_interval.h4
-rw-r--r--src/interfaces/ecpg/include/pgtypes_numeric.h8
-rw-r--r--src/interfaces/ecpg/include/pgtypes_timestamp.h2
-rw-r--r--src/interfaces/ecpg/include/sql3types.h4
-rw-r--r--src/interfaces/ecpg/include/sqltypes.h2
-rw-r--r--src/interfaces/ecpg/pgtypeslib/datetime.c4
-rw-r--r--src/interfaces/ecpg/pgtypeslib/dt_common.c2
-rw-r--r--src/interfaces/ecpg/pgtypeslib/interval.c6
-rw-r--r--src/interfaces/ecpg/pgtypeslib/numeric.c59
-rw-r--r--src/interfaces/ecpg/pgtypeslib/timestamp.c28
-rw-r--r--src/interfaces/ecpg/preproc/descriptor.c6
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c33
-rw-r--r--src/interfaces/ecpg/preproc/extern.h2
-rw-r--r--src/interfaces/ecpg/preproc/type.c6
-rw-r--r--src/interfaces/ecpg/preproc/type.h24
-rw-r--r--src/interfaces/ecpg/preproc/variable.c9
-rw-r--r--src/interfaces/libpq/fe-connect.c41
-rw-r--r--src/interfaces/libpq/fe-exec.c69
-rw-r--r--src/interfaces/libpq/fe-lobj.c8
-rw-r--r--src/interfaces/libpq/fe-misc.c21
-rw-r--r--src/interfaces/libpq/fe-print.c3
-rw-r--r--src/interfaces/libpq/fe-protocol2.c16
-rw-r--r--src/interfaces/libpq/fe-protocol3.c10
-rw-r--r--src/interfaces/libpq/fe-secure.c147
-rw-r--r--src/interfaces/libpq/libpq-fe.h55
-rw-r--r--src/interfaces/libpq/libpq-int.h6
-rw-r--r--src/interfaces/libpq/pqexpbuffer.c4
-rw-r--r--src/interfaces/libpq/pqsignal.c10
-rw-r--r--src/interfaces/libpq/pthread-win32.c32
-rw-r--r--src/interfaces/libpq/win32.c2
41 files changed, 637 insertions, 549 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c
index ad55a542e28..d8d95c03ccc 100644
--- a/src/interfaces/ecpg/compatlib/informix.c
+++ b/src/interfaces/ecpg/compatlib/informix.c
@@ -12,7 +12,7 @@
#include <pgtypes_numeric.h>
#include <sqltypes.h>
-char *ECPGalloc(long, int);
+char *ECPGalloc(long, int);
static int
deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *))
@@ -60,7 +60,10 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
*nres;
int i;
- /* we must NOT set the result to NULL here because it may be the same variable as one of the arguments */
+ /*
+ * we must NOT set the result to NULL here because it may be the same
+ * variable as one of the arguments
+ */
if (risnull(CDECIMALTYPE, (char *) arg1) || risnull(CDECIMALTYPE, (char *) arg2))
return 0;
@@ -100,12 +103,12 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
if (i == 0) /* No error */
{
-
+
/* set the result to null in case it errors out later */
rsetnull(CDECIMALTYPE, (char *) result);
PGTYPESnumeric_to_decimal(nres, result);
}
-
+
PGTYPESnumeric_free(nres);
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
@@ -161,8 +164,9 @@ ecpg_strndup(const char *str, size_t len)
int
deccvasc(char *cp, int len, decimal * np)
{
- char *str = ecpg_strndup(cp, len); /* decimal_in always converts the
- * complete string */
+ char *str = ecpg_strndup(cp, len); /* decimal_in always
+ * converts the complete
+ * string */
int ret = 0;
numeric *result;
@@ -269,7 +273,7 @@ deccvlong(long lng, decimal * np)
int
decdiv(decimal * n1, decimal * n2, decimal * result)
{
-
+
int i;
i = deccall3(n1, n2, result, PGTYPESnumeric_div);
@@ -295,7 +299,7 @@ int
decmul(decimal * n1, decimal * n2, decimal * result)
{
int i;
-
+
i = deccall3(n1, n2, result, PGTYPESnumeric_mul);
if (i != 0)
@@ -316,7 +320,7 @@ int
decsub(decimal * n1, decimal * n2, decimal * result)
{
int i;
-
+
i = deccall3(n1, n2, result, PGTYPESnumeric_sub);
if (i != 0)
@@ -452,48 +456,50 @@ int
rstrdate(char *str, date * d)
{
date dat;
- char strbuf[10];
- int i,j;
-
- rsetnull(CDATETYPE, (char *)&dat);
- /*
- * we have to flip the year month date around for postgres
- * expects yyyymmdd
- *
- */
-
- for (i=0,j=0; i < 10; i++ )
+ char strbuf[10];
+ int i,
+ j;
+
+ rsetnull(CDATETYPE, (char *) &dat);
+
+ /*
+ * we have to flip the year month date around for postgres expects
+ * yyyymmdd
+ *
+ */
+
+ for (i = 0, j = 0; i < 10; i++)
{
/* ignore non-digits */
- if ( isdigit((unsigned char) str[i]) )
+ if (isdigit((unsigned char) str[i]))
{
-
+
/* j only increments if it is a digit */
- switch(j)
+ switch (j)
{
- /* stick the month into the 4th, 5th position */
+ /* stick the month into the 4th, 5th position */
case 0:
case 1:
- strbuf[j+4] = str[i];
+ strbuf[j + 4] = str[i];
break;
- /* stick the day into the 6th, and 7th position */
+ /* stick the day into the 6th, and 7th position */
case 2:
case 3:
- strbuf[j+4] = str[i];
+ strbuf[j + 4] = str[i];
break;
- /* stick the year into the first 4 positions */
+ /* stick the year into the first 4 positions */
case 4:
case 5:
case 6:
case 7:
- strbuf[j-4] = str[i];
+ strbuf[j - 4] = str[i];
break;
-
+
}
j++;
- }
- }
+ }
+ }
strbuf[8] = '\0';
dat = PGTYPESdate_from_asc(strbuf, NULL);
@@ -581,13 +587,13 @@ rdayofweek(date d)
/* And the datetime stuff */
void
-dtcurrent(timestamp *ts)
+dtcurrent(timestamp * ts)
{
PGTYPEStimestamp_current(ts);
}
int
-dtcvasc(char *str, timestamp *ts)
+dtcvasc(char *str, timestamp * ts)
{
timestamp ts_tmp;
int i;
@@ -610,13 +616,13 @@ dtcvasc(char *str, timestamp *ts)
}
int
-dtsub(timestamp *ts1, timestamp *ts2, interval *iv)
+dtsub(timestamp * ts1, timestamp * ts2, interval * iv)
{
return PGTYPEStimestamp_sub(ts1, ts2, iv);
}
int
-dttoasc(timestamp *ts, char *output)
+dttoasc(timestamp * ts, char *output)
{
char *asctime = PGTYPEStimestamp_to_asc(*ts);
@@ -626,13 +632,13 @@ dttoasc(timestamp *ts, char *output)
}
int
-dttofmtasc(timestamp *ts, char *output, int str_len, char *fmtstr)
+dttofmtasc(timestamp * ts, char *output, int str_len, char *fmtstr)
{
return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr);
}
int
-intoasc(interval *i, char *str)
+intoasc(interval * i, char *str)
{
str = PGTYPESinterval_to_asc(i);
@@ -665,46 +671,48 @@ static struct
* of the long value
*/
static void
-initValue (long lng_val)
-{
- int i, j;
- long l, dig;
-
- /* set some obvious things */
- value.val = lng_val >= 0 ? lng_val : lng_val * (-1);
- value.sign = lng_val >= 0 ? '+' : '-';
- value.maxdigits = log10 (2) * (8 * sizeof (long) - 1);
-
- /* determine the number of digits */
- i = 0;
- l = 1;
- do
- {
- i++;
- l *= 10;
- }
- while ((l - 1) < value.val && l <= LONG_MAX / 10);
-
- if (l <= LONG_MAX/10)
- {
- value.digits = i;
- l /= 10;
- }
- else
- value.digits = i + 1;
-
- value.remaining = value.digits;
-
- /* convert the long to string */
- value.val_string = (char *) malloc (value.digits + 1);
- dig = value.val;
- for (i = value.digits, j = 0; i > 0; i--, j++)
- {
- value.val_string[j] = dig/l + '0';
- dig = dig % l;
- l /= 10;
- }
- value.val_string[value.digits] = '\0';
+initValue(long lng_val)
+{
+ int i,
+ j;
+ long l,
+ dig;
+
+ /* set some obvious things */
+ value.val = lng_val >= 0 ? lng_val : lng_val * (-1);
+ value.sign = lng_val >= 0 ? '+' : '-';
+ value.maxdigits = log10(2) * (8 * sizeof(long) - 1);
+
+ /* determine the number of digits */
+ i = 0;
+ l = 1;
+ do
+ {
+ i++;
+ l *= 10;
+ }
+ while ((l - 1) < value.val && l <= LONG_MAX / 10);
+
+ if (l <= LONG_MAX / 10)
+ {
+ value.digits = i;
+ l /= 10;
+ }
+ else
+ value.digits = i + 1;
+
+ value.remaining = value.digits;
+
+ /* convert the long to string */
+ value.val_string = (char *) malloc(value.digits + 1);
+ dig = value.val;
+ for (i = value.digits, j = 0; i > 0; i--, j++)
+ {
+ value.val_string[j] = dig / l + '0';
+ dig = dig % l;
+ l /= 10;
+ }
+ value.val_string[value.digits] = '\0';
}
/* return the position oft the right-most dot in some string */
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 838cedf5c94..2dded3a17d4 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.22 2004/06/10 22:26:21 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.23 2004/08/29 05:06:59 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -14,8 +14,9 @@
#ifdef ENABLE_THREAD_SAFETY
static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_key_t actual_connection_key;
+static pthread_key_t actual_connection_key;
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
+
#else
static struct connection *actual_connection = NULL;
#endif
@@ -25,7 +26,7 @@ static struct connection *all_connections = NULL;
static void
ecpg_actual_connection_init(void)
{
- pthread_key_create(&actual_connection_key, NULL);
+ pthread_key_create(&actual_connection_key, NULL);
}
#endif
@@ -114,8 +115,8 @@ ecpg_finish(struct connection * act)
}
#ifdef ENABLE_THREAD_SAFETY
- if( pthread_getspecific(actual_connection_key) == act )
- pthread_setspecific(actual_connection_key, all_connections);
+ if (pthread_getspecific(actual_connection_key) == act)
+ pthread_setspecific(actual_connection_key, all_connections);
#else
if (actual_connection == act)
actual_connection = all_connections;
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index 04e944ce892..25738796fb2 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.26 2004/07/04 15:02:22 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.27 2004/08/29 05:06:59 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -16,12 +16,16 @@
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
-static bool garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat)
+static bool
+garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat)
{
- /* INFORMIX allows for selecting a numeric into an int, the result is truncated */
- if (isarray == ECPG_ARRAY_NONE && INFORMIX_MODE(compat) && *scan_length == '.')
+ /*
+ * INFORMIX allows for selecting a numeric into an int, the result is
+ * truncated
+ */
+ if (isarray == ECPG_ARRAY_NONE && INFORMIX_MODE(compat) && *scan_length == '.')
return false;
-
+
if (isarray == ECPG_ARRAY_ARRAY && *scan_length != ',' && *scan_length != '}')
return true;
@@ -44,7 +48,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
int value_for_indicator = 0;
- ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? pval : "", offset, isarray?"Yes":"No");
+ ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? pval : "", offset, isarray ? "Yes" : "No");
/* pval is a pointer to the value */
/* let's check if it really is an array if it should be one */
@@ -228,7 +232,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
*((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 */
{
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
@@ -419,7 +423,10 @@ ECPGget_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_numeric, nres);
}
else
@@ -463,7 +470,10 @@ ECPGget_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_interval, ires);
}
else
@@ -503,7 +513,10 @@ ECPGget_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
@@ -542,7 +555,10 @@ ECPGget_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
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index bc56b0222bc..08c8d3479ce 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.11 2004/07/05 09:45:53 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.12 2004/08/29 05:06:59 momjian Exp $
*/
#define POSTGRES_ECPG_INTERNAL
@@ -434,10 +434,10 @@ bool
ECPGset_desc_header(int lineno, char *desc_name, int count)
{
struct descriptor *desc;
-
+
for (desc = all_descriptors; desc; desc = desc->next)
{
- if (strcmp(desc_name, desc->name)==0)
+ if (strcmp(desc_name, desc->name) == 0)
break;
}
@@ -461,7 +461,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
for (desc = all_descriptors; desc; desc = desc->next)
{
- if (strcmp(desc_name, desc->name)==0)
+ if (strcmp(desc_name, desc->name) == 0)
break;
}
@@ -486,7 +486,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
}
if (!(var = (struct variable *) ECPGalloc(sizeof(struct variable), lineno)))
- return false;
+ return false;
va_start(args, index);
@@ -494,7 +494,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
{
enum ECPGdtype itemtype;
enum ECPGttype type;
- const char *tobeinserted = NULL;
+ const char *tobeinserted = NULL;
bool malloced;
itemtype = va_arg(args, enum ECPGdtype);
@@ -508,17 +508,17 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
switch (itemtype)
{
case ECPGd_data:
- {
- if (!ECPGstore_input(lineno, true, var, &tobeinserted, &malloced))
{
- ECPGfree(var);
- return false;
+ if (!ECPGstore_input(lineno, true, var, &tobeinserted, &malloced))
+ {
+ ECPGfree(var);
+ return false;
+ }
+
+ desc_item->data = (char *) tobeinserted;
+ tobeinserted = NULL;
+ break;
}
-
- desc_item->data = (char *) tobeinserted;
- tobeinserted = NULL;
- break;
- }
case ECPGd_indicator:
set_int_item(lineno, &desc_item->indicator, var->pointer, var->type);
@@ -541,20 +541,20 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
break;
default:
- {
- char type_str[20];
- snprintf(type_str, sizeof(type_str), "%d", itemtype);
- ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
- ECPGfree(var);
- return false;
- }
+ {
+ char type_str[20];
+
+ snprintf(type_str, sizeof(type_str), "%d", itemtype);
+ ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, type_str);
+ ECPGfree(var);
+ return false;
+ }
}
- /*if (itemtype == ECPGd_data)
- {
- free(desc_item->data);
- desc_item->data = NULL;
- }*/
+ /*
+ * if (itemtype == ECPGd_data) { free(desc_item->data);
+ * desc_item->data = NULL; }
+ */
}
while (true);
ECPGfree(var);
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index a3a601aed52..ac16e457dd8 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.37 2004/07/05 09:45:53 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.38 2004/08/29 05:06:59 momjian Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -70,7 +70,7 @@ quote_postgres(char *arg, int lineno)
}
void
-ECPGget_variable(va_list *ap, enum ECPGttype type, struct variable *var, bool indicator)
+ECPGget_variable(va_list *ap, enum ECPGttype type, struct variable * var, bool indicator)
{
var->type = type;
var->pointer = va_arg(*ap, char *);
@@ -78,15 +78,14 @@ ECPGget_variable(va_list *ap, enum ECPGttype type, struct variable *var, bool in
var->varcharsize = va_arg(*ap, long);
var->arrsize = va_arg(*ap, long);
var->offset = va_arg(*ap, long);
-
+
if (var->arrsize == 0 || var->varcharsize == 0)
var->value = *((char **) (var->pointer));
else
var->value = var->pointer;
/*
- * negative values are used to indicate an array without given
- * bounds
+ * negative values are used to indicate an array without given bounds
*/
/* reset to zero for us */
if (var->arrsize < 0)
@@ -95,7 +94,7 @@ ECPGget_variable(va_list *ap, enum ECPGttype type, struct variable *var, bool in
var->varcharsize = 0;
var->next = NULL;
-
+
if (indicator)
{
var->ind_type = va_arg(*ap, enum ECPGttype);
@@ -245,19 +244,19 @@ ECPGtypeinfocache_push(struct ECPGtype_information_cache ** cache, int oid, bool
{
struct ECPGtype_information_cache *new_entry
= (struct ECPGtype_information_cache *) ECPGalloc(sizeof(struct ECPGtype_information_cache), lineno);
-
+
new_entry->oid = oid;
new_entry->isarray = isarray;
new_entry->next = *cache;
*cache = new_entry;
}
-
+
static enum ARRAY_TYPE
ECPGis_type_an_array(int type, const struct statement * stmt, const struct variable * var)
{
- char *array_query;
- enum ARRAY_TYPE isarray = ECPG_ARRAY_NOT_SET;
- PGresult *query;
+ char *array_query;
+ enum ARRAY_TYPE isarray = ECPG_ARRAY_NOT_SET;
+ PGresult *query;
struct ECPGtype_information_cache *cache_entry;
if ((stmt->connection->cache_head) == NULL)
@@ -319,14 +318,14 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
if (cache_entry->oid == type)
return cache_entry->isarray;
}
-
+
array_query = (char *) ECPGalloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno);
sprintf(array_query, "select typlen from pg_type where oid=%d and typelem<>0", type);
query = PQexec(stmt->connection->connection, array_query);
ECPGfree(array_query);
- if (PQresultStatus(query) == PGRES_TUPLES_OK )
+ if (PQresultStatus(query) == PGRES_TUPLES_OK)
{
- if ( PQntuples(query) == 0 )
+ if (PQntuples(query) == 0)
isarray = ECPG_ARRAY_NONE;
else
{
@@ -343,7 +342,7 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
}
PQclear(query);
ECPGtypeinfocache_push(&(stmt->connection->cache_head), type, isarray, stmt->lineno);
- ECPGlog("ECPGis_type_an_array line %d: TYPE database: %d C: %d array: %s\n", stmt->lineno, type, var->type, isarray?"Yes":"No");
+ ECPGlog("ECPGis_type_an_array line %d: TYPE database: %d C: %d array: %s\n", stmt->lineno, type, var->type, isarray ? "Yes" : "No");
return isarray;
}
@@ -352,7 +351,7 @@ bool
ECPGstore_result(const PGresult *results, int act_field,
const struct statement * stmt, struct variable * var)
{
- enum ARRAY_TYPE isarray;
+ enum ARRAY_TYPE isarray;
int act_tuple,
ntuples = PQntuples(results);
bool status = true;
@@ -368,7 +367,7 @@ ECPGstore_result(const PGresult *results, int act_field,
{
ECPGlog("ECPGstore_result line %d: Incorrect number of matches: %d don't fit into array of %d\n",
stmt->lineno, ntuples, var->arrsize);
- ECPGraise(stmt->lineno, INFORMIX_MODE(stmt->compat)?ECPG_INFORMIX_SUBSELECT_NOT_ONE:ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
+ ECPGraise(stmt->lineno, INFORMIX_MODE(stmt->compat) ? ECPG_INFORMIX_SUBSELECT_NOT_ONE : ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
return false;
}
}
@@ -797,7 +796,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
case ECPGt_unsigned_char:
{
/* set slen to string length if type is char * */
- int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize;
+ int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize;
if (!(newcopy = ECPGalloc(slen + 1, lineno)))
return false;
@@ -1036,7 +1035,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
free(str);
}
break;
-
+
case ECPGt_descriptor:
break;
@@ -1059,7 +1058,7 @@ ECPGexecute(struct statement * stmt)
PGresult *results;
PGnotify *notify;
struct variable *var;
- int desc_counter = 0;
+ int desc_counter = 0;
copiedquery = ECPGstrdup(stmt->command, stmt->lineno);
@@ -1074,32 +1073,39 @@ ECPGexecute(struct statement * stmt)
while (var)
{
char *newcopy = NULL;
- const char *tobeinserted;
+ const char *tobeinserted;
char *p;
- bool malloced = FALSE;
- int hostvarl = 0;
+ bool malloced = FALSE;
+ int hostvarl = 0;
tobeinserted = NULL;
-
- /* A descriptor is a special case since it contains many variables but is listed only once. */
+
+ /*
+ * A descriptor is a special case since it contains many variables
+ * but is listed only once.
+ */
if (var->type == ECPGt_descriptor)
{
- /* We create an additional variable list here, so the same logic applies. */
+ /*
+ * We create an additional variable list here, so the same
+ * logic applies.
+ */
struct variable desc_inlist;
struct descriptor *desc;
struct descriptor_item *desc_item;
+
for (desc = all_descriptors; desc; desc = desc->next)
{
if (strcmp(var->pointer, desc->name) == 0)
break;
}
-
+
if (desc == NULL)
{
ECPGraise(stmt->lineno, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, var->pointer);
return false;
}
-
+
desc_counter++;
if (desc->count < 0 || desc->count >= desc_counter)
{
@@ -1129,7 +1135,7 @@ ECPGexecute(struct statement * stmt)
}
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, &malloced))
return false;
-
+
break;
}
}
@@ -1145,12 +1151,12 @@ ECPGexecute(struct statement * stmt)
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, &malloced))
return false;
}
-
+
if (tobeinserted)
{
/*
- * Now tobeinserted points to an area that is to be inserted at
- * the first %s
+ * Now tobeinserted points to an area that is to be inserted
+ * at the first %s
*/
if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery) + strlen(tobeinserted) + 1, stmt->lineno)))
return false;
@@ -1159,8 +1165,8 @@ ECPGexecute(struct statement * stmt)
if ((p = next_insert(newcopy + hostvarl)) == NULL)
{
/*
- * We have an argument but we dont have the matched up string
- * in the string
+ * We have an argument but we dont have the matched up
+ * string in the string
*/
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL);
return false;
@@ -1171,8 +1177,8 @@ ECPGexecute(struct statement * stmt)
hostvarl = strlen(newcopy);
/*
- * The strange thing in the second argument is the rest of the
- * string from the old string
+ * The strange thing in the second argument is the rest of
+ * the string from the old string
*/
strcat(newcopy,
copiedquery
@@ -1181,9 +1187,9 @@ ECPGexecute(struct statement * stmt)
}
/*
- * Now everything is safely copied to the newcopy. Lets free the
- * oldcopy and let the copiedquery get the var->value from the
- * newcopy.
+ * Now everything is safely copied to the newcopy. Lets free
+ * the oldcopy and let the copiedquery get the var->value from
+ * the newcopy.
*/
if (malloced)
{
@@ -1194,9 +1200,9 @@ ECPGexecute(struct statement * stmt)
ECPGfree(copiedquery);
copiedquery = newcopy;
}
-
+
if (desc_counter == 0)
- var = var->next;
+ var = var->next;
}
/* Check if there are unmatched things left. */
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index 74a8b046c92..8a04ad0aaf1 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -7,42 +7,42 @@
enum COMPAT_MODE
{
- ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
+ ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
};
#define INFORMIX_MODE(X) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
enum ARRAY_TYPE
{
- ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
+ ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
};
/* Here are some methods used by the lib. */
/* Returns a pointer to a string containing a simple type name. */
-void ECPGadd_mem (void *ptr, int lineno);
-
-bool ECPGget_data (const PGresult *, int, int, int, enum ECPGttype type,
- enum ECPGttype, char *, char *, long, long, long,
- enum ARRAY_TYPE, enum COMPAT_MODE, bool);
-struct connection *ECPGget_connection (const char *);
-char *ECPGalloc (long, int);
-char *ECPGrealloc (void *, long, int);
-void ECPGfree (void *);
-bool ECPGinit (const struct connection *, const char *, const int);
-char *ECPGstrdup (const char *, int);
-const char *ECPGtype_name (enum ECPGttype);
-unsigned int ECPGDynamicType (Oid);
-void ECPGfree_auto_mem (void);
-void ECPGclear_auto_mem (void);
-
-struct descriptor *ecpggetdescp (int, char *);
+void ECPGadd_mem(void *ptr, int lineno);
+
+bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
+ enum ECPGttype, char *, char *, long, long, long,
+ enum ARRAY_TYPE, enum COMPAT_MODE, bool);
+struct connection *ECPGget_connection(const char *);
+char *ECPGalloc(long, int);
+char *ECPGrealloc(void *, long, int);
+void ECPGfree(void *);
+bool ECPGinit(const struct connection *, const char *, const int);
+char *ECPGstrdup(const char *, int);
+const char *ECPGtype_name(enum ECPGttype);
+unsigned int ECPGDynamicType(Oid);
+void ECPGfree_auto_mem(void);
+void ECPGclear_auto_mem(void);
+
+struct descriptor *ecpggetdescp(int, char *);
/* A generic varchar type. */
struct ECPGgeneric_varchar
{
- int len;
- char arr[1];
+ int len;
+ char arr[1];
};
/*
@@ -51,81 +51,81 @@ struct ECPGgeneric_varchar
struct ECPGtype_information_cache
{
- struct ECPGtype_information_cache *next;
- int oid;
- bool isarray;
+ struct ECPGtype_information_cache *next;
+ int oid;
+ bool isarray;
};
/* structure to store one statement */
struct statement
{
- int lineno;
- char *command;
- struct connection *connection;
- enum COMPAT_MODE compat;
- bool force_indicator;
- struct variable *inlist;
- struct variable *outlist;
+ int lineno;
+ char *command;
+ struct connection *connection;
+ enum COMPAT_MODE compat;
+ bool force_indicator;
+ struct variable *inlist;
+ struct variable *outlist;
};
/* structure to store connections */
struct connection
{
- char *name;
- PGconn *connection;
- bool committed;
- int autocommit;
- struct ECPGtype_information_cache *cache_head;
- struct connection *next;
+ char *name;
+ PGconn *connection;
+ bool committed;
+ int autocommit;
+ struct ECPGtype_information_cache *cache_head;
+ struct connection *next;
};
/* structure to store descriptors */
struct descriptor
{
- char *name;
- PGresult *result;
- struct descriptor *next;
- int count;
- struct descriptor_item *items;
+ char *name;
+ PGresult *result;
+ struct descriptor *next;
+ int count;
+ struct descriptor_item *items;
};
extern struct descriptor *all_descriptors;
struct descriptor_item
{
- int num;
- char *data;
- int indicator;
- int length;
- int precision;
- int scale;
- int type;
- struct descriptor_item *next;
+ int num;
+ char *data;
+ int indicator;
+ int length;
+ int precision;
+ int scale;
+ int type;
+ struct descriptor_item *next;
};
struct variable
{
- enum ECPGttype type;
- void *value;
- void *pointer;
- long varcharsize;
- long arrsize;
- long offset;
- enum ECPGttype ind_type;
- void *ind_value;
- void *ind_pointer;
- long ind_varcharsize;
- long ind_arrsize;
- long ind_offset;
- struct variable *next;
+ enum ECPGttype type;
+ void *value;
+ void *pointer;
+ long varcharsize;
+ long arrsize;
+ long offset;
+ enum ECPGttype ind_type;
+ void *ind_value;
+ void *ind_pointer;
+ long ind_varcharsize;
+ long ind_arrsize;
+ long ind_offset;
+ struct variable *next;
};
-PGresult **ECPGdescriptor_lvalue (int line, const char *descriptor);
+PGresult **ECPGdescriptor_lvalue(int line, const char *descriptor);
-bool ECPGstore_result (const PGresult * results, int act_field,
- const struct statement *stmt, struct variable *var);
-bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool *);
-void ECPGget_variable(va_list *, enum ECPGttype, struct variable *, bool);
+bool ECPGstore_result(const PGresult *results, int act_field,
+ const struct statement * stmt, struct variable * var);
+bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool *);
+void ECPGget_variable(va_list *, enum ECPGttype, struct variable *, bool);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */
@@ -153,4 +153,4 @@ void ECPGget_variable(va_list *, enum ECPGttype, struct variable *, bool);
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR "YE000"
#define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY "YE001"
-#endif /* _ECPG_LIB_EXTERN_H */
+#endif /* _ECPG_LIB_EXTERN_H */
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 8faf6b2fdff..69789d9da17 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.21 2004/06/27 12:28:40 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.22 2004/08/29 05:06:59 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -118,15 +118,18 @@ ECPGinit(const struct connection * con, const char *connection_name, const int l
}
#ifdef ENABLE_THREAD_SAFETY
-static void ecpg_sqlca_key_destructor(void *arg)
+static void
+ecpg_sqlca_key_destructor(void *arg)
{
- if( arg != NULL )
- free(arg); /* sqlca structure allocated in ECPGget_sqlca */
+ if (arg != NULL)
+ free(arg); /* sqlca structure allocated in
+ * ECPGget_sqlca */
}
-static void ecpg_sqlca_key_init(void)
+static void
+ecpg_sqlca_key_init(void)
{
- pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
+ pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
}
#endif
diff --git a/src/interfaces/ecpg/include/datetime.h b/src/interfaces/ecpg/include/datetime.h
index 13940cda398..b4108c5d2b8 100644
--- a/src/interfaces/ecpg/include/datetime.h
+++ b/src/interfaces/ecpg/include/datetime.h
@@ -6,4 +6,4 @@
typedef timestamp dtime_t;
typedef interval intrvl_t;
-#endif /* ndef _ECPG_DATETIME_H */
+#endif /* ndef _ECPG_DATETIME_H */
diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h
index 111a97a9dab..80cef55d1e1 100644
--- a/src/interfaces/ecpg/include/decimal.h
+++ b/src/interfaces/ecpg/include/decimal.h
@@ -5,4 +5,4 @@
typedef decimal dec_t;
-#endif /* ndef _ECPG_DECIMAL_H */
+#endif /* ndef _ECPG_DECIMAL_H */
diff --git a/src/interfaces/ecpg/include/ecpg_informix.h b/src/interfaces/ecpg/include/ecpg_informix.h
index 2a17202010e..3e3fcfcfcaa 100644
--- a/src/interfaces/ecpg/include/ecpg_informix.h
+++ b/src/interfaces/ecpg/include/ecpg_informix.h
@@ -1,7 +1,7 @@
/*
* This file contains stuff needed to be as compatible to Informix as possible.
*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.15 2004/05/10 13:46:06 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.16 2004/08/29 05:06:59 momjian Exp $
*/
#ifndef _ECPG_INFORMIX_H
#define _ECPG_INFORMIX_H
@@ -15,14 +15,14 @@
#define SQLNOTFOUND 100
#define ECPG_INFORMIX_NUM_OVERFLOW -1200
-#define ECPG_INFORMIX_NUM_UNDERFLOW -1201
+#define ECPG_INFORMIX_NUM_UNDERFLOW -1201
#define ECPG_INFORMIX_DIVIDE_ZERO -1202
#define ECPG_INFORMIX_BAD_YEAR -1204
#define ECPG_INFORMIX_BAD_MONTH -1205
#define ECPG_INFORMIX_BAD_DAY -1206
#define ECPG_INFORMIX_ENOSHORTDATE -1209
#define ECPG_INFORMIX_DATE_CONVERT -1210
-#define ECPG_INFORMIX_OUT_OF_MEMORY -1211
+#define ECPG_INFORMIX_OUT_OF_MEMORY -1211
#define ECPG_INFORMIX_ENOTDMY -1212
#define ECPG_INFORMIX_BAD_NUMERIC -1213
#define ECPG_INFORMIX_BAD_EXPONENT -1216
@@ -30,12 +30,12 @@
#define ECPG_INFORMIX_EXTRA_CHARS -1264
#ifdef __cplusplus
-extern "C"
+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 *);
@@ -50,7 +50,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 *);
@@ -59,25 +59,25 @@ extern void ECPG_informix_set_var(int, void *, int);
extern void *ECPG_informix_get_var(int);
/* Informix defines these in decimal.h */
-int decadd(decimal *, decimal *, decimal *);
-int deccmp(decimal *, decimal *);
-void deccopy(decimal *, decimal *);
-int deccvasc(char *, int, decimal *);
-int deccvdbl(double, decimal *);
-int deccvint(int, decimal *);
-int deccvlong(long, decimal *);
-int decdiv(decimal *, decimal *, decimal *);
-int decmul(decimal *, decimal *, decimal *);
-int decsub(decimal *, decimal *, decimal *);
-int dectoasc(decimal *, char *, int, int);
-int dectodbl(decimal *, double *);
-int dectoint(decimal *, int *);
-int dectolong(decimal *, long *);
+int decadd(decimal *, decimal *, decimal *);
+int deccmp(decimal *, decimal *);
+void deccopy(decimal *, decimal *);
+int deccvasc(char *, int, decimal *);
+int deccvdbl(double, decimal *);
+int deccvint(int, decimal *);
+int deccvlong(long, decimal *);
+int decdiv(decimal *, decimal *, decimal *);
+int decmul(decimal *, decimal *, decimal *);
+int decsub(decimal *, decimal *, decimal *);
+int dectoasc(decimal *, char *, int, int);
+int dectodbl(decimal *, double *);
+int dectoint(decimal *, int *);
+int dectolong(decimal *, long *);
/* Informix defines these in datetime.h */
-extern void dtcurrent(timestamp *);
-extern int dtcvasc(char *, timestamp *);
-extern int dtsub(timestamp *, timestamp *, interval *);
+extern void dtcurrent(timestamp *);
+extern int dtcvasc(char *, timestamp *);
+extern int dtsub(timestamp *, timestamp *, interval *);
extern int dttoasc(timestamp *, char *);
extern int dttofmtasc(timestamp *, char *, int, char *);
extern int intoasc(interval *, char *);
@@ -87,4 +87,4 @@ extern int dtcvfmtasc(char *, char *, timestamp *);
}
#endif
-#endif /* ndef _ECPG_INFORMIX_H */
+#endif /* ndef _ECPG_INFORMIX_H */
diff --git a/src/interfaces/ecpg/include/pgtypes_date.h b/src/interfaces/ecpg/include/pgtypes_date.h
index 0e30823d2f0..8a98c710d92 100644
--- a/src/interfaces/ecpg/include/pgtypes_date.h
+++ b/src/interfaces/ecpg/include/pgtypes_date.h
@@ -4,8 +4,9 @@
#include <pgtypes_timestamp.h>
typedef long date;
+
#ifdef __cplusplus
-extern "C"
+extern "C"
{
#endif
diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h
index c963b1b89e4..f1edf1618cb 100644
--- a/src/interfaces/ecpg/include/pgtypes_interval.h
+++ b/src/interfaces/ecpg/include/pgtypes_interval.h
@@ -12,10 +12,10 @@ typedef struct
#endif
long month; /* months and years, after time for
* alignment */
-} interval;
+} interval;
#ifdef __cplusplus
-extern "C"
+extern "C"
{
#endif
diff --git a/src/interfaces/ecpg/include/pgtypes_numeric.h b/src/interfaces/ecpg/include/pgtypes_numeric.h
index 951f7dfc0e6..d4846a337ab 100644
--- a/src/interfaces/ecpg/include/pgtypes_numeric.h
+++ b/src/interfaces/ecpg/include/pgtypes_numeric.h
@@ -23,7 +23,7 @@ typedef struct
* NUMERIC_NAN */
NumericDigit *buf; /* start of alloc'd space for digits[] */
NumericDigit *digits; /* decimal digits */
-} numeric;
+} numeric;
typedef struct
{
@@ -38,11 +38,11 @@ typedef struct
} decimal;
#ifdef __cplusplus
-extern "C"
+extern "C"
{
#endif
-
-numeric *PGTYPESnumeric_new(void);
+
+ numeric * PGTYPESnumeric_new(void);
void PGTYPESnumeric_free(numeric *);
numeric *PGTYPESnumeric_from_asc(char *, char **);
char *PGTYPESnumeric_to_asc(numeric *, int);
diff --git a/src/interfaces/ecpg/include/pgtypes_timestamp.h b/src/interfaces/ecpg/include/pgtypes_timestamp.h
index 3b93a43e5a6..b6f1745a5e0 100644
--- a/src/interfaces/ecpg/include/pgtypes_timestamp.h
+++ b/src/interfaces/ecpg/include/pgtypes_timestamp.h
@@ -13,7 +13,7 @@ typedef double TimestampTz;
#endif
#ifdef __cplusplus
-extern "C"
+extern "C"
{
#endif
diff --git a/src/interfaces/ecpg/include/sql3types.h b/src/interfaces/ecpg/include/sql3types.h
index 56366e204c8..6909f2cde08 100644
--- a/src/interfaces/ecpg/include/sql3types.h
+++ b/src/interfaces/ecpg/include/sql3types.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 2000, Christof Petig <[email protected]>
*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.9 2003/11/29 19:52:08 pgsql Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.10 2004/08/29 05:06:59 momjian Exp $
*/
/* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */
@@ -45,4 +45,4 @@ enum
* standard) */
};
-#endif /* !_ECPG_SQL3TYPES_H */
+#endif /* !_ECPG_SQL3TYPES_H */
diff --git a/src/interfaces/ecpg/include/sqltypes.h b/src/interfaces/ecpg/include/sqltypes.h
index 522e6977aa6..f93bd41f8e0 100644
--- a/src/interfaces/ecpg/include/sqltypes.h
+++ b/src/interfaces/ecpg/include/sqltypes.h
@@ -27,4 +27,4 @@
#define CLVCHARPTRTYPE 124
#define CTYPEMAX 25
-#endif /* ndef ECPG_SQLTYPES_H */
+#endif /* ndef ECPG_SQLTYPES_H */
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index a8a26cd4439..cc8788af578 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -124,8 +124,8 @@ int
PGTYPESdate_dayofweek(date dDate)
{
/*
- * Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
- * Thursday: 4 Friday: 5 Saturday: 6
+ * Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3 Thursday:
+ * 4 Friday: 5 Saturday: 6
*/
return (int) (dDate + date2j(2000, 1, 1) + 1) % 7;
}
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c
index f906b449b08..a5a13f8b537 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt_common.c
+++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c
@@ -2729,7 +2729,7 @@ int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int
int *, int *, int *, int *);
int
-PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d,
+PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
int *year, int *month, int *day,
int *hour, int *minute, int *second,
int *tz)
diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c
index e1d34e8a7b2..39576bf369e 100644
--- a/src/interfaces/ecpg/pgtypeslib/interval.c
+++ b/src/interfaces/ecpg/pgtypeslib/interval.c
@@ -720,7 +720,7 @@ interval2tm(interval span, struct tm * tm, fsec_t *fsec)
} /* interval2tm() */
static int
-tm2interval(struct tm * tm, fsec_t fsec, interval *span)
+tm2interval(struct tm * tm, fsec_t fsec, interval * span)
{
span->month = ((tm->tm_year * 12) + tm->tm_mon);
#ifdef HAVE_INT64_TIMESTAMP
@@ -797,7 +797,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
}
char *
-PGTYPESinterval_to_asc(interval *span)
+PGTYPESinterval_to_asc(interval * span)
{
struct tm tt,
*tm = &tt;
@@ -821,7 +821,7 @@ PGTYPESinterval_to_asc(interval *span)
}
int
-PGTYPESinterval_copy(interval *intvlsrc, interval *intrcldest)
+PGTYPESinterval_copy(interval * intvlsrc, interval * intrcldest)
{
intrcldest->time = intvlsrc->time;
intrcldest->month = intvlsrc->month;
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index b06b8d14e56..a79d8bcf90c 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -28,7 +28,7 @@
* ----------
*/
static int
-apply_typmod(numeric *var, long typmod)
+apply_typmod(numeric * var, long typmod)
{
int precision;
int scale;
@@ -108,7 +108,7 @@ apply_typmod(numeric *var, long typmod)
* ----------
*/
static int
-alloc_var(numeric *var, int ndigits)
+alloc_var(numeric * var, int ndigits)
{
digitbuf_free(var->buf);
var->buf = digitbuf_alloc(ndigits + 1);
@@ -141,7 +141,7 @@ PGTYPESnumeric_new(void)
* ----------
*/
static int
-set_var_from_str(char *str, char **ptr, numeric *dest)
+set_var_from_str(char *str, char **ptr, numeric * dest)
{
bool have_dp = FALSE;
int i = 0;
@@ -271,7 +271,7 @@ set_var_from_str(char *str, char **ptr, numeric *dest)
* ----------
*/
static char *
-get_str_from_var(numeric *var, int dscale)
+get_str_from_var(numeric * var, int dscale)
{
char *str;
char *cp;
@@ -385,7 +385,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
}
char *
-PGTYPESnumeric_to_asc(numeric *num, int dscale)
+PGTYPESnumeric_to_asc(numeric * num, int dscale)
{
if (dscale < 0)
dscale = num->dscale;
@@ -401,7 +401,7 @@ PGTYPESnumeric_to_asc(numeric *num, int dscale)
* ----------
*/
static void
-zero_var(numeric *var)
+zero_var(numeric * var)
{
digitbuf_free(var->buf);
var->buf = NULL;
@@ -412,7 +412,7 @@ zero_var(numeric *var)
}
void
-PGTYPESnumeric_free(numeric *var)
+PGTYPESnumeric_free(numeric * var)
{
digitbuf_free(var->buf);
free(var);
@@ -428,7 +428,7 @@ PGTYPESnumeric_free(numeric *var)
* ----------
*/
static int
-cmp_abs(numeric *var1, numeric *var2)
+cmp_abs(numeric * var1, numeric * var2)
{
int i1 = 0;
int i2 = 0;
@@ -486,7 +486,7 @@ cmp_abs(numeric *var1, numeric *var2)
* ----------
*/
static int
-add_abs(numeric *var1, numeric *var2, numeric *result)
+add_abs(numeric * var1, numeric * var2, numeric * result)
{
NumericDigit *res_buf;
NumericDigit *res_digits;
@@ -574,7 +574,7 @@ add_abs(numeric *var1, numeric *var2, numeric *result)
* ----------
*/
static int
-sub_abs(numeric *var1, numeric *var2, numeric *result)
+sub_abs(numeric * var1, numeric * var2, numeric * result)
{
NumericDigit *res_buf;
NumericDigit *res_digits;
@@ -658,7 +658,7 @@ sub_abs(numeric *var1, numeric *var2, numeric *result)
* ----------
*/
int
-PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result)
+PGTYPESnumeric_add(numeric * var1, numeric * var2, numeric * result)
{
/*
* Decide on the signs of the two variables what to do
@@ -787,7 +787,7 @@ PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result)
* ----------
*/
int
-PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result)
+PGTYPESnumeric_sub(numeric * var1, numeric * var2, numeric * result)
{
/*
* Decide on the signs of the two variables what to do
@@ -918,7 +918,7 @@ PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result)
* ----------
*/
int
-PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
+PGTYPESnumeric_mul(numeric * var1, numeric * var2, numeric * result)
{
NumericDigit *res_buf;
NumericDigit *res_digits;
@@ -1009,7 +1009,7 @@ PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
* Note that this must be called before div_var.
*/
static int
-select_div_scale(numeric *var1, numeric *var2, int *rscale)
+select_div_scale(numeric * var1, numeric * var2, int *rscale)
{
int weight1,
weight2,
@@ -1076,7 +1076,7 @@ select_div_scale(numeric *var1, numeric *var2, int *rscale)
}
int
-PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
+PGTYPESnumeric_div(numeric * var1, numeric * var2, numeric * result)
{
NumericDigit *res_digits;
int res_ndigits;
@@ -1282,7 +1282,7 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
int
-PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
+PGTYPESnumeric_cmp(numeric * var1, numeric * var2)
{
/* use cmp_abs function to calculate the result */
@@ -1313,7 +1313,7 @@ PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
}
int
-PGTYPESnumeric_from_int(signed int int_val, numeric *var)
+PGTYPESnumeric_from_int(signed int int_val, numeric * var)
{
/* implicit conversion */
signed long int long_int = int_val;
@@ -1322,7 +1322,7 @@ PGTYPESnumeric_from_int(signed int int_val, numeric *var)
}
int
-PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
+PGTYPESnumeric_from_long(signed long int long_val, numeric * var)
{
/* calculate the size of the long int number */
/* a number n needs log_10 n digits */
@@ -1351,9 +1351,9 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
{
size++;
reach_limit *= 10;
- } while ((reach_limit - 1) < abs_long_val && reach_limit <= LONG_MAX/10);
+ } while ((reach_limit - 1) < abs_long_val && reach_limit <= LONG_MAX / 10);
- if (reach_limit > LONG_MAX/10)
+ if (reach_limit > LONG_MAX / 10)
{
/* add the first digit and a .0 */
size += 2;
@@ -1392,11 +1392,12 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
}
int
-PGTYPESnumeric_copy(numeric *src, numeric *dst)
+PGTYPESnumeric_copy(numeric * src, numeric * dst)
{
int i;
- if ( dst == NULL ) return -1;
+ if (dst == NULL)
+ return -1;
zero_var(dst);
dst->weight = src->weight;
@@ -1414,7 +1415,7 @@ PGTYPESnumeric_copy(numeric *src, numeric *dst)
}
int
-PGTYPESnumeric_from_double(double d, numeric *dst)
+PGTYPESnumeric_from_double(double d, numeric * dst)
{
char buffer[100];
numeric *tmp;
@@ -1431,7 +1432,7 @@ PGTYPESnumeric_from_double(double d, numeric *dst)
}
static int
-numericvar_to_double_no_overflow(numeric *var, double *dp)
+numericvar_to_double_no_overflow(numeric * var, double *dp)
{
char *tmp;
double val;
@@ -1455,7 +1456,7 @@ numericvar_to_double_no_overflow(numeric *var, double *dp)
}
int
-PGTYPESnumeric_to_double(numeric *nv, double *dp)
+PGTYPESnumeric_to_double(numeric * nv, double *dp)
{
double tmp;
int i;
@@ -1467,7 +1468,7 @@ PGTYPESnumeric_to_double(numeric *nv, double *dp)
}
int
-PGTYPESnumeric_to_int(numeric *nv, int *ip)
+PGTYPESnumeric_to_int(numeric * nv, int *ip)
{
long l;
int i;
@@ -1486,7 +1487,7 @@ PGTYPESnumeric_to_int(numeric *nv, int *ip)
}
int
-PGTYPESnumeric_to_long(numeric *nv, long *lp)
+PGTYPESnumeric_to_long(numeric * nv, long *lp)
{
int i;
long l = 0;
@@ -1514,7 +1515,7 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
}
int
-PGTYPESnumeric_to_decimal(numeric *src, decimal * dst)
+PGTYPESnumeric_to_decimal(numeric * src, decimal * dst)
{
int i;
@@ -1537,7 +1538,7 @@ PGTYPESnumeric_to_decimal(numeric *src, decimal * dst)
}
int
-PGTYPESnumeric_from_decimal(decimal * src, numeric *dst)
+PGTYPESnumeric_from_decimal(decimal * src, numeric * dst)
{
int i;
diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c
index 19146d03e10..671d42e67d2 100644
--- a/src/interfaces/ecpg/pgtypeslib/timestamp.c
+++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c
@@ -50,14 +50,15 @@ dt2local(timestamp dt, int tz)
* Returns -1 on failure (overflow).
*/
int
-tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp *result)
+tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp * result)
{
#ifdef HAVE_INT64_TIMESTAMP
- int dDate;
+ int dDate;
int64 time;
#else
- double dDate, time;
+ double dDate,
+ time;
#endif
/* Julian day routines are not correct for negative Julian days */
@@ -142,11 +143,13 @@ static int
timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
{
#ifdef HAVE_INT64_TIMESTAMP
- int dDate, date0;
+ int dDate,
+ date0;
int64 time;
#else
- double dDate, date0;
+ double dDate,
+ date0;
double time;
#endif
time_t utime;
@@ -337,7 +340,10 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
/* AdjustTimestampForTypmod(&result, typmod); */
- /* Since it's difficult to test for noresult, make sure errno is 0 if no error occured. */
+ /*
+ * Since it's difficult to test for noresult, make sure errno is 0 if
+ * no error occured.
+ */
errno = 0;
return result;
}
@@ -366,7 +372,7 @@ PGTYPEStimestamp_to_asc(timestamp tstamp)
}
void
-PGTYPEStimestamp_current(timestamp *ts)
+PGTYPEStimestamp_current(timestamp * ts)
{
struct tm tm;
@@ -376,7 +382,7 @@ PGTYPEStimestamp_current(timestamp *ts)
}
static int
-dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm * tm,
+dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
char *output, int *pstr_len, char *fmtstr)
{
union un_fmt_comb replace_val;
@@ -766,7 +772,7 @@ dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm * tm,
int
-PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr)
+PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, char *fmtstr)
{
struct tm tm;
fsec_t fsec;
@@ -781,7 +787,7 @@ PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr)
}
int
-PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv)
+PGTYPEStimestamp_sub(timestamp * ts1, timestamp * ts2, interval * iv)
{
if (TIMESTAMP_NOT_FINITE(*ts1) || TIMESTAMP_NOT_FINITE(*ts2))
return PGTYPES_TS_ERR_EINFTIME;
@@ -798,7 +804,7 @@ PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv)
}
int
-PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d)
+PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp * d)
{
int year,
month,
diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c
index 43193364b47..7ba6aa520d7 100644
--- a/src/interfaces/ecpg/preproc/descriptor.c
+++ b/src/interfaces/ecpg/preproc/descriptor.c
@@ -315,10 +315,10 @@ struct variable *
descriptor_variable(const char *name, int input)
{
static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
- static const struct ECPGtype descriptor_type = { ECPGt_descriptor, 0 };
+ static const struct ECPGtype descriptor_type = {ECPGt_descriptor, 0};
static const struct variable varspace[2] = {
- { descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL },
- { descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL }
+ {descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
+ {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
};
strncpy(descriptor_names[input], name, MAX_DESCRIPTOR_NAMELEN);
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 5592b42a79d..9d0648289cf 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.89 2004/07/20 18:06:41 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.90 2004/08/29 05:07:00 momjian Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <[email protected]> Feb 5th, 1998 */
@@ -121,9 +121,9 @@ main(int argc, char *const argv[])
out_option = 0;
struct _include_path *ip;
const char *progname;
- char my_exec_path[MAXPGPATH];
- char include_path[MAXPGPATH];
-
+ char my_exec_path[MAXPGPATH];
+ char include_path[MAXPGPATH];
+
progname = get_progname(argv[0]);
if (argc > 1)
@@ -180,9 +180,9 @@ main(int argc, char *const argv[])
case 'C':
if (strncmp(optarg, "INFORMIX", strlen("INFORMIX")) == 0)
{
- char pkginclude_path[MAXPGPATH];
- char informix_path[MAXPGPATH];
-
+ char pkginclude_path[MAXPGPATH];
+ char informix_path[MAXPGPATH];
+
compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
/* system_includes = true; */
add_preprocessor_define("dec_t=decimal");
@@ -281,7 +281,7 @@ main(int argc, char *const argv[])
ptr2ext[0] = '.';
ptr2ext[1] = 'p';
ptr2ext[2] = 'g';
- ptr2ext[3] = (header_mode == true)? 'h' : 'c';
+ ptr2ext[3] = (header_mode == true) ? 'h' : 'c';
ptr2ext[4] = '\0';
}
@@ -298,7 +298,7 @@ main(int argc, char *const argv[])
ptr2ext = strrchr(output_filename, '.');
/* make extension = .c resp. .h */
- ptr2ext[1] = (header_mode == true)? 'h' : 'c';
+ ptr2ext[1] = (header_mode == true) ? 'h' : 'c';
ptr2ext[2] = '\0';
yyout = fopen(output_filename, PG_BINARY_W);
@@ -403,7 +403,7 @@ main(int argc, char *const argv[])
/* we need several includes */
/* but not if we are in header mode */
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
-
+
if (header_mode == false)
{
fprintf(yyout, "/* These include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n");
@@ -416,24 +416,27 @@ main(int argc, char *const argv[])
}
fprintf(yyout, "#line 1 \"%s\"\n", input_filename);
-
+
/* and parse the source */
yyparse();
/* check if all cursors were indeed opened */
for (ptr = cur; ptr != NULL;)
{
- char errortext[128];
-
+ char errortext[128];
+
if (!(ptr->opened))
{
- /* Does not really make sense to declare a cursor but not open it */
+ /*
+ * Does not really make sense to declare a cursor
+ * but not open it
+ */
snprintf(errortext, sizeof(errortext), "cursor `%s´ has been declared but ot opened\n", ptr->name);
mmerror(PARSE_ERROR, ET_WARNING, errortext);
}
ptr = ptr->next;
}
-
+
if (yyin != NULL && yyin != stdin)
fclose(yyin);
if (out_option == 0 && yyout != stdout)
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index 6f9518f7e61..06cc74f2040 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -62,7 +62,7 @@ extern int yylex(void);
extern void yyerror(char *);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *);
-extern void mmerror(int, enum errortype, char *, ...);
+extern void mmerror(int, enum errortype, char *,...);
extern ScanKeyword *ScanECPGKeywordLookup(char *);
extern ScanKeyword *ScanCKeywordLookup(char *);
extern void output_get_descr_header(char *);
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index 77caff9ac2a..24185222046 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -47,7 +47,11 @@ ECPGstruct_member_dup(struct ECPGstruct_member * rm)
type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
break;
case ECPGt_array:
- /* if this array does contain a struct again, we have to create the struct too */
+
+ /*
+ * if this array does contain a struct again, we have to
+ * create the struct too
+ */
if (rm->type->u.element->type == ECPGt_struct)
type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
else
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index 9aab463aa1c..1a5471fe153 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -115,7 +115,7 @@ struct cursor
char *name;
char *command;
char *connection;
- bool opened;
+ bool opened;
struct arguments *argsinsert;
struct arguments *argsresult;
struct cursor *next;
@@ -123,28 +123,28 @@ struct cursor
struct typedefs
{
- char *name;
- struct this_type *type;
- struct ECPGstruct_member *struct_member_list;
- int brace_level;
- struct typedefs *next;
+ char *name;
+ struct this_type *type;
+ struct ECPGstruct_member *struct_member_list;
+ int brace_level;
+ struct typedefs *next;
};
struct _defines
{
- char *old;
- char *new;
- int pertinent;
- void *used;
+ char *old;
+ char *new;
+ int pertinent;
+ void *used;
struct _defines *next;
};
/* This is a linked list of the variable names and types. */
struct variable
{
- char *name;
+ char *name;
struct ECPGtype *type;
- int brace_level;
+ int brace_level;
struct variable *next;
};
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index 207d2647718..6037d978c70 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -267,7 +267,7 @@ remove_typedefs(int brace_level)
else
prev->next = p->next;
- if (p->type->type_enum == ECPGt_struct || p->type->type_enum == ECPGt_union)
+ if (p->type->type_enum == ECPGt_struct || p->type->type_enum == ECPGt_union)
free(p->struct_member_list);
free(p->type);
free(p->name);
@@ -366,7 +366,7 @@ reset_variables(void)
argsresult = NULL;
}
-/* Insert a new variable into our request list.
+/* Insert a new variable into our request list.
* Note: The list is dumped from the end,
* so we have to add new entries at the beginning */
void
@@ -554,9 +554,10 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
* given bounds
*/
if (atoi(*dimension) < 0 && !type_definition)
+
/*
- * do not change this for typedefs
- * since it will be changed later on when the variable is defined
+ * do not change this for typedefs since it will be
+ * changed later on when the variable is defined
*/
*length = make_str("1");
else if (atoi(*dimension) == 0)
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index a72f71de932..625de2a5331 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.283 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.284 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -449,7 +449,7 @@ connectOptions2(PGconn *conn)
{
conn->status = CONNECTION_BAD;
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("invalid sslmode value: \"%s\"\n"),
+ libpq_gettext("invalid sslmode value: \"%s\"\n"),
conn->sslmode);
return false;
}
@@ -881,6 +881,7 @@ connectDBStart(PGconn *conn)
struct addrinfo hint;
const char *node = NULL;
int ret;
+
#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_once_t check_sigpipe_once = PTHREAD_ONCE_INIT;
@@ -2283,11 +2284,12 @@ retry4:
}
/*
- * Wait for the postmaster to close the connection, which indicates that
- * it's processed the request. Without this delay, we might issue another
- * command only to find that our cancel zaps that command instead of the
- * one we thought we were canceling. Note we don't actually expect this
- * read to obtain any data, we are just waiting for EOF to be signaled.
+ * Wait for the postmaster to close the connection, which indicates
+ * that it's processed the request. Without this delay, we might
+ * issue another command only to find that our cancel zaps that
+ * command instead of the one we thought we were canceling. Note we
+ * don't actually expect this read to obtain any data, we are just
+ * waiting for EOF to be signaled.
*/
retry5:
if (recv(tmpsock, (char *) &crp, 1, 0) < 0)
@@ -2385,11 +2387,11 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
service = getenv("PGSERVICE");
/*
- * This could be used by any application so we can't use the binary
- * location to find our config files.
- */
+ * This could be used by any application so we can't use the binary
+ * location to find our config files.
+ */
snprintf(serviceFile, MAXPGPATH, "%s/pg_service.conf",
- getenv("PGSYSCONFDIR") ? getenv("PGSYSCONFDIR") : SYSCONFDIR);
+ getenv("PGSYSCONFDIR") ? getenv("PGSYSCONFDIR") : SYSCONFDIR);
if (service != NULL)
{
@@ -3112,12 +3114,12 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
port = DEF_PGPORT_STR;
/*
- * Look for it in the home dir.
- * We don't use get_home_path() so we don't pull path.c into our library.
+ * Look for it in the home dir. We don't use get_home_path() so we
+ * don't pull path.c into our library.
*/
if (!(home = getenv(HOMEDIR)))
return NULL;
-
+
pgpassfile = malloc(strlen(home) + 1 + strlen(PGPASSFILE) + 1);
if (!pgpassfile)
{
@@ -3208,16 +3210,18 @@ default_threadlock(int acquire)
#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
+
#else
static pthread_mutex_t singlethread_lock = NULL;
static long mutex_initlock = 0;
- if (singlethread_lock == NULL) {
- while(InterlockedExchange(&mutex_initlock, 1) == 1)
- /* loop, another thread own the lock */ ;
+ if (singlethread_lock == NULL)
+ {
+ while (InterlockedExchange(&mutex_initlock, 1) == 1)
+ /* loop, another thread own the lock */ ;
if (singlethread_lock == NULL)
pthread_mutex_init(&singlethread_lock, NULL);
- InterlockedExchange(&mutex_initlock,0);
+ InterlockedExchange(&mutex_initlock, 0);
}
#endif
if (acquire)
@@ -3241,4 +3245,3 @@ PQregisterThreadLock(pgthreadlock_t *newhandler)
g_threadlock = default_threadlock;
return prev;
}
-
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 1168eec8646..7b8b607e575 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.160 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.161 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,14 +45,14 @@ char *const pgresStatus[] = {
static bool PQsendQueryStart(PGconn *conn);
static int PQsendQueryGuts(PGconn *conn,
- const char *command,
- const char *stmtName,
- int nParams,
- const Oid *paramTypes,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
+ const char *command,
+ const char *stmtName,
+ int nParams,
+ const Oid *paramTypes,
+ const char *const * paramValues,
+ const int *paramLengths,
+ const int *paramFormats,
+ int resultFormat);
static void parseInput(PGconn *conn);
static bool PQexecStart(PGconn *conn);
static PGresult *PQexecFinish(PGconn *conn);
@@ -623,7 +623,7 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
cnt = sscanf(value, "%d.%d.%d", &vmaj, &vmin, &vrev);
if (cnt < 2)
- conn->sversion = 0; /* unknown */
+ conn->sversion = 0; /* unknown */
else
{
if (cnt == 2)
@@ -737,15 +737,15 @@ PQsendQueryPrepared(PGconn *conn,
if (!stmtName)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("statement name is a null pointer\n"));
+ libpq_gettext("statement name is a null pointer\n"));
return 0;
}
return PQsendQueryGuts(conn,
- NULL, /* no command to parse */
+ NULL, /* no command to parse */
stmtName,
nParams,
- NULL, /* no param types */
+ NULL, /* no param types */
paramValues,
paramLengths,
paramFormats,
@@ -811,13 +811,13 @@ PQsendQueryGuts(PGconn *conn,
if (PG_PROTOCOL_MAJOR(conn->pversion) < 3)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("function requires at least protocol version 3.0\n"));
+ libpq_gettext("function requires at least protocol version 3.0\n"));
return 0;
}
/*
- * We will send Parse (if needed), Bind, Describe Portal, Execute, Sync,
- * using specified statement name and the unnamed portal.
+ * We will send Parse (if needed), Bind, Describe Portal, Execute,
+ * Sync, using specified statement name and the unnamed portal.
*/
if (command)
@@ -1445,6 +1445,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
pqPutMsgEnd(conn) < 0)
return -1;
}
+
/*
* If we sent the COPY command in extended-query mode, we must
* issue a Sync as well.
@@ -1462,7 +1463,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
{
/* Ooops, no way to do this in 2.0 */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("function requires at least protocol version 3.0\n"));
+ libpq_gettext("function requires at least protocol version 3.0\n"));
return -1;
}
else
@@ -1843,7 +1844,7 @@ PQfname(const PGresult *res, int field_num)
* downcasing in the frontend might follow different locale rules than
* downcasing in the backend...
*
- * Returns -1 if no match. In the present backend it is also possible
+ * Returns -1 if no match. In the present backend it is also possible
* to have multiple matches, in which case the first one is found.
*/
int
@@ -1859,8 +1860,8 @@ PQfnumber(const PGresult *res, const char *field_name)
return -1;
/*
- * Note: it is correct to reject a zero-length input string; the proper
- * input to match a zero-length field name would be "".
+ * Note: it is correct to reject a zero-length input string; the
+ * proper input to match a zero-length field name would be "".
*/
if (field_name == NULL ||
field_name[0] == '\0' ||
@@ -1869,8 +1870,8 @@ PQfnumber(const PGresult *res, const char *field_name)
/*
* Note: this code will not reject partially quoted strings, eg
- * foo"BAR"foo will become fooBARfoo when it probably ought to be
- * an error condition.
+ * foo"BAR"foo will become fooBARfoo when it probably ought to be an
+ * error condition.
*/
field_case = strdup(field_name);
if (field_case == NULL)
@@ -1880,7 +1881,7 @@ PQfnumber(const PGresult *res, const char *field_name)
optr = field_case;
for (iptr = field_case; *iptr; iptr++)
{
- char c = *iptr;
+ char c = *iptr;
if (in_quotes)
{
@@ -1899,9 +1900,7 @@ PQfnumber(const PGresult *res, const char *field_name)
*optr++ = c;
}
else if (c == '"')
- {
in_quotes = true;
- }
else
{
c = pg_tolower((unsigned char) c);
@@ -2148,7 +2147,7 @@ PQgetisnull(const PGresult *res, int tup_num, int field_num)
int
PQsetnonblocking(PGconn *conn, int arg)
{
- bool barg;
+ bool barg;
if (!conn || conn->status == CONNECTION_BAD)
return -1;
@@ -2283,7 +2282,7 @@ PQescapeString(char *to, const char *from, size_t length)
* '\'' == ASCII 39 == \'
* '\\' == ASCII 92 == \\\\
* anything < 0x20, or > 0x7e ---> \\ooo
- * (where ooo is an octal expression)
+ * (where ooo is an octal expression)
*/
unsigned char *
PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen)
@@ -2378,6 +2377,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
return NULL;
strtextlen = strlen(strtext);
+
/*
* Length of input is max length of output, but add one to avoid
* unportable malloc(0) if input is zero-length.
@@ -2386,7 +2386,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
if (buffer == NULL)
return NULL;
- for (i = j = 0; i < strtextlen; )
+ for (i = j = 0; i < strtextlen;)
{
switch (strtext[i])
{
@@ -2400,7 +2400,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
(ISOCTDIGIT(strtext[i + 1])) &&
(ISOCTDIGIT(strtext[i + 2])))
{
- int byte;
+ int byte;
byte = OCTVAL(strtext[i++]);
byte = (byte << 3) + OCTVAL(strtext[i++]);
@@ -2408,12 +2408,13 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
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.
+ * 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;
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 8138d0dae91..2c70fc09241 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.50 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.51 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -520,7 +520,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (close(fd))
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while writing to file \"%s\"\n"),
+ libpq_gettext("error while writing to file \"%s\"\n"),
filename);
return -1;
}
@@ -559,8 +559,8 @@ lo_initialize(PGconn *conn)
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
/*
- * Execute the query to get all the functions at once. In 7.3 and later
- * we need to be schema-safe.
+ * Execute the query to get all the functions at once. In 7.3 and
+ * later we need to be schema-safe.
*/
if (conn->sversion >= 70300)
query = "select proname, oid from pg_catalog.pg_proc "
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index a1c69ebdb76..212f7a63cd4 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.109 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.110 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -830,15 +830,16 @@ pqSendSome(PGconn *conn, int len)
/*
* There are scenarios in which we can't send data because the
- * communications channel is full, but we cannot expect the server
- * to clear the channel eventually because it's blocked trying to
- * send data to us. (This can happen when we are sending a large
- * amount of COPY data, and the server has generated lots of
- * NOTICE responses.) To avoid a deadlock situation, we must be
- * prepared to accept and buffer incoming data before we try
- * again. Furthermore, it is possible that such incoming data
- * might not arrive until after we've gone to sleep. Therefore,
- * we wait for either read ready or write ready.
+ * communications channel is full, but we cannot expect the
+ * server to clear the channel eventually because it's blocked
+ * trying to send data to us. (This can happen when we are
+ * sending a large amount of COPY data, and the server has
+ * generated lots of NOTICE responses.) To avoid a deadlock
+ * situation, we must be prepared to accept and buffer
+ * incoming data before we try again. Furthermore, it is
+ * possible that such incoming data might not arrive until
+ * after we've gone to sleep. Therefore, we wait for either
+ * read ready or write ready.
*/
if (pqReadData(conn) < 0)
{
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 992af524450..bd89e825c77 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -10,7 +10,7 @@
* didn't really belong there.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.53 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.54 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -91,6 +91,7 @@ PQprint(FILE *fout,
int total_line_length = 0;
int usePipe = 0;
char *pagerenv;
+
#if !defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
pqsigfunc oldsigpipehandler = NULL;
#endif
diff --git a/src/interfaces/libpq/fe-protocol2.c b/src/interfaces/libpq/fe-protocol2.c
index a69c115a740..9fe877841c0 100644
--- a/src/interfaces/libpq/fe-protocol2.c
+++ b/src/interfaces/libpq/fe-protocol2.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.12 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.13 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -177,10 +177,10 @@ pqSetenvPoll(PGconn *conn)
* must use begin/commit in case autocommit is off by
* default in a 7.3 server.
*
- * Note: version() exists in all
- * protocol-2.0-supporting backends. In 7.3 it would
- * be safer to write pg_catalog.version(), but we can't
- * do that without causing problems on older versions.
+ * Note: version() exists in all protocol-2.0-supporting
+ * backends. In 7.3 it would be safer to write
+ * pg_catalog.version(), but we can't do that without
+ * causing problems on older versions.
*/
if (!PQsendQuery(conn, "begin; select version(); end"))
goto error_return;
@@ -303,9 +303,9 @@ pqSetenvPoll(PGconn *conn)
else
{
/*
- * Error: presumably function not
- * available, so use PGCLIENTENCODING or
- * SQL_ASCII as the fallback.
+ * Error: presumably function not available,
+ * so use PGCLIENTENCODING or SQL_ASCII as the
+ * fallback.
*/
val = getenv("PGCLIENTENCODING");
if (val && *val)
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 23281bd423c..68789067d2b 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.14 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.15 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -261,15 +261,16 @@ pqParseInput3(PGconn *conn)
}
break;
case 'n': /* No Data */
+
/*
* NoData indicates that we will not be seeing a
* RowDescription message because the statement or
- * portal inquired about doesn't return rows.
- * Set up a COMMAND_OK result, instead of TUPLES_OK.
+ * portal inquired about doesn't return rows. Set up a
+ * COMMAND_OK result, instead of TUPLES_OK.
*/
if (conn->result == NULL)
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_COMMAND_OK);
+ PGRES_COMMAND_OK);
break;
case 'D': /* Data Row */
if (conn->result != NULL &&
@@ -1107,6 +1108,7 @@ pqEndcopy3(PGconn *conn)
if (pqPutMsgStart('c', false, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return 1;
+
/*
* If we sent the COPY command in extended-query mode, we must
* issue a Sync as well.
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index 6a54ba09bef..db254e52c27 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.48 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.49 2004/08/29 05:07:00 momjian Exp $
*
* NOTES
* The client *requires* a valid server certificate. Since
@@ -145,7 +145,7 @@ static void SSLerrfree(char *buf);
#endif
#ifdef USE_SSL
-bool pq_initssllib = true;
+bool pq_initssllib = true;
static SSL_CTX *SSL_context = NULL;
#endif
@@ -256,7 +256,8 @@ pqsecure_open_client(PGconn *conn)
!SSL_set_app_data(conn->ssl, conn) ||
!SSL_set_fd(conn->ssl, conn->sock))
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not establish SSL connection: %s\n"),
err);
@@ -335,9 +336,10 @@ rloop:
}
case SSL_ERROR_SSL:
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), err);
+ libpq_gettext("SSL error: %s\n"), err);
SSLerrfree(err);
}
/* fall through */
@@ -347,7 +349,7 @@ rloop:
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code\n"));
+ libpq_gettext("unrecognized SSL error code\n"));
n = -1;
break;
}
@@ -414,9 +416,10 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
}
case SSL_ERROR_SSL:
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), err);
+ libpq_gettext("SSL error: %s\n"), err);
SSLerrfree(err);
}
/* fall through */
@@ -426,7 +429,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code\n"));
+ libpq_gettext("unrecognized SSL error code\n"));
n = -1;
break;
}
@@ -501,12 +504,12 @@ verify_peer(PGconn *conn)
struct hostent hpstr;
char buf[BUFSIZ];
int herrno = 0;
-
+
/*
- * Currently, pqGethostbyname() is used only on platforms that
- * don't have getaddrinfo(). If you enable this function,
- * you should convert the pqGethostbyname() function call to
- * use getaddrinfo().
+ * Currently, pqGethostbyname() is used only on platforms that
+ * don't have getaddrinfo(). If you enable this function, you
+ * should convert the pqGethostbyname() function call to use
+ * getaddrinfo().
*/
pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf),
&h, &herrno);
@@ -583,7 +586,7 @@ static DH *
load_dh_file(int keylength)
{
#ifdef WIN32
- return NULL;
+ return NULL;
#else
char pwdbuf[BUFSIZ];
struct passwd pwdstr;
@@ -730,7 +733,7 @@ static int
client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{
#ifdef WIN32
- return 0;
+ return 0;
#else
char pwdbuf[BUFSIZ];
struct passwd pwdstr;
@@ -765,7 +768,8 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
}
if (PEM_read_X509(fp, x509, NULL, NULL) == NULL)
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not read certificate (%s): %s\n"),
fnbuf, err);
@@ -812,7 +816,8 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
}
if (PEM_read_PrivateKey(fp, pkey, cb, NULL) == NULL)
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not read private key (%s): %s\n"),
fnbuf, err);
@@ -826,7 +831,8 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
/* verify that the cert and key go together */
if (!X509_check_private_key(*x509, *pkey))
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("certificate/private key mismatch (%s): %s\n"),
fnbuf, err);
@@ -845,52 +851,55 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
static unsigned long
pq_threadidcallback(void)
{
- return (unsigned long)pthread_self();
+ return (unsigned long) pthread_self();
}
static pthread_mutex_t *pq_lockarray;
static void
pq_lockingcallback(int mode, int n, const char *file, int line)
{
- if (mode & CRYPTO_LOCK) {
+ if (mode & CRYPTO_LOCK)
pthread_mutex_lock(&pq_lockarray[n]);
- } else {
+ else
pthread_mutex_unlock(&pq_lockarray[n]);
- }
}
-
-#endif /* ENABLE_THREAD_SAFETY */
+#endif /* ENABLE_THREAD_SAFETY */
static int
init_ssl_system(PGconn *conn)
{
#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
- static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
#else
static pthread_mutex_t init_mutex = NULL;
static long mutex_initlock = 0;
- if (init_mutex == NULL) {
- while(InterlockedExchange(&mutex_initlock, 1) == 1)
- /* loop, another thread own the lock */ ;
+ if (init_mutex == NULL)
+ {
+ while (InterlockedExchange(&mutex_initlock, 1) == 1)
+ /* loop, another thread own the lock */ ;
if (init_mutex == NULL)
pthread_mutex_init(&init_mutex, NULL);
- InterlockedExchange(&mutex_initlock,0);
+ InterlockedExchange(&mutex_initlock, 0);
}
#endif
pthread_mutex_lock(&init_mutex);
-
- if (pq_initssllib && pq_lockarray == NULL) {
- int i;
+
+ if (pq_initssllib && pq_lockarray == NULL)
+ {
+ int i;
+
CRYPTO_set_id_callback(pq_threadidcallback);
- pq_lockarray = malloc(sizeof(pthread_mutex_t)*CRYPTO_num_locks());
- if (!pq_lockarray) {
+ pq_lockarray = malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
+ if (!pq_lockarray)
+ {
pthread_mutex_unlock(&init_mutex);
return -1;
}
- for (i=0;i<CRYPTO_num_locks();i++)
+ for (i = 0; i < CRYPTO_num_locks(); i++)
pthread_mutex_init(&pq_lockarray[i], NULL);
CRYPTO_set_locking_callback(pq_lockingcallback);
@@ -898,14 +907,16 @@ init_ssl_system(PGconn *conn)
#endif
if (!SSL_context)
{
- if (pq_initssllib) {
+ if (pq_initssllib)
+ {
SSL_library_init();
SSL_load_error_strings();
}
SSL_context = SSL_CTX_new(TLSv1_method());
if (!SSL_context)
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not create SSL context: %s\n"),
err);
@@ -921,6 +932,7 @@ init_ssl_system(PGconn *conn)
#endif
return 0;
}
+
/*
* Initialize global SSL context.
*/
@@ -935,7 +947,7 @@ initialize_SSL(PGconn *conn)
char fnbuf[2048];
#endif
- if(init_ssl_system(conn))
+ if (init_ssl_system(conn))
return -1;
#ifndef WIN32
@@ -958,7 +970,8 @@ initialize_SSL(PGconn *conn)
}
if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, 0))
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not read root certificate list (%s): %s\n"),
fnbuf, err);
@@ -1030,9 +1043,10 @@ open_client_SSL(PGconn *conn)
}
case SSL_ERROR_SSL:
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), err);
+ libpq_gettext("SSL error: %s\n"), err);
SSLerrfree(err);
close_SSL(conn);
return PGRES_POLLING_FAILED;
@@ -1040,7 +1054,7 @@ open_client_SSL(PGconn *conn)
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code\n"));
+ libpq_gettext("unrecognized SSL error code\n"));
close_SSL(conn);
return PGRES_POLLING_FAILED;
}
@@ -1070,7 +1084,8 @@ open_client_SSL(PGconn *conn)
conn->peer = SSL_get_peer_certificate(conn->ssl);
if (conn->peer == NULL)
{
- char *err = SSLerrmessage();
+ char *err = SSLerrmessage();
+
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("certificate could not be obtained: %s\n"),
err);
@@ -1136,27 +1151,30 @@ close_SSL(PGconn *conn)
* want to return NULL ever.
*/
static char ssl_nomem[] = "Out of memory allocating error description";
-#define SSL_ERR_LEN 128
+
+#define SSL_ERR_LEN 128
static char *
SSLerrmessage(void)
{
unsigned long errcode;
const char *errreason;
- char *errbuf;
+ char *errbuf;
errbuf = malloc(SSL_ERR_LEN);
if (!errbuf)
return ssl_nomem;
errcode = ERR_get_error();
- if (errcode == 0) {
+ if (errcode == 0)
+ {
strcpy(errbuf, "No SSL error reported");
return errbuf;
}
errreason = ERR_reason_error_string(errcode);
- if (errreason != NULL) {
- strncpy(errbuf, errreason, SSL_ERR_LEN-1);
- errbuf[SSL_ERR_LEN-1] = '\0';
+ if (errreason != NULL)
+ {
+ strncpy(errbuf, errreason, SSL_ERR_LEN - 1);
+ errbuf[SSL_ERR_LEN - 1] = '\0';
return errbuf;
}
snprintf(errbuf, SSL_ERR_LEN, "SSL error code %lu", errcode);
@@ -1169,6 +1187,7 @@ SSLerrfree(char *buf)
if (buf != ssl_nomem)
free(buf);
}
+
/*
* Return pointer to SSL object.
*/
@@ -1179,7 +1198,6 @@ PQgetssl(PGconn *conn)
return NULL;
return conn->ssl;
}
-
#endif /* USE_SSL */
@@ -1192,8 +1210,9 @@ void
pq_check_sigpipe_handler(void)
{
pthread_key_create(&pq_thread_in_send, NULL);
+
/*
- * Find current pipe handler and chain on to it.
+ * Find current pipe handler and chain on to it.
*/
pq_pipe_handler = pqsignalinquire(SIGPIPE);
pqsignal(SIGPIPE, sigpipe_handler_ignore_send);
@@ -1206,22 +1225,21 @@ void
sigpipe_handler_ignore_send(int signo)
{
/*
- * If we have gotten a SIGPIPE outside send(), chain or
- * exit if we are at the end of the chain.
- * Synchronous signals are delivered to the thread that
- * caused the signal.
+ * If we have gotten a SIGPIPE outside send(), chain or exit if we are
+ * at the end of the chain. Synchronous signals are delivered to the
+ * thread that caused the signal.
*/
if (!PQinSend())
{
- if (pq_pipe_handler == SIG_DFL) /* not set by application */
+ if (pq_pipe_handler == SIG_DFL) /* not set by application */
exit(128 + SIGPIPE); /* typical return value for SIG_DFL */
else
- (*pq_pipe_handler)(signo); /* call original handler */
+ (*pq_pipe_handler) (signo); /* call original handler */
}
}
#endif
#endif
-
+
/*
* Indicates whether the current thread is in send()
* For use by SIGPIPE signal handlers; they should
@@ -1233,13 +1251,14 @@ PQinSend(void)
{
#ifdef ENABLE_THREAD_SAFETY
return (pthread_getspecific(pq_thread_in_send) /* has it been set? */ &&
- *(char *)pthread_getspecific(pq_thread_in_send) == 't') ? true : false;
+ *(char *) pthread_getspecific(pq_thread_in_send) == 't') ? true : false;
#else
+
/*
- * No threading: our code ignores SIGPIPE around send().
- * Therefore, we can't be in send() if we are checking
- * from a SIGPIPE signal handler.
+ * No threading: our code ignores SIGPIPE around send(). Therefore, we
+ * can't be in send() if we are checking from a SIGPIPE signal
+ * handler.
*/
- return false;
+ return false;
#endif
}
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 60ab1d0d564..ff1a2c1ad69 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.107 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.108 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -248,7 +248,7 @@ extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
extern const char *PQparameterStatus(const PGconn *conn,
const char *paramName);
extern int PQprotocolVersion(const PGconn *conn);
-extern int PQserverVersion(const PGconn *conn);
+extern int PQserverVersion(const PGconn *conn);
extern char *PQerrorMessage(const PGconn *conn);
extern int PQsocket(const PGconn *conn);
extern int PQbackendPID(const PGconn *conn);
@@ -276,15 +276,15 @@ extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,
void *arg);
/*
- * Used to set callback that prevents concurrent access to
- * non-thread safe functions that libpq needs.
- * The default implementation uses a libpq internal mutex.
- * Only required for multithreaded apps that use kerberos
- * both within their app and for postgresql connections.
+ * Used to set callback that prevents concurrent access to
+ * non-thread safe functions that libpq needs.
+ * The default implementation uses a libpq internal mutex.
+ * Only required for multithreaded apps that use kerberos
+ * both within their app and for postgresql connections.
*/
-typedef void (pgthreadlock_t)(int acquire);
+typedef void (pgthreadlock_t) (int acquire);
-extern pgthreadlock_t * PQregisterThreadLock(pgthreadlock_t *newhandler);
+extern pgthreadlock_t *PQregisterThreadLock(pgthreadlock_t *newhandler);
extern void PQinitSSL(int do_init);
@@ -301,12 +301,12 @@ extern PGresult *PQexecParams(PGconn *conn,
const int *paramFormats,
int resultFormat);
extern PGresult *PQexecPrepared(PGconn *conn,
- const char *stmtName,
- int nParams,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
+ const char *stmtName,
+ int nParams,
+ const char *const * paramValues,
+ const int *paramLengths,
+ const int *paramFormats,
+ int resultFormat);
/* Interface for multiple-result or asynchronous queries */
extern int PQsendQuery(PGconn *conn, const char *query);
@@ -319,12 +319,12 @@ extern int PQsendQueryParams(PGconn *conn,
const int *paramFormats,
int resultFormat);
extern int PQsendQueryPrepared(PGconn *conn,
- const char *stmtName,
- int nParams,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
+ const char *stmtName,
+ int nParams,
+ const char *const * paramValues,
+ const int *paramLengths,
+ const int *paramFormats,
+ int resultFormat);
extern PGresult *PQgetResult(PGconn *conn);
/* Routines for managing an asynchronous query */
@@ -417,21 +417,24 @@ extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
/* === in fe-print.c === */
-extern void PQprint(FILE *fout, /* output stream */
- const PGresult *res,
- const PQprintOpt *ps); /* option structure */
+extern void
+PQprint(FILE *fout, /* output stream */
+ const PGresult *res,
+ const PQprintOpt *ps); /* option structure */
/*
* really old printing routines
*/
-extern void PQdisplayTuples(const PGresult *res,
+extern void
+PQdisplayTuples(const PGresult *res,
FILE *fp, /* where to send the output */
int fillAlign, /* pad the fields with spaces */
const char *fieldSep, /* field separator */
int printHeader, /* display headers? */
int quiet);
-extern void PQprintTuples(const PGresult *res,
+extern void
+PQprintTuples(const PGresult *res,
FILE *fout, /* output stream */
int printAttName, /* print attribute names */
int terseOutput, /* delimiter bars */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index ecf8fab50a9..3037b0d2669 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.90 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.91 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -361,13 +361,14 @@ extern int pqPacketSend(PGconn *conn, char pack_type,
#ifdef ENABLE_THREAD_SAFETY
extern pgthreadlock_t *g_threadlock;
+
#define pglock_thread() g_threadlock(true);
#define pgunlock_thread() g_threadlock(false);
#else
#define pglock_thread() ((void)0)
#define pgunlock_thread() ((void)0)
#endif
-
+
/* === in fe-exec.c === */
@@ -455,6 +456,7 @@ extern PostgresPollingStatusType pqsecure_open_client(PGconn *);
extern void pqsecure_close(PGconn *);
extern ssize_t pqsecure_read(PGconn *, void *ptr, size_t len);
extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
+
#ifdef ENABLE_THREAD_SAFETY
extern void pq_check_sigpipe_handler(void);
extern pthread_key_t pq_thread_in_send;
diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c
index 58a2cc01ab9..0afb8e714cb 100644
--- a/src/interfaces/libpq/pqexpbuffer.c
+++ b/src/interfaces/libpq/pqexpbuffer.c
@@ -17,7 +17,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.18 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.19 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,7 +136,7 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed)
/*
* Guard against ridiculous "needed" values, which can occur if we're
- * fed bogus data. Without this, we can get an overflow or infinite
+ * fed bogus data. Without this, we can get an overflow or infinite
* loop in the following.
*/
if (needed >= ((size_t) INT_MAX - str->len))
diff --git a/src/interfaces/libpq/pqsignal.c b/src/interfaces/libpq/pqsignal.c
index 226f90771cd..4bd24b78eb4 100644
--- a/src/interfaces/libpq/pqsignal.c
+++ b/src/interfaces/libpq/pqsignal.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.22 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.23 2004/08/29 05:07:00 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
@@ -50,12 +50,12 @@ pqsignalinquire(int signo)
{
#ifndef WIN32
#if !defined(HAVE_POSIX_SIGNALS)
- pqsigfunc old_sigfunc;
- int old_sigmask;
+ pqsigfunc old_sigfunc;
+ int old_sigmask;
/* Prevent signal handler calls during test */
old_sigmask = sigblock(sigmask(signo));
- old_sigfunc = signal(signo, SIG_DFL);
+ old_sigfunc = signal(signo, SIG_DFL);
signal(signo, old_sigfunc);
sigblock(old_sigmask);
return old_sigfunc;
@@ -63,7 +63,7 @@ pqsignalinquire(int signo)
struct sigaction oact;
if (sigaction(signo, NULL, &oact) < 0)
- return SIG_ERR;
+ return SIG_ERR;
return oact.sa_handler;
#endif /* !HAVE_POSIX_SIGNALS */
#else
diff --git a/src/interfaces/libpq/pthread-win32.c b/src/interfaces/libpq/pthread-win32.c
index 87546424df0..24bdca29185 100644
--- a/src/interfaces/libpq/pthread-win32.c
+++ b/src/interfaces/libpq/pthread-win32.c
@@ -1,11 +1,11 @@
/*-------------------------------------------------------------------------
*
* pthread-win32.c
-* partial pthread implementation for win32
+* partial pthread implementation for win32
*
* Copyright (c) 2004, PostgreSQL Global Development Group
* IDENTIFICATION
-* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.1 2004/06/19 04:22:17 momjian Exp $
+* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.2 2004/08/29 05:07:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,31 +14,37 @@
#include "windows.h"
#include "pthread.h"
-HANDLE pthread_self()
+HANDLE
+pthread_self()
{
- return GetCurrentThread();
+ return GetCurrentThread();
}
-void pthread_setspecific(pthread_key_t key, void *val)
+void
+pthread_setspecific(pthread_key_t key, void *val)
{
}
-void *pthread_getspecific(pthread_key_t key)
+void *
+pthread_getspecific(pthread_key_t key)
{
- return NULL;
+ return NULL;
}
-void pthread_mutex_init(pthread_mutex_t *mp, void *attr)
+void
+pthread_mutex_init(pthread_mutex_t *mp, void *attr)
{
- *mp = CreateMutex(0, 0, 0);
+ *mp = CreateMutex(0, 0, 0);
}
-void pthread_mutex_lock(pthread_mutex_t *mp)
+void
+pthread_mutex_lock(pthread_mutex_t *mp)
{
- WaitForSingleObject(*mp, INFINITE);
+ WaitForSingleObject(*mp, INFINITE);
}
-void pthread_mutex_unlock(pthread_mutex_t *mp)
+void
+pthread_mutex_unlock(pthread_mutex_t *mp)
{
- ReleaseMutex(*mp);
+ ReleaseMutex(*mp);
}
diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c
index 4e5820ec260..b2c77063e1f 100644
--- a/src/interfaces/libpq/win32.c
+++ b/src/interfaces/libpq/win32.c
@@ -314,7 +314,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
{
strerrbuf[buflen - 1] = '\0';
offs = strlen(strerrbuf);
- if (offs > (int)buflen - 64)
+ if (offs > (int) buflen - 64)
offs = buflen - 64;
sprintf(strerrbuf + offs, " (0x%08X/%i)", err, err);
}