summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-09-04 20:31:48 +0000
committerBruce Momjian <bruce@momjian.us>2002-09-04 20:31:48 +0000
commite50f52a074bdf0d6a9dc384840e641c4c0b0bb1a (patch)
treeab73e8c8ec94a6ddc774c1f9c49b87aa6b93fd13 /src/interfaces
parentc91ceec21d357d6d857163d897ac75a79c883dee (diff)
downloadpostgresql-e50f52a074bdf0d6a9dc384840e641c4c0b0bb1a.tar.gz
pgindent run.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/cli/example1.c8
-rw-r--r--src/interfaces/cli/example2.c14
-rw-r--r--src/interfaces/cli/sqlcli.h104
-rw-r--r--src/interfaces/ecpg/include/ecpgerrno.h6
-rw-r--r--src/interfaces/ecpg/include/ecpglib.h3
-rw-r--r--src/interfaces/ecpg/include/ecpgtype.h1
-rw-r--r--src/interfaces/ecpg/lib/connect.c48
-rw-r--r--src/interfaces/ecpg/lib/data.c64
-rw-r--r--src/interfaces/ecpg/lib/descriptor.c85
-rw-r--r--src/interfaces/ecpg/lib/error.c4
-rw-r--r--src/interfaces/ecpg/lib/execute.c57
-rw-r--r--src/interfaces/ecpg/lib/extern.h2
-rw-r--r--src/interfaces/ecpg/lib/memory.c3
-rw-r--r--src/interfaces/ecpg/lib/misc.c8
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c6
-rw-r--r--src/interfaces/ecpg/preproc/extern.h3
-rw-r--r--src/interfaces/ecpg/preproc/type.c18
-rw-r--r--src/interfaces/ecpg/preproc/type.h5
-rw-r--r--src/interfaces/ecpg/preproc/variable.c21
-rw-r--r--src/interfaces/libpgtcl/pgtcl.c4
-rw-r--r--src/interfaces/libpgtcl/pgtclCmds.c15
-rw-r--r--src/interfaces/libpgtcl/pgtclCmds.h4
-rw-r--r--src/interfaces/libpgtcl/pgtclId.c19
-rw-r--r--src/interfaces/libpq/fe-auth.c6
-rw-r--r--src/interfaces/libpq/fe-connect.c72
-rw-r--r--src/interfaces/libpq/fe-exec.c89
-rw-r--r--src/interfaces/libpq/fe-misc.c92
-rw-r--r--src/interfaces/libpq/fe-secure.c483
-rw-r--r--src/interfaces/libpq/libpq-fe.h6
-rw-r--r--src/interfaces/libpq/libpq-int.h19
-rw-r--r--src/interfaces/libpq/win32.c402
-rw-r--r--src/interfaces/python/pgmodule.c6
32 files changed, 924 insertions, 753 deletions
diff --git a/src/interfaces/cli/example1.c b/src/interfaces/cli/example1.c
index 9660ce5719..75cedda3dd 100644
--- a/src/interfaces/cli/example1.c
+++ b/src/interfaces/cli/example1.c
@@ -40,7 +40,7 @@
int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
int
-example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen)
+example1(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen)
{
SQLHENV henv;
SQLHDBC hdbc;
@@ -135,12 +135,12 @@ example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen)
/* this time, explicitly allocate an application row descriptor */
SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc);
SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0,
- (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) &idind);
+ (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) & idind);
SQLSetDescRec(hdesc, 2, SQL_
CHAR, 0, (SQLINTEGER) sizeof(name),
- 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) &namelen,
- (SQLSMALLINT *) &nameind);
+ 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) & namelen,
+ (SQLSMALLINT *) & nameind);
/* associate descriptor with statement handle */
SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0);
/* execute the fetch */
diff --git a/src/interfaces/cli/example2.c b/src/interfaces/cli/example2.c
index 6a4fb56c73..9b02e4f3b7 100644
--- a/src/interfaces/cli/example2.c
+++ b/src/interfaces/cli/example2.c
@@ -39,17 +39,17 @@
#define max(a,b) (a>b?a:b)
int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
-int build_indicator_message(SQLCHAR *errmsg,
+int build_indicator_message(SQLCHAR * errmsg,
SQLPOINTER * data,
SQLINTEGER collen,
- SQLINTEGER *outlen,
+ SQLINTEGER * outlen,
SQLSMALLINT colnum);
SQLINTEGER display_length(SQLSMALLINT coltype,
SQLINTEGER collen,
- SQLCHAR *colname);
+ SQLCHAR * colname);
-example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr)
+example2(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen, SQLCHAR * sqlstr)
{
int i;
SQLHENV henv;
@@ -214,7 +214,7 @@ example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr)
SQLINTEGER
display_length(SQLSMALLINT coltype, SQLINTEGER collen,
- SQLCHAR *colname)
+ SQLCHAR * colname)
{
switch (coltype)
{
@@ -252,8 +252,8 @@ display_length(SQLSMALLINT coltype, SQLINTEGER collen,
}
int
-build_indicator_message(SQLCHAR *errmsg, SQLPOINTER * data,
- SQLINTEGER collen, SQLINTEGER *outlen, SQLSMALLINT colnum)
+build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data,
+ SQLINTEGER collen, SQLINTEGER * outlen, SQLSMALLINT colnum)
{
if (*outlen == SQL_NULL_DATA)
{
diff --git a/src/interfaces/cli/sqlcli.h b/src/interfaces/cli/sqlcli.h
index 2942abf12f..a9145495fc 100644
--- a/src/interfaces/cli/sqlcli.h
+++ b/src/interfaces/cli/sqlcli.h
@@ -473,7 +473,7 @@ SQLRETURN SQLAllocEnv(SQLHENV * EnvironmentHandle);
SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType,
SQLINTEGER InputHandle,
- SQLINTEGER *OutputHandle);
+ SQLINTEGER * OutputHandle);
SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle,
SQLSTMT * StatementHandle);
@@ -483,7 +483,7 @@ SQLRETURN SQLBindCol(SQLHSTMT StatementHandle,
SQLSMALLINT BufferType,
SQLPOINTER Data,
SQLINTEGER BufferLength,
- SQLINTEGER *DataLength);
+ SQLINTEGER * DataLength);
SQLRETURN SQLBindParam(SQLHSTMT StatementHandle,
SQLSMALLINT ParamNumber,
@@ -492,7 +492,7 @@ SQLRETURN SQLBindParam(SQLHSTMT StatementHandle,
SQLINTEGER ParamLength,
SQLSMALLINT Scale,
SQLPOINTER Data,
- SQLINTEGER *DataLength);
+ SQLINTEGER * DataLength);
SQLRETURN SQLCancel(SQLHSTMT StatementHandle);
@@ -501,17 +501,17 @@ SQLRETURN SQLCloseCursor(SQLHSTMT StatementHandle);
SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLSMALLINT FieldIdentifier,
- SQLCHAR *CharacterAttribute,
+ SQLCHAR * CharacterAttribute,
SQLINTEGER BufferLength,
- SQLINTEGER *AttributetLength,
- SQLINTEGER *NumericAttribute);
+ SQLINTEGER * AttributetLength,
+ SQLINTEGER * NumericAttribute);
SQLRETURN SQLConnect(SQLHDBC ConnectionHandle,
- SQLCHAR *ServerName,
+ SQLCHAR * ServerName,
SQLSMALLINT NameLength1,
- SQLCHAR *UserName,
+ SQLCHAR * UserName,
SQLSMALLINT NameLength2,
- SQLCHAR *Authentication,
+ SQLCHAR * Authentication,
SQLSMALLINT NameLength3);
SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle,
@@ -519,22 +519,22 @@ SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle,
SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle,
SQLSMALLINT Direction,
- SQLCHAR *ServerName,
+ SQLCHAR * ServerName,
SQLSMALLINT BufferLength1,
- SQLSMALLINT *NameLength1,
- SQLCHAR *Description,
+ SQLSMALLINT * NameLength1,
+ SQLCHAR * Description,
SQLSMALLINT BufferLength2,
- SQLSMALLINT *NameLength2);
+ SQLSMALLINT * NameLength2);
SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
- SQLCHAR *ColumnName,
+ SQLCHAR * ColumnName,
SQLSMALLINT BufferLength,
- SQLSMALLINT *ColumnNameLength,
- SQLSMALLINT *ColumnType,
- SQLINTEGER *ColumnLength,
- SQLSMALLINT *ColumnScale,
- SQLSMALLINT *Nullable);
+ SQLSMALLINT * ColumnNameLength,
+ SQLSMALLINT * ColumnType,
+ SQLINTEGER * ColumnLength,
+ SQLSMALLINT * ColumnScale,
+ SQLSMALLINT * Nullable);
SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle);
@@ -545,14 +545,14 @@ SQLRETURN SQLEndTran(SQLSMALLINT HandleType,
SQLRETURN SQLError(SQLHENV EnvironmentHandle,
SQLHDBC ConnectionHandle,
SQLSTMT StatementHandle,
- SQLCHAR *Sqlstate,
- SQLINTEGER *NativeError,
- SQLCHAR *MessageText,
+ SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeError,
+ SQLCHAR * MessageText,
SQLINTEGER BufferLength,
- SQLINTEGER *TextLength);
+ SQLINTEGER * TextLength);
SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle,
- SQLCHAR *StatementText,
+ SQLCHAR * StatementText,
SQLSMALLINT StringLength);
SQLRETURN SQLExecute(SQLHSTMT StatementHandle);
@@ -576,38 +576,38 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle,
- SQLCHAR *CursorName,
+ SQLCHAR * CursorName,
SQLSMALLINT BufferLength,
- SQLSMALLINT *NameLength);
+ SQLSMALLINT * NameLength);
SQLRETURN SQLGetData(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLSMALLINT TargetType,
SQLPOINTER TargetValue,
SQLINTEGER BufferLength,
- SQLINTEGER *IndicatorValue);
+ SQLINTEGER * IndicatorValue);
SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecordNumber,
SQLSMALLINT FieldIdentifier,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetDescRec(SQLHDESC DescriptorHandle,
SQLSMALLINT RecordNumber,
- SQLCHAR *Name,
+ SQLCHAR * Name,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength,
- SQLSMALLINT *Type,
- SQLSMALLINT *SubType,
- SQLINTEGER *Length,
- SQLSMALLINT *Precision,
- SQLSMALLINT *Scale,
- SQLSMALLINT *Nullable);
+ SQLSMALLINT * StringLength,
+ SQLSMALLINT * Type,
+ SQLSMALLINT * SubType,
+ SQLINTEGER * Length,
+ SQLSMALLINT * Precision,
+ SQLSMALLINT * Scale,
+ SQLSMALLINT * Nullable);
SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType,
SQLINTEGER Handle,
@@ -615,51 +615,51 @@ SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType,
SQLSMALLINT DiagIdentifier,
SQLPOINTER DiagInfo,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType,
SQLINTEGER Handle,
SQLSMALLINT RecordNumber,
- SQLCHAR *Sqlstate,
- SQLINTEGER *NativeError,
- SQLCHAR *MessageText,
+ SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeError,
+ SQLCHAR * MessageText,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle,
SQLSMALLINT FunctionId,
- SQLSMALLINT *Supported);
+ SQLSMALLINT * Supported);
SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle,
SQLSMALLINT InfoType,
SQLPOINTER InfoValue,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle,
SQLSMALLINT DataType);
SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle,
- SQLINTEGER *ColumnCount);
+ SQLINTEGER * ColumnCount);
SQLRETURN SQLParamData(SQLHSTMT StatementHandle,
SQLPOINTER * Value);
SQLRETURN SQLPrepare(SQLHSTMT StatementHandle,
- SQLCHAR *StatementText,
+ SQLCHAR * StatementText,
SQLSMALLINT StringLength);
@@ -668,7 +668,7 @@ SQLRETURN SQLPutData(SQLHSTMT StatementHandle,
SQLINTEGER StringLength);
SQLRETURN SQLRowCount(SQLHSTMT StatementHandle,
- SQLINTEGER *RowCount);
+ SQLINTEGER * RowCount);
SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER AttributeCursorName,
@@ -676,7 +676,7 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER StringLength);
SQLRETURN SQLSetCursorName(SQLHSTMT StatementHandle,
- SQLCHAR *CursorName,
+ SQLCHAR * CursorName,
SQLSMALLINT NameLength);
SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle,
@@ -692,8 +692,8 @@ SQLRETURN SQLSetDescRec(SQLHDESC DescriptorHandle,
SQLSMALLINT Precision,
SQLSMALLINT Scale,
SQLPOINTER Data,
- SQLINTEGER *StringLength,
- SQLSMALLINT *Indicator);
+ SQLINTEGER * StringLength,
+ SQLSMALLINT * Indicator);
SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h
index 545782e2a6..2106e3dd54 100644
--- a/src/interfaces/ecpg/include/ecpgerrno.h
+++ b/src/interfaces/ecpg/include/ecpgerrno.h
@@ -54,12 +54,12 @@
*/
#define ECPG_WARNING_QUERY_IGNORED -601
/* WARNING: PerformPortalClose: portal "*" not found */
-#define ECPG_WARNING_UNKNOWN_PORTAL -602
+#define ECPG_WARNING_UNKNOWN_PORTAL -602
/* WARNING: BEGIN: already a transaction in progress */
-#define ECPG_WARNING_IN_TRANSACTION -603
+#define ECPG_WARNING_IN_TRANSACTION -603
/* WARNING: AbortTransaction and not in in-progress state */
/* WARNING: COMMIT: no transaction in progress */
-#define ECPG_WARNING_NO_TRANSACTION -604
+#define ECPG_WARNING_NO_TRANSACTION -604
/* WARNING: BlankPortalAssignName: portal * already exists */
#define ECPG_WARNING_PORTAL_EXISTS -605
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 5c295d8728..f2ca4e5a33 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -68,8 +68,9 @@ bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...);
/* dynamic result allocation */
- void ECPGfree_auto_mem(void);
+void ECPGfree_auto_mem(void);
#ifdef __cplusplus
}
+
#endif
diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h
index 29aedf49c6..8f640906e4 100644
--- a/src/interfaces/ecpg/include/ecpgtype.h
+++ b/src/interfaces/ecpg/include/ecpgtype.h
@@ -76,4 +76,5 @@ enum ECPGdtype
#ifdef __cplusplus
}
+
#endif
diff --git a/src/interfaces/ecpg/lib/connect.c b/src/interfaces/ecpg/lib/connect.c
index ae53972e5c..6cc1f0cb5e 100644
--- a/src/interfaces/ecpg/lib/connect.c
+++ b/src/interfaces/ecpg/lib/connect.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.18 2002/03/06 06:10:35 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.19 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -154,10 +154,10 @@ ECPGnoticeProcessor(void *arg, const char *message)
message++;
ECPGlog("WARNING: %s", message);
- /* WARNING: (transaction aborted): queries ignored until END */
+ /* WARNING: (transaction aborted): queries ignored until END */
/*
- * WARNING: current transaction is aborted, queries ignored until end
+ * WARNING: current transaction is aborted, queries ignored until end
* of transaction block
*/
if (strstr(message, "queries ignored") && strstr(message, "transaction")
@@ -167,7 +167,7 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
- /* WARNING: PerformPortalClose: portal "*" not found */
+ /* WARNING: PerformPortalClose: portal "*" not found */
if ((!strncmp(message, "PerformPortalClose: portal", 26)
|| !strncmp(message, "PerformPortalFetch: portal", 26))
&& strstr(message + 26, "not found"))
@@ -176,16 +176,16 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
- /* WARNING: BEGIN: already a transaction in progress */
+ /* WARNING: BEGIN: already a transaction in progress */
if (!strncmp(message, "BEGIN: already a transaction in progress", 40))
{
ECPGnoticeProcessor_raise(ECPG_WARNING_IN_TRANSACTION, message);
return;
}
- /* WARNING: AbortTransaction and not in in-progress state */
- /* WARNING: COMMIT: no transaction in progress */
- /* WARNING: ROLLBACK: no transaction in progress */
+ /* WARNING: AbortTransaction and not in in-progress state */
+ /* WARNING: COMMIT: no transaction in progress */
+ /* WARNING: ROLLBACK: no transaction in progress */
if (!strncmp(message, "AbortTransaction and not in in-progress state", 45)
|| !strncmp(message, "COMMIT: no transaction in progress", 34)
|| !strncmp(message, "ROLLBACK: no transaction in progress", 36))
@@ -194,7 +194,7 @@ ECPGnoticeProcessor(void *arg, const char *message)
return;
}
- /* WARNING: BlankPortalAssignName: portal * already exists */
+ /* WARNING: BlankPortalAssignName: portal * already exists */
if (!strncmp(message, "BlankPortalAssignName: portal", 29)
&& strstr(message + 29, "already exists"))
{
@@ -205,54 +205,54 @@ ECPGnoticeProcessor(void *arg, const char *message)
/* these are harmless - do nothing */
/*
- * WARNING: CREATE TABLE / PRIMARY KEY will create implicit index '*'
+ * WARNING: CREATE TABLE / PRIMARY KEY will create implicit index '*'
* for table '*'
*/
/*
- * WARNING: ALTER TABLE ... ADD CONSTRAINT will create implicit
+ * WARNING: ALTER TABLE ... ADD CONSTRAINT will create implicit
* trigger(s) for FOREIGN KEY check(s)
*/
/*
- * WARNING: CREATE TABLE will create implicit sequence '*' for SERIAL
+ * WARNING: CREATE TABLE will create implicit sequence '*' for SERIAL
* column '*.*'
*/
/*
- * WARNING: CREATE TABLE will create implicit trigger(s) for FOREIGN
+ * WARNING: CREATE TABLE will create implicit trigger(s) for FOREIGN
* KEY check(s)
*/
if ((!strncmp(message, "CREATE TABLE", 12) || !strncmp(message, "ALTER TABLE", 11))
&& strstr(message + 11, "will create implicit"))
return;
- /* WARNING: QUERY PLAN: */
+ /* WARNING: QUERY PLAN: */
if (!strncmp(message, "QUERY PLAN:", 11)) /* do we really see these? */
return;
/*
- * WARNING: DROP TABLE implicitly drops referential integrity trigger
+ * WARNING: DROP TABLE implicitly drops referential integrity trigger
* from table "*"
*/
if (!strncmp(message, "DROP TABLE implicitly drops", 27))
return;
/*
- * WARNING: Caution: DROP INDEX cannot be rolled back, so don't abort
+ * WARNING: Caution: DROP INDEX cannot be rolled back, so don't abort
* now
*/
if (strstr(message, "cannot be rolled back"))
return;
/* these and other unmentioned should set sqlca.sqlwarn[2] */
- /* WARNING: The ':' operator is deprecated. Use exp(x) instead. */
- /* WARNING: Rel *: Uninitialized page 0 - fixing */
- /* WARNING: PortalHeapMemoryFree: * not in alloc set! */
- /* WARNING: Too old parent tuple found - can't continue vc_repair_frag */
- /* WARNING: identifier "*" will be truncated to "*" */
- /* WARNING: InvalidateSharedInvalid: cache state reset */
- /* WARNING: RegisterSharedInvalid: SI buffer overflow */
+ /* WARNING: The ':' operator is deprecated. Use exp(x) instead. */
+ /* WARNING: Rel *: Uninitialized page 0 - fixing */
+ /* WARNING: PortalHeapMemoryFree: * not in alloc set! */
+ /* WARNING: Too old parent tuple found - can't continue vc_repair_frag */
+ /* WARNING: identifier "*" will be truncated to "*" */
+ /* WARNING: InvalidateSharedInvalid: cache state reset */
+ /* WARNING: RegisterSharedInvalid: SI buffer overflow */
sqlca.sqlwarn[2] = 'W';
sqlca.sqlwarn[0] = 'W';
}
@@ -388,9 +388,7 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
}
else
- {
realname = strdup(dbname);
- }
}
else
realname = strdup(dbname);
diff --git a/src/interfaces/ecpg/lib/data.c b/src/interfaces/ecpg/lib/data.c
index 743b0d0339..bfdbe806f1 100644
--- a/src/interfaces/ecpg/lib/data.c
+++ b/src/interfaces/ecpg/lib/data.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.23 2002/01/08 23:34:47 tgl Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.24 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -13,9 +13,9 @@
bool
ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
- enum ECPGttype type, enum ECPGttype ind_type,
- char *var, char *ind, long varcharsize, long offset,
- long ind_offset, bool isarray)
+ enum ECPGttype type, enum ECPGttype ind_type,
+ char *var, char *ind, long varcharsize, long offset,
+ long ind_offset, bool isarray)
{
char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
@@ -54,23 +54,23 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
- *((short *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
+ *((short *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
- *((int *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
+ *((int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
- *((long *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
+ *((long *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
/* ((long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
- *((long long int *) (ind + ind_offset*act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
+ *((long long int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break;
/* case ECPGt_unsigned_long_long:
((unsigned long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);
@@ -118,15 +118,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_short:
/* ((short *) var)[act_tuple] = (short) res;*/
- *((short *) (var + offset*act_tuple)) = (short) res;
+ *((short *) (var + offset * act_tuple)) = (short) res;
break;
case ECPGt_int:
/* ((int *) var)[act_tuple] = (int) res;*/
- *((int *) (var + offset*act_tuple)) = (int) res;
+ *((int *) (var + offset * act_tuple)) = (int) res;
break;
case ECPGt_long:
/* ((long *) var)[act_tuple] = res;*/
- *((long *) (var + offset*act_tuple)) = (long) res;
+ *((long *) (var + offset * act_tuple)) = (long) res;
break;
default:
/* Cannot happen */
@@ -154,15 +154,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_unsigned_short:
/* ((unsigned short *) var)[act_tuple] = (unsigned short) ures;*/
- *((unsigned short *) (var + offset*act_tuple)) = (unsigned short) ures;
+ *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
break;
case ECPGt_unsigned_int:
/* ((unsigned int *) var)[act_tuple] = (unsigned int) ures;*/
- *((unsigned int *) (var + offset*act_tuple)) = (unsigned int) ures;
+ *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
break;
case ECPGt_unsigned_long:
/* ((unsigned long *) var)[act_tuple] = ures;*/
- *((unsigned long *) (var + offset*act_tuple)) = (unsigned long) ures;
+ *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
break;
default:
/* Cannot happen */
@@ -176,7 +176,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (pval)
{
/* ((long long int *) var)[act_tuple] = strtoll(pval, &scan_length, 10);*/
- *((long long int *) (var + offset*act_tuple)) = strtoll(pval, &scan_length, 10);
+ *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0')) /* Garbage left */
{
@@ -186,7 +186,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
/* ((long long int *) var)[act_tuple] = (long long) 0;*/
- *((long long int *) (var + offset*act_tuple)) = (long long) 0;
+ *((long long int *) (var + offset * act_tuple)) = (long long) 0;
break;
#endif /* HAVE_STRTOLL */
@@ -195,7 +195,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (pval)
{
/* ((unsigned long long int *) var)[act_tuple] = strtoull(pval, &scan_length, 10);*/
- *((unsigned long long int *) (var + offset*act_tuple)) = strtoull(pval, &scan_length, 10);
+ *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0')) /* Garbage left */
{
@@ -205,7 +205,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
/* ((unsigned long long int *) var)[act_tuple] = (long long) 0;*/
- *((unsigned long long int *) (var + offset*act_tuple)) = (long long) 0;
+ *((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
break;
#endif /* HAVE_STRTOULL */
@@ -237,11 +237,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
case ECPGt_float:
/* ((float *) var)[act_tuple] = dres;*/
- *((float *) (var + offset*act_tuple)) = dres;
+ *((float *) (var + offset * act_tuple)) = dres;
break;
case ECPGt_double:
/* ((double *) var)[act_tuple] = dres;*/
- *((double *) (var + offset*act_tuple)) = dres;
+ *((double *) (var + offset * act_tuple)) = dres;
break;
default:
/* Cannot happen */
@@ -256,10 +256,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (offset == sizeof(char))
/* ((char *) var)[act_tuple] = false;*/
- *((char *) (var + offset*act_tuple)) = false;
+ *((char *) (var + offset * act_tuple)) = false;
else if (offset == sizeof(int))
/* ((int *) var)[act_tuple] = false;*/
- *((int *) (var + offset*act_tuple)) = false;
+ *((int *) (var + offset * act_tuple)) = false;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
break;
@@ -268,10 +268,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (offset == sizeof(char))
/* ((char *) var)[act_tuple] = true;*/
- *((char *) (var + offset*act_tuple)) = true;
+ *((char *) (var + offset * act_tuple)) = true;
else if (offset == sizeof(int))
/* ((int *) var)[act_tuple] = true;*/
- *((int *) (var + offset*act_tuple)) = true;
+ *((int *) (var + offset * act_tuple)) = true;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
break;
@@ -299,22 +299,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = strlen(pval);*/
- *((short *) (ind + ind_offset*act_tuple)) = strlen(pval);
+ *((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = strlen(pval);*/
- *((int *) (ind + ind_offset*act_tuple)) = strlen(pval);
+ *((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = strlen(pval);*/
- *((long *) (ind + ind_offset*act_tuple)) = strlen(pval);
+ *((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
- *((long long int *) (ind + ind_offset*act_tuple)) = strlen(pval);
+ *((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
break;
#endif /* HAVE_LONG_LONG_INT_64 */
default:
@@ -344,22 +344,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_short:
case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = variable->len;*/
- *((short *) (ind + offset*act_tuple)) = variable->len;
+ *((short *) (ind + offset * act_tuple)) = variable->len;
break;
case ECPGt_int:
case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = variable->len;*/
- *((int *) (ind + offset*act_tuple)) = variable->len;
+ *((int *) (ind + offset * act_tuple)) = variable->len;
break;
case ECPGt_long:
case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = variable->len;*/
- *((long *) (ind + offset*act_tuple)) = variable->len;
+ *((long *) (ind + offset * act_tuple)) = variable->len;
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
- *((long long int *) (ind + ind_offset*act_tuple)) = variable->len;
+ *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
break;
#endif /* HAVE_LONG_LONG_INT_64 */
default:
diff --git a/src/interfaces/ecpg/lib/descriptor.c b/src/interfaces/ecpg/lib/descriptor.c
index 80180e4484..17598fa91a 100644
--- a/src/interfaces/ecpg/lib/descriptor.c
+++ b/src/interfaces/ecpg/lib/descriptor.c
@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.22 2002/01/23 16:34:06 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.23 2002/09/04 20:31:46 momjian Exp $
*/
#include "postgres_fe.h"
@@ -58,7 +58,7 @@ ECPGget_desc_header(int lineno, char *desc_name, int *count)
return false;
*count = PQnfields(ECPGresult);
- sqlca.sqlerrd[2]=1;
+ sqlca.sqlerrd[2] = 1;
ECPGlog("ECPGget_desc_header: found %d attributes.\n", *count);
return true;
}
@@ -149,7 +149,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
int ntuples,
act_tuple;
struct variable data_var;
-
+
va_start(args, index);
ECPGinit_sqlca();
ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
@@ -173,11 +173,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
--index;
type = va_arg(args, enum ECPGdtype);
-
- memset (&data_var, 0, sizeof data_var);
- data_var.type=ECPGt_EORT;
- data_var.ind_type=ECPGt_NO_INDICATOR;
-
+
+ memset(&data_var, 0, sizeof data_var);
+ data_var.type = ECPGt_EORT;
+ data_var.ind_type = ECPGt_NO_INDICATOR;
+
while (type != ECPGd_EODT)
{
char type_str[20];
@@ -196,11 +196,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
switch (type)
{
case (ECPGd_indicator):
- data_var.ind_type=vartype;
- data_var.ind_pointer=var;
- data_var.ind_varcharsize=varcharsize;
- data_var.ind_arrsize=arrsize;
- data_var.ind_offset=offset;
+ data_var.ind_type = vartype;
+ data_var.ind_pointer = var;
+ data_var.ind_varcharsize = varcharsize;
+ data_var.ind_arrsize = arrsize;
+ data_var.ind_offset = offset;
if (data_var.ind_arrsize == 0 || data_var.ind_varcharsize == 0)
data_var.ind_value = *((void **) (data_var.ind_pointer));
else
@@ -208,11 +208,11 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
break;
case ECPGd_data:
- data_var.type=vartype;
- data_var.pointer=var;
- data_var.varcharsize=varcharsize;
- data_var.arrsize=arrsize;
- data_var.offset=offset;
+ data_var.type = vartype;
+ data_var.pointer = var;
+ data_var.varcharsize = varcharsize;
+ data_var.arrsize = arrsize;
+ data_var.offset = offset;
if (data_var.arrsize == 0 || data_var.varcharsize == 0)
data_var.value = *((void **) (data_var.pointer));
else
@@ -279,7 +279,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
break;
-
+
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
@@ -301,14 +301,15 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
return false;
}
/* allocate storage if needed */
- if (arrsize == 0 && var != NULL && *(void**)var == NULL)
+ if (arrsize == 0 && var != NULL && *(void **) var == NULL)
{
- void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
- *(void **)var = mem;
+ void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
+
+ *(void **) var = mem;
ECPGadd_mem(mem, lineno);
var = mem;
}
-
+
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
@@ -327,31 +328,31 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type = va_arg(args, enum ECPGdtype);
}
- if (data_var.type!=ECPGt_EORT)
+ if (data_var.type != ECPGt_EORT)
{
struct statement stmt;
- char *oldlocale;
-
+ char *oldlocale;
+
/* Make sure we do NOT honor the locale for numeric input */
/* since the database gives the standard decimal point */
oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
-
- memset (&stmt, 0, sizeof stmt);
- stmt.lineno=lineno;
-
+
+ memset(&stmt, 0, sizeof stmt);
+ stmt.lineno = lineno;
+
/* desparate try to guess something sensible */
- stmt.connection=ECPGget_connection(NULL);
+ stmt.connection = ECPGget_connection(NULL);
ECPGstore_result(ECPGresult, index, &stmt, &data_var);
-
+
setlocale(LC_NUMERIC, oldlocale);
ECPGfree(oldlocale);
}
- else if (data_var.ind_type!=ECPGt_NO_INDICATOR)
+ else if (data_var.ind_type != ECPGt_NO_INDICATOR)
{
/*
- * this is like ECPGstore_result
- * but since we don't have a data variable at hand, we can't call it
+ * this is like ECPGstore_result but since we don't have a data
+ * variable at hand, we can't call it
*/
if (data_var.ind_arrsize > 0 && ntuples > data_var.ind_arrsize)
{
@@ -363,8 +364,9 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
/* allocate storage if needed */
if (data_var.ind_arrsize == 0 && data_var.ind_pointer != NULL && data_var.ind_value == NULL)
{
- void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
- *(void **)data_var.ind_pointer = mem;
+ void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
+
+ *(void **) data_var.ind_pointer = mem;
ECPGadd_mem(mem, lineno);
data_var.ind_value = mem;
}
@@ -376,7 +378,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
}
- sqlca.sqlerrd[2]=ntuples;
+ sqlca.sqlerrd[2] = ntuples;
return (true);
}
@@ -409,16 +411,17 @@ ECPGallocate_desc(int line, const char *name)
ECPGinit_sqlca();
new = (struct descriptor *) ECPGalloc(sizeof(struct descriptor), line);
- if (!new) return false;
+ if (!new)
+ return false;
new->next = all_descriptors;
new->name = ECPGalloc(strlen(name) + 1, line);
- if (!new->name)
+ if (!new->name)
{
ECPGfree(new);
return false;
}
new->result = PQmakeEmptyPGresult(NULL, 0);
- if (!new->result)
+ if (!new->result)
{
ECPGfree(new->name);
ECPGfree(new);
diff --git a/src/interfaces/ecpg/lib/error.c b/src/interfaces/ecpg/lib/error.c
index ca3e53382e..526634a0f6 100644
--- a/src/interfaces/ecpg/lib/error.c
+++ b/src/interfaces/ecpg/lib/error.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.15 2002/01/07 02:29:15 petere Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.16 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -84,7 +84,7 @@ ECPGraise(int line, int code, const char *str)
case ECPG_ARRAY_INSERT:
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
- "Trying to insert an array of variables in line %d.", line);
+ "Trying to insert an array of variables in line %d.", line);
break;
case ECPG_NO_CONN:
diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c
index 2a95319e2a..bad48a750f 100644
--- a/src/interfaces/ecpg/lib/execute.c
+++ b/src/interfaces/ecpg/lib/execute.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.38 2002/07/20 08:24:18 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.39 2002/09/04 20:31:46 momjian Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -89,7 +89,7 @@ quote_postgres(char *arg, int lineno)
res[ri++] = '\'';
res[ri] = '\0';
-
+
return res;
}
@@ -168,7 +168,7 @@ create_statement(int lineno, struct connection * connection, struct statement **
var->next = NULL;
if (var->ind_type != ECPGt_NO_INDICATOR
- && (var->ind_arrsize == 0 || var->ind_varcharsize == 0))
+ && (var->ind_arrsize == 0 || var->ind_varcharsize == 0))
var->ind_value = *((char **) (var->ind_pointer));
else
var->ind_value = var->ind_pointer;
@@ -390,14 +390,12 @@ ECPGstore_result(const PGresult *results, int act_field,
{
/* special mode for handling char**foo=0 */
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
- {
len += strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
- }
len *= var->offset; /* should be 1, but YMNK */
- len += (ntuples+1) * sizeof(char *);
+ len += (ntuples + 1) * sizeof(char *);
ECPGlog("ECPGstore_result: line %d: allocating %d bytes for %d tuples (char**=0)",
- stmt->lineno,len, ntuples);
+ stmt->lineno, len, ntuples);
}
else
{
@@ -405,7 +403,7 @@ ECPGstore_result(const PGresult *results, int act_field,
/* check strlen for each tuple */
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
- int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
+ int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
if (len > var->varcharsize)
var->varcharsize = len;
@@ -427,31 +425,34 @@ ECPGstore_result(const PGresult *results, int act_field,
}
/* allocate indicator variable if needed */
- if ((var->ind_arrsize == 0 || var->ind_varcharsize == 0) && var->ind_value == NULL && var->ind_pointer!=NULL)
+ if ((var->ind_arrsize == 0 || var->ind_varcharsize == 0) && var->ind_value == NULL && var->ind_pointer != NULL)
{
- int len = var->ind_offset * ntuples;
+ int len = var->ind_offset * ntuples;
+
var->ind_value = (char *) ECPGalloc(len, stmt->lineno);
*((char **) var->ind_pointer) = var->ind_value;
ECPGadd_mem(var->ind_value, stmt->lineno);
}
-
+
/* fill the variable with the tuple(s) */
- if (!var->varcharsize && !var->arrsize &&
- (var->type==ECPGt_char || var->type==ECPGt_unsigned_char))
+ if (!var->varcharsize && !var->arrsize &&
+ (var->type == ECPGt_char || var->type == ECPGt_unsigned_char))
{
/* special mode for handling char**foo=0 */
-
+
/* filling the array of (char*)s */
- char **current_string = (char**) var->value;
+ char **current_string = (char **) var->value;
+
/* storing the data (after the last array element) */
- char *current_data_location = (char*) &current_string[ntuples+1];
-
+ char *current_data_location = (char *) &current_string[ntuples + 1];
+
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
{
- int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
+ int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
+
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
- var->type, var->ind_type, current_data_location,
- var->ind_value, len, 0, 0, isarray))
+ var->type, var->ind_type, current_data_location,
+ var->ind_value, len, 0, 0, isarray))
status = false;
else
{
@@ -460,7 +461,7 @@ ECPGstore_result(const PGresult *results, int act_field,
current_string++;
}
}
-
+
/* terminate the list */
*current_string = NULL;
}
@@ -469,8 +470,8 @@ ECPGstore_result(const PGresult *results, int act_field,
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
{
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
- var->type, var->ind_type, var->value,
- var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray))
+ var->type, var->ind_type, var->value,
+ var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray))
status = false;
}
}
@@ -484,9 +485,9 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
char *mallocedval = NULL;
char *newcopy = NULL;
- /*
- * arrays are not possible unless the attribute is an array too
- * FIXME: we do not know if the attribute is an array here
+ /*
+ * arrays are not possible unless the attribute is an array too FIXME:
+ * we do not know if the attribute is an array here
*/
/* if (var->arrsize > 1 && ...)
@@ -494,7 +495,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL);
return false;
}*/
-
+
/*
* Some special treatment is needed for records since we want their
* contents to arrive in a comma-separated list on insert (I think).
@@ -1116,7 +1117,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
/* initialize auto_mem struct */
ECPGclear_auto_mem();
-
+
status = ECPGexecute(stmt);
free_statement(stmt);
diff --git a/src/interfaces/ecpg/lib/extern.h b/src/interfaces/ecpg/lib/extern.h
index 3fa935d6f0..24073bba4e 100644
--- a/src/interfaces/ecpg/lib/extern.h
+++ b/src/interfaces/ecpg/lib/extern.h
@@ -6,7 +6,7 @@
void ECPGadd_mem(void *ptr, int lineno);
bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
- enum ECPGttype, char *, char *, long, long, long, bool);
+ enum ECPGttype, char *, char *, long, long, long, bool);
struct connection *ECPGget_connection(const char *);
void ECPGinit_sqlca(void);
char *ECPGalloc(long, int);
diff --git a/src/interfaces/ecpg/lib/memory.c b/src/interfaces/ecpg/lib/memory.c
index 5e85261332..2551fda5d3 100644
--- a/src/interfaces/ecpg/lib/memory.c
+++ b/src/interfaces/ecpg/lib/memory.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.8 2001/12/23 12:17:41 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.9 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -53,6 +53,7 @@ void
ECPGadd_mem(void *ptr, int lineno)
{
struct auto_mem *am = (struct auto_mem *) ECPGalloc(sizeof(struct auto_mem), lineno);
+
am->pointer = ptr;
am->next = auto_allocs;
auto_allocs = am;
diff --git a/src/interfaces/ecpg/lib/misc.c b/src/interfaces/ecpg/lib/misc.c
index 4a5573b649..7bbd8df3c5 100644
--- a/src/interfaces/ecpg/lib/misc.c
+++ b/src/interfaces/ecpg/lib/misc.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.12 2002/01/18 15:51:00 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.13 2002/09/04 20:31:46 momjian Exp $ */
#include "postgres_fe.h"
@@ -90,8 +90,10 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
/* if we have no connection we just simulate the command */
if (con && con->connection)
{
- /* if we are not in autocommit mode, already have committed
- * the transaction and get another commit, just ignore it */
+ /*
+ * if we are not in autocommit mode, already have committed the
+ * transaction and get another commit, just ignore it
+ */
if (!con->committed || con->autocommit)
{
if ((res = PQexec(con->connection, transaction)) == NULL)
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 2f20bd95fc..8de3819667 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.56 2002/04/28 17:20:03 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.57 2002/09/04 20:31:46 momjian Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -32,7 +32,7 @@ help(const char *progname)
/* printf is a macro some places; don't #ifdef inside its arguments */
#ifdef YYDEBUG
printf("Usage:\n"
- " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
+ " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
progname);
#else
printf("Usage:\n"
@@ -61,7 +61,7 @@ add_include_path(char *path)
include_paths = mm_alloc(sizeof(struct _include_path));
include_paths->path = path;
include_paths->next = ip;
-
+
}
static void
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index 4ef4f51002..9b90899c09 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -18,7 +18,8 @@ extern char *descriptor_index;
extern char *descriptor_name;
extern char *connection;
extern char *input_filename;
-extern char *yytext, *token_start,
+extern char *yytext,
+ *token_start,
errortext[128];
#ifdef YYDEBUG
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index c064f34d8b..4722f21863 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -26,7 +26,7 @@ mm_strdup(const char *string)
if (new == NULL)
mmerror(OUT_OF_MEMORY, ET_FATAL, "Out of memory\n");
-
+
return new;
}
@@ -183,7 +183,7 @@ get_type(enum ECPGttype type)
/* Dump a type.
The type is dumped as:
type-tag <comma> - enum ECPGttype
- reference-to-variable <comma> - char *
+ reference-to-variable <comma> - char *
size <comma> - long size of this field (if varchar)
arrsize <comma> - long number of elements in the arr
offset <comma> - offset to the next element
@@ -208,7 +208,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
case ECPGt_array:
if (indicator_set && ind_type->type != ECPGt_array)
mmerror(INDICATOR_NOT_ARRAY, ET_FATAL, "Indicator for array/pointer has to be array/pointer.\n");
-
+
switch (type->u.element->type)
{
case ECPGt_array:
@@ -223,7 +223,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
ECPGdump_a_simple(o, name, type->u.element->type,
- type->u.element->size, type->size, NULL, prefix);
+ type->u.element->size, type->size, NULL, prefix);
if (ind_type != NULL)
{
if (ind_type->type == ECPGt_NO_INDICATOR)
@@ -325,7 +325,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use the pointer except for arrays with given
* bounds
*/
- if (arrsize > 0 && siz== NULL)
+ if (arrsize > 0 && siz == NULL)
sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
@@ -376,24 +376,22 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
else
sprintf(pbuf, "%s%s->", prefix ? prefix : "", name);
-
+
prefix = pbuf;
if (ind_type == &ecpg_no_indicator)
- {
ind_p = &struct_no_indicator;
- }
else if (ind_type != NULL)
{
if (arrsiz == 1)
sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
else
sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name);
-
+
ind_prefix = ind_pbuf;
ind_p = ind_type->u.members;
}
-
+
for (p = type->u.members; p; p = p->next)
{
ECPGdump_a_type(o, p->name, p->type, (ind_p != NULL) ? ind_p->name : NULL, (ind_p != NULL) ? ind_p->type : NULL, prefix, ind_prefix, arrsiz, type->struct_sizeof, (ind_p != NULL) ? ind_type->struct_sizeof : NULL);
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index f73bda5060..10d5fc8f48 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -14,7 +14,8 @@ struct ECPGtype
long size; /* For array it is the number of elements.
* For varchar it is the maxsize of the
* area. */
- char *struct_sizeof; /* For a struct this is the sizeof() type as string */
+ char *struct_sizeof; /* For a struct this is the sizeof() type
+ * as string */
union
{
struct ECPGtype *element; /* For an array this is the type
@@ -90,7 +91,7 @@ struct this_type
char *type_str;
int type_dimension;
int type_index;
- char * type_sizeof;
+ char *type_sizeof;
};
struct _include_path
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index fd8b7c9794..34504ccfec 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -242,7 +242,7 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
- list->indicator->name, list->indicator->type, NULL, NULL, 0, NULL, NULL);
+ list->indicator->name, list->indicator->type, NULL, NULL, 0, NULL, NULL);
/* Then release the list element. */
if (mode != 0)
@@ -318,16 +318,17 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
*dimension = type_dimension;
}
-
- if (pointer_len>2)
- { snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d",pointer_len);
- mmerror(PARSE_ERROR, ET_FATAL, errortext);
+
+ if (pointer_len > 2)
+ {
+ snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d", pointer_len);
+ mmerror(PARSE_ERROR, ET_FATAL, errortext);
/* mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
}
- if (pointer_len>1 && type_enum!=ECPGt_char && type_enum!=ECPGt_unsigned_char)
+ if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
mmerror(PARSE_ERROR, ET_FATAL, "No pointer to pointer supported for this type");
- if (pointer_len>1 && (*length >= 0 || *dimension >= 0))
+ if (pointer_len > 1 && (*length >= 0 || *dimension >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (*length >= 0 && *dimension >= 0 && pointer_len)
@@ -364,14 +365,14 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
case ECPGt_char:
case ECPGt_unsigned_char:
/* char ** */
- if (pointer_len==2)
+ if (pointer_len == 2)
{
*length = *dimension = 0;
break;
}
-
+
/* pointer has to get length 0 */
- if (pointer_len==1)
+ if (pointer_len == 1)
*length = 0;
/* one index is the string length */
diff --git a/src/interfaces/libpgtcl/pgtcl.c b/src/interfaces/libpgtcl/pgtcl.c
index e0f64958fe..60f51b800b 100644
--- a/src/interfaces/libpgtcl/pgtcl.c
+++ b/src/interfaces/libpgtcl/pgtcl.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.26 2002/09/02 21:51:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.27 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,7 +151,7 @@ Pgtcl_Init(Tcl_Interp *interp)
"pg_listen",
Pg_listen,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-
+
Tcl_CreateCommand(interp,
"pg_on_connection_loss",
Pg_on_connection_loss,
diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c
index 28680c90fc..d04406c110 100644
--- a/src/interfaces/libpgtcl/pgtclCmds.c
+++ b/src/interfaces/libpgtcl/pgtclCmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.67 2002/09/02 23:41:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.68 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1577,7 +1577,10 @@ Pg_lo_import(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
lobjId = lo_import(conn, filename);
if (lobjId == InvalidOid)
{
- /* What is the maximum size of this? FIXME if this is not a good quess */
+ /*
+ * What is the maximum size of this? FIXME if this is not a good
+ * quess
+ */
snprintf(interp->result, 128, "Pg_lo_import of '%s' failed", filename);
return TCL_ERROR;
}
@@ -2040,10 +2043,10 @@ Pg_on_connection_loss(ClientData cData, Tcl_Interp *interp, int argc, char *argv
if (callback)
{
/*
- * Start the notify event source if it isn't already running.
- * The notify source will cause Tcl to watch read-ready on the
- * connection socket, so that we find out quickly if the connection
- * drops.
+ * Start the notify event source if it isn't already running. The
+ * notify source will cause Tcl to watch read-ready on the
+ * connection socket, so that we find out quickly if the
+ * connection drops.
*/
PgStartNotifyEventSource(connid);
}
diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h
index 97b19da7f4..5cc802a696 100644
--- a/src/interfaces/libpgtcl/pgtclCmds.h
+++ b/src/interfaces/libpgtcl/pgtclCmds.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pgtclCmds.h,v 1.27 2002/09/02 21:51:47 tgl Exp $
+ * $Id: pgtclCmds.h,v 1.28 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -134,6 +134,6 @@ extern int Pg_lo_export(
extern int Pg_listen(
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
extern int Pg_on_connection_loss(
- ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
+ ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
#endif /* PGTCLCMDS_H */
diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c
index 94bacfc000..2187503646 100644
--- a/src/interfaces/libpgtcl/pgtclId.c
+++ b/src/interfaces/libpgtcl/pgtclId.c
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.34 2002/09/02 23:41:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.35 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -289,7 +289,7 @@ PgDelConnectionId(DRIVER_DEL_PROTO)
connid->conn = NULL;
/*
- * Kill the notifier channel, too. We must not do this until after
+ * Kill the notifier channel, too. We must not do this until after
* we've closed the libpq connection, because Tcl will try to close
* the socket itself!
*
@@ -653,8 +653,8 @@ PgNotifyTransferEvents(Pg_ConnectionId * connid)
* This is also a good place to check for unexpected closure of the
* connection (ie, backend crash), in which case we must shut down the
* notify event source to keep Tcl from trying to select() on the now-
- * closed socket descriptor. But don't kill on-connection-loss events;
- * in fact, register one.
+ * closed socket descriptor. But don't kill on-connection-loss
+ * events; in fact, register one.
*/
if (PQsocket(connid->conn) < 0)
PgConnLossTransferEvents(connid);
@@ -678,9 +678,10 @@ PgConnLossTransferEvents(Pg_ConnectionId * connid)
}
/*
- * Shut down the notify event source to keep Tcl from trying to select()
- * on the now-closed socket descriptor. And zap any unprocessed notify
- * events ... but not, of course, the connection-loss event.
+ * Shut down the notify event source to keep Tcl from trying to
+ * select() on the now-closed socket descriptor. And zap any
+ * unprocessed notify events ... but not, of course, the
+ * connection-loss event.
*/
PgStopNotifyEventSource(connid, false);
}
@@ -770,8 +771,8 @@ Pg_Notify_FileHandler(ClientData clientData, int mask)
else
{
/*
- * If there is no input but we have read-ready,
- * assume this means we lost the connection.
+ * If there is no input but we have read-ready, assume this means
+ * we lost the connection.
*/
PgConnLossTransferEvents(connid);
}
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index dbca53c585..5a6e492b64 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.70 2002/09/02 06:11:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.71 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -415,7 +415,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
err_ret->e_data->length,
- (const char *)err_ret->e_data->data);
+ (const char *) err_ret->e_data->data);
#else
#error "bogus configuration"
#endif
@@ -619,7 +619,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
if (password == NULL || *password == '\0')
{
(void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "fe_sendauth: no password supplied\n");
+ "fe_sendauth: no password supplied\n");
return STATUS_ERROR;
}
if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index f7fd94f877..c875ce7a60 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.200 2002/08/30 05:28:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.201 2002/09/04 20:31:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,9 +184,9 @@ static char *conninfo_getval(PQconninfoOption *connOptions,
static void defaultNoticeProcessor(void *arg, const char *message);
static int parseServiceInfo(PQconninfoOption *options,
PQExpBuffer errorMessage);
-char *pwdfMatchesString(char *buf, char *token);
+char *pwdfMatchesString(char *buf, char *token);
char *PasswordFromFile(char *hostname, char *port, char *dbname,
- char *username, char *pwdfile);
+ char *username, char *pwdfile);
/*
* Connecting to a Database
@@ -396,8 +396,8 @@ PQconndefaults(void)
* PGPASSWORD The user's password.
*
* PGPASSWORDFILE
- * A file that contains host:port:database:user:password
- * for authentication
+ * A file that contains host:port:database:user:password
+ * for authentication
*
* PGDATABASE name of database to which to connect if <pgdatabase>
* argument is NULL or a null string
@@ -497,14 +497,17 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
else
conn->dbName = strdup(dbName);
- /* getPasswordFromFile mallocs its result, so we don't need strdup here */
+ /*
+ * getPasswordFromFile mallocs its result, so we don't need strdup
+ * here
+ */
if (pwd)
conn->pgpass = strdup(pwd);
else if ((tmp = getenv("PGPASSWORD")) != NULL)
conn->pgpass = strdup(tmp);
else if ((tmp = PasswordFromFile(conn->pghost, conn->pgport,
- conn->dbName, conn->pguser,
- getenv("PGPASSWORDFILE"))) != NULL)
+ conn->dbName, conn->pguser,
+ getenv("PGPASSWORDFILE"))) != NULL)
conn->pgpass = tmp;
else
conn->pgpass = strdup(DefaultPassword);
@@ -978,9 +981,7 @@ retry2:
{
if (pqsecure_initialize(conn) == -1 ||
pqsecure_open_client(conn) == -1)
- {
goto connect_errReturn;
- }
/* SSL connection finished. Continue to send startup packet */
}
else if (SSLok == 'E')
@@ -1056,15 +1057,18 @@ connectDBComplete(PGconn *conn)
{
PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
- struct timeval remains, *rp = NULL, finish_time, start_time;
+ struct timeval remains,
+ *rp = NULL,
+ finish_time,
+ start_time;
if (conn == NULL || conn->status == CONNECTION_BAD)
return 0;
- /*
- * Prepare to time calculations, if connect_timeout isn't zero.
- */
- if (conn->connect_timeout != NULL)
+ /*
+ * Prepare to time calculations, if connect_timeout isn't zero.
+ */
+ if (conn->connect_timeout != NULL)
{
remains.tv_sec = atoi(conn->connect_timeout);
if (!remains.tv_sec)
@@ -1137,12 +1141,12 @@ connectDBComplete(PGconn *conn)
conn->status = CONNECTION_BAD;
return 0;
}
- if ((finish_time.tv_usec -= start_time.tv_usec) < 0 )
+ if ((finish_time.tv_usec -= start_time.tv_usec) < 0)
{
remains.tv_sec++;
finish_time.tv_usec += 1000000;
}
- if ((remains.tv_usec -= finish_time.tv_usec) < 0 )
+ if ((remains.tv_usec -= finish_time.tv_usec) < 0)
{
remains.tv_sec--;
remains.tv_usec += 1000000;
@@ -1971,8 +1975,8 @@ freePGconn(PGconn *conn)
free(conn->pguser);
if (conn->pgpass)
free(conn->pgpass);
- if (conn->connect_timeout)
- free(conn->connect_timeout);
+ if (conn->connect_timeout)
+ free(conn->connect_timeout);
/* Note that conn->Pfdebug is not ours to close or free */
if (conn->notifyList)
DLFreeList(conn->notifyList);
@@ -2866,9 +2870,10 @@ defaultNoticeProcessor(void *arg, const char *message)
char *
pwdfMatchesString(char *buf, char *token)
{
- char *tbuf,
- *ttok;
- bool bslash = false;
+ char *tbuf,
+ *ttok;
+ bool bslash = false;
+
if (buf == NULL || token == NULL)
return NULL;
tbuf = buf;
@@ -2883,7 +2888,7 @@ pwdfMatchesString(char *buf, char *token)
bslash = true;
}
if (*tbuf == ':' && *ttok == 0 && !bslash)
- return tbuf+1;
+ return tbuf + 1;
bslash = false;
if (*ttok == 0)
return NULL;
@@ -2901,11 +2906,12 @@ pwdfMatchesString(char *buf, char *token)
/* get a password from the password file. */
char *
PasswordFromFile(char *hostname, char *port, char *dbname,
- char *username, char *pwdfile)
+ char *username, char *pwdfile)
{
- FILE *fp;
+ FILE *fp;
+
#define LINELEN NAMEDATALEN*5
- char buf[LINELEN];
+ char buf[LINELEN];
struct stat stat_buf;
if (pwdfile == NULL || strcmp(pwdfile, "") == 0)
@@ -2940,18 +2946,20 @@ PasswordFromFile(char *hostname, char *port, char *dbname,
if (fp == NULL)
return NULL;
- while (!feof(fp)) {
- char *t = buf,
- *ret;
+ while (!feof(fp))
+ {
+ char *t = buf,
+ *ret;
+
fgets(buf, LINELEN - 1, fp);
if (strlen(buf) == 0)
continue;
buf[strlen(buf) - 1] = 0;
if ((t = pwdfMatchesString(t, hostname)) == NULL ||
- (t = pwdfMatchesString(t, port)) == NULL ||
- (t = pwdfMatchesString(t, dbname)) == NULL ||
- (t = pwdfMatchesString(t, username)) == NULL)
+ (t = pwdfMatchesString(t, port)) == NULL ||
+ (t = pwdfMatchesString(t, dbname)) == NULL ||
+ (t = pwdfMatchesString(t, username)) == NULL)
continue;
ret = strdup(t);
fclose(fp);
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 0d1b7ad05b..214f2929fd 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.121 2002/08/24 15:00:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.122 2002/09/04 20:31:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -135,7 +135,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
for (i = binlen; i > 0; i--, vp++)
{
if (*vp == 0 || *vp >= 0x80)
- len += 5; /* '5' is for '\\ooo' */
+ len += 5; /* '5' is for '\\ooo' */
else if (*vp == '\'')
len += 2;
else if (*vp == '\\')
@@ -155,7 +155,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
{
if (*vp == 0 || *vp >= 0x80)
{
- (void)sprintf(rp,"\\\\%03o",*vp);
+ (void) sprintf(rp, "\\\\%03o", *vp);
rp += 5;
}
else if (*vp == '\'')
@@ -181,7 +181,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
}
/*
- * PQunescapeBytea - converts the null terminated string representation
+ * PQunescapeBytea - converts the null terminated string representation
* of a bytea, strtext, into binary, filling a buffer. It returns a
* pointer to the buffer which is NULL on error, and the size of the
* buffer in retbuflen. The pointer may subsequently be used as an
@@ -204,72 +204,83 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
unsigned char *
PQunescapeBytea(unsigned char *strtext, size_t *retbuflen)
{
- size_t buflen;
- unsigned char *buffer, *sp, *bp;
- unsigned int state=0;
-
- if(strtext == NULL)return NULL;
- buflen = strlen(strtext); /* will shrink, also we discover if strtext */
- buffer = (unsigned char *) malloc(buflen); /* isn't NULL terminated */
- if(buffer == NULL)return NULL;
- for(bp = buffer, sp = strtext; *sp != '\0'; bp++, sp++)
+ size_t buflen;
+ unsigned char *buffer,
+ *sp,
+ *bp;
+ unsigned int state = 0;
+
+ if (strtext == NULL)
+ return NULL;
+ buflen = strlen(strtext); /* will shrink, also we discover if
+ * strtext */
+ buffer = (unsigned char *) malloc(buflen); /* isn't NULL terminated */
+ if (buffer == NULL)
+ return NULL;
+ for (bp = buffer, sp = strtext; *sp != '\0'; bp++, sp++)
{
- switch(state)
+ switch (state)
{
case 0:
- if(*sp == '\\')state=1;
+ if (*sp == '\\')
+ state = 1;
*bp = *sp;
break;
case 1:
- if(*sp == '\'') /* state=5 */
- { /* replace \' with 39 */
+ if (*sp == '\'') /* state=5 */
+ { /* replace \' with 39 */
bp--;
*bp = '\'';
buflen--;
- state=0;
+ state = 0;
}
- else if(*sp == '\\') /* state=6 */
- { /* replace \\ with 92 */
+ else if (*sp == '\\') /* state=6 */
+ { /* replace \\ with 92 */
bp--;
*bp = '\\';
buflen--;
- state=0;
+ state = 0;
}
else
{
- if(isdigit(*sp))state=2;
- else state=0;
+ if (isdigit(*sp))
+ state = 2;
+ else
+ state = 0;
*bp = *sp;
}
break;
case 2:
- if(isdigit(*sp))state=3;
- else state=0;
+ if (isdigit(*sp))
+ state = 3;
+ else
+ state = 0;
*bp = *sp;
break;
case 3:
- if(isdigit(*sp)) /* state=4 */
+ if (isdigit(*sp)) /* state=4 */
{
- int v;
+ int v;
+
bp -= 3;
- sscanf(sp-2, "%03o", &v);
+ sscanf(sp - 2, "%03o", &v);
*bp = v;
buflen -= 3;
- state=0;
+ state = 0;
}
else
{
*bp = *sp;
- state=0;
+ state = 0;
}
break;
}
}
- buffer = realloc(buffer,buflen);
+ buffer = realloc(buffer, buflen);
if (buffer == NULL)
return NULL;
- *retbuflen=buflen;
+ *retbuflen = buflen;
return buffer;
}
@@ -894,8 +905,8 @@ parseInput(PGconn *conn)
return;
/*
- * NOTIFY and WARNING messages can happen in any state besides COPY
- * OUT; always process them right away.
+ * NOTIFY and WARNING messages can happen in any state besides
+ * COPY OUT; always process them right away.
*
* Most other messages should only be processed while in BUSY state.
* (In particular, in READY state we hold off further parsing
@@ -1508,13 +1519,13 @@ getNotify(PGconn *conn)
return EOF;
/*
- * Store the relation name right after the PQnotify structure so it can
- * all be freed at once. We don't use NAMEDATALEN because we don't
- * want to tie this interface to a specific server name length.
+ * Store the relation name right after the PQnotify structure so it
+ * can all be freed at once. We don't use NAMEDATALEN because we
+ * don't want to tie this interface to a specific server name length.
*/
newNotify = (PGnotify *) malloc(sizeof(PGnotify) +
- strlen(conn->workBuffer.data) + 1);
- newNotify->relname = (char *)newNotify + sizeof(PGnotify);
+ strlen(conn->workBuffer.data) +1);
+ newNotify->relname = (char *) newNotify + sizeof(PGnotify);
strcpy(newNotify->relname, conn->workBuffer.data);
newNotify->be_pid = be_pid;
DLAddTail(conn->notifyList, DLNewElem(newNotify));
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 8e40a531c2..794e757d56 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.78 2002/08/29 07:22:30 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.79 2002/09/04 20:31:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -104,18 +104,20 @@ pqPutc(char c, PGconn *conn)
static int
pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
{
- /* Strategy to handle blocking and non-blocking connections: Fill
- * the output buffer and flush it repeatedly until either all data
- * has been sent or is at least queued in the buffer.
+ /*
+ * Strategy to handle blocking and non-blocking connections: Fill the
+ * output buffer and flush it repeatedly until either all data has
+ * been sent or is at least queued in the buffer.
*
- * For non-blocking connections, grow the buffer if not all data
- * fits into it and the buffer can't be sent because the socket
- * would block.
+ * For non-blocking connections, grow the buffer if not all data fits
+ * into it and the buffer can't be sent because the socket would
+ * block.
*/
while (nbytes)
{
- size_t avail, remaining;
+ size_t avail,
+ remaining;
/* fill the output buffer */
avail = Max(conn->outBufSize - conn->outCount, 0);
@@ -125,36 +127,40 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
s += remaining;
nbytes -= remaining;
- /* if the data didn't fit completely into the buffer, try to
- * flush the buffer */
+ /*
+ * if the data didn't fit completely into the buffer, try to flush
+ * the buffer
+ */
if (nbytes)
{
- int send_result = pqSendSome(conn);
+ int send_result = pqSendSome(conn);
/* if there were errors, report them */
if (send_result < 0)
return EOF;
- /* if not all data could be sent, increase the output
- * buffer, put the rest of s into it and return
- * successfully. This case will only happen in a
- * non-blocking connection
+ /*
+ * if not all data could be sent, increase the output buffer,
+ * put the rest of s into it and return successfully. This
+ * case will only happen in a non-blocking connection
*/
if (send_result > 0)
{
- /* try to grow the buffer.
- * FIXME: The new size could be chosen more
- * intelligently.
+ /*
+ * try to grow the buffer. FIXME: The new size could be
+ * chosen more intelligently.
*/
- size_t buflen = conn->outCount + nbytes;
+ size_t buflen = conn->outCount + nbytes;
+
if (buflen > conn->outBufSize)
{
- char * newbuf = realloc(conn->outBuffer, buflen);
+ char *newbuf = realloc(conn->outBuffer, buflen);
+
if (!newbuf)
{
/* realloc failed. Probably out of memory */
printfPQExpBuffer(&conn->errorMessage,
- "cannot allocate memory for output buffer\n");
+ "cannot allocate memory for output buffer\n");
return EOF;
}
conn->outBuffer = newbuf;
@@ -169,9 +175,11 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
}
}
- /* pqSendSome was able to send all data. Continue with the next
- * chunk of s. */
- } /* while */
+ /*
+ * pqSendSome was able to send all data. Continue with the next
+ * chunk of s.
+ */
+ } /* while */
return 0;
}
@@ -484,7 +492,7 @@ pqReadData(PGconn *conn)
/* OK, try to read some data */
retry3:
nread = pqsecure_read(conn, conn->inBuffer + conn->inEnd,
- conn->inBufSize - conn->inEnd);
+ conn->inBufSize - conn->inEnd);
if (nread < 0)
{
if (SOCK_ERRNO == EINTR)
@@ -676,7 +684,7 @@ pqSendSome(PGconn *conn)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
+ "\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
/*
@@ -754,9 +762,7 @@ int
pqFlush(PGconn *conn)
{
if (pqSendSome(conn))
- {
return EOF;
- }
return 0;
}
@@ -773,18 +779,18 @@ pqFlush(PGconn *conn)
int
pqWait(int forRead, int forWrite, PGconn *conn)
{
- return pqWaitTimed( forRead, forWrite, conn, (const struct timeval *) NULL);
+ return pqWaitTimed(forRead, forWrite, conn, (const struct timeval *) NULL);
}
int
-pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval *timeout)
+pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout)
{
fd_set input_mask;
fd_set output_mask;
fd_set except_mask;
- struct timeval tmp_timeout;
- struct timeval *ptmp_timeout = NULL;
+ struct timeval tmp_timeout;
+ struct timeval *ptmp_timeout = NULL;
if (conn->sock < 0)
{
@@ -814,17 +820,18 @@ retry5:
FD_SET(conn->sock, &output_mask);
FD_SET(conn->sock, &except_mask);
- if (NULL != timeout)
+ if (NULL != timeout)
+ {
+ /*
+ * select may modify timeout argument on some platforms use
+ * copy
+ */
+ tmp_timeout = *timeout;
+ ptmp_timeout = &tmp_timeout;
+ }
+ if (select(conn->sock + 1, &input_mask, &output_mask,
+ &except_mask, ptmp_timeout) < 0)
{
- /*
- * select may modify timeout argument on some platforms use copy
- */
- tmp_timeout = *timeout;
- ptmp_timeout = &tmp_timeout;
- }
- if (select(conn->sock + 1, &input_mask, &output_mask,
- &except_mask, ptmp_timeout) < 0)
- {
if (SOCK_ERRNO == EINTR)
goto retry5;
printfPQExpBuffer(&conn->errorMessage,
@@ -884,4 +891,5 @@ libpq_gettext(const char *msgid)
return dgettext("libpq", msgid);
}
+
#endif /* ENABLE_NLS */
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index 1ef5d62e1b..8a17c1aa14 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -11,8 +11,8 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.10 2002/07/20 05:43:31 momjian Exp $
- *
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.11 2002/09/04 20:31:47 momjian Exp $
+ *
* NOTES
* The client *requires* a valid server certificate. Since
* SSH tunnels provide anonymous confidentiality, the presumption
@@ -21,27 +21,27 @@
* anonymous connections will use SSH tunnels.
*
* This code verifies the server certificate, to detect simple
- * "man-in-the-middle" and "impersonation" attacks. The
+ * "man-in-the-middle" and "impersonation" attacks. The
* server certificate, or better yet the CA certificate used
* to sign the server certificate, should be present in the
* "$HOME/.postgresql/root.crt" file. If this file isn't
- * readable, or the server certificate can't be validated,
+ * readable, or the server certificate can't be validated,
* pqsecure_open_client() will return an error code.
*
* Additionally, the server certificate's "common name" must
* resolve to the other end of the socket. This makes it
* substantially harder to pull off a "man-in-the-middle" or
* "impersonation" attack even if the server's private key
- * has been stolen. This check limits acceptable network
+ * has been stolen. This check limits acceptable network
* layers to Unix sockets (weird, but legal), TCPv4 and TCPv6.
*
* Unfortunately neither the current front- or back-end handle
* failure gracefully, resulting in the backend hiccupping.
* This points out problems in each (the frontend shouldn't even
* try to do SSL if pqsecure_initialize() fails, and the backend
- * shouldn't crash/recover if an SSH negotiation fails. The
+ * shouldn't crash/recover if an SSH negotiation fails. The
* backend definitely needs to be fixed, to prevent a "denial
- * of service" attack, but I don't know enough about how the
+ * of service" attack, but I don't know enough about how the
* backend works (especially that pre-SSL negotiation) to identify
* a fix.
*
@@ -49,7 +49,7 @@
*
* Unlike the server's static private key, the client's
* static private key ($HOME/.postgresql/postgresql.key)
- * should normally be stored encrypted. However we still
+ * should normally be stored encrypted. However we still
* support EPH since it's useful for other reasons.
*
* ...
@@ -61,9 +61,9 @@
* keeping it closed to everyone else.
*
* The user's certificate and private key are located in
- * $HOME/.postgresql/postgresql.crt
+ * $HOME/.postgresql/postgresql.crt
* and
- * $HOME/.postgresql/postgresql.key
+ * $HOME/.postgresql/postgresql.key
* respectively.
*
* ...
@@ -118,19 +118,19 @@
#ifdef USE_SSL
#include <openssl/ssl.h>
#include <openssl/e_os.h>
-#endif /* USE_SSL */
+#endif /* USE_SSL */
#ifdef USE_SSL
-static int verify_cb(int ok, X509_STORE_CTX *ctx);
-static int verify_peer(PGconn *);
-static DH *load_dh_file(int keylength);
-static DH *load_dh_buffer(const char *, size_t);
-static DH *tmp_dh_cb(SSL *s, int is_export, int keylength);
-static int client_cert_cb(SSL *, X509 **, EVP_PKEY **);
-static int initialize_SSL(PGconn *);
+static int verify_cb(int ok, X509_STORE_CTX *ctx);
+static int verify_peer(PGconn *);
+static DH *load_dh_file(int keylength);
+static DH *load_dh_buffer(const char *, size_t);
+static DH *tmp_dh_cb(SSL *s, int is_export, int keylength);
+static int client_cert_cb(SSL *, X509 **, EVP_PKEY **);
+static int initialize_SSL(PGconn *);
static void destroy_SSL(void);
-static int open_client_SSL(PGconn *);
+static int open_client_SSL(PGconn *);
static void close_SSL(PGconn *);
static const char *SSLerrmessage(void);
#endif
@@ -140,7 +140,7 @@ static SSL_CTX *SSL_context = NULL;
#endif
/* ------------------------------------------------------------ */
-/* Hardcoded values */
+/* Hardcoded values */
/* ------------------------------------------------------------ */
/*
@@ -148,7 +148,7 @@ static SSL_CTX *SSL_context = NULL;
* As discussed above, EDH protects the confidentiality of
* sessions even if the static private key is compromised,
* so we are *highly* motivated to ensure that we can use
- * EDH even if the user... or an attacker... deletes the
+ * EDH even if the user... or an attacker... deletes the
* $HOME/.postgresql/dh*.pem files.
*
* It's not critical that users have EPH keys, but it doesn't
@@ -193,16 +193,16 @@ KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI=\n\
-----END DH PARAMETERS-----\n";
/* ------------------------------------------------------------ */
-/* Procedures common to all secure sessions */
+/* Procedures common to all secure sessions */
/* ------------------------------------------------------------ */
/*
* Initialize global context
*/
int
-pqsecure_initialize (PGconn *conn)
+pqsecure_initialize(PGconn *conn)
{
- int r = 0;
+ int r = 0;
#ifdef USE_SSL
r = initialize_SSL(conn);
@@ -215,7 +215,7 @@ pqsecure_initialize (PGconn *conn)
* Destroy global context
*/
void
-pqsecure_destroy (void)
+pqsecure_destroy(void)
{
#ifdef USE_SSL
destroy_SSL();
@@ -225,10 +225,10 @@ pqsecure_destroy (void)
/*
* Attempt to negotiate secure session.
*/
-int
-pqsecure_open_client (PGconn *conn)
+int
+pqsecure_open_client(PGconn *conn)
{
- int r = 0;
+ int r = 0;
#ifdef USE_SSL
r = open_client_SSL(conn);
@@ -241,7 +241,7 @@ pqsecure_open_client (PGconn *conn)
* Close secure session.
*/
void
-pqsecure_close (PGconn *conn)
+pqsecure_close(PGconn *conn)
{
#ifdef USE_SSL
if (conn->ssl)
@@ -253,9 +253,9 @@ pqsecure_close (PGconn *conn)
* Read data from a secure connection.
*/
ssize_t
-pqsecure_read (PGconn *conn, void *ptr, size_t len)
+pqsecure_read(PGconn *conn, void *ptr, size_t len)
{
- ssize_t n;
+ ssize_t n;
#ifdef USE_SSL
if (conn->ssl)
@@ -263,30 +263,30 @@ pqsecure_read (PGconn *conn, void *ptr, size_t len)
n = SSL_read(conn->ssl, ptr, len);
switch (SSL_get_error(conn->ssl, n))
{
- case SSL_ERROR_NONE:
- break;
- case SSL_ERROR_WANT_READ:
- break;
- case SSL_ERROR_SYSCALL:
- SOCK_ERRNO = get_last_socket_error();
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO));
- break;
- case SSL_ERROR_SSL:
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), SSLerrmessage());
- /* fall through */
- case SSL_ERROR_ZERO_RETURN:
- pqsecure_close(conn);
- SOCK_ERRNO = ECONNRESET;
- n = -1;
- break;
+ case SSL_ERROR_NONE:
+ break;
+ case SSL_ERROR_WANT_READ:
+ break;
+ case SSL_ERROR_SYSCALL:
+ SOCK_ERRNO = get_last_socket_error();
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("SSL SYSCALL error: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO));
+ break;
+ case SSL_ERROR_SSL:
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("SSL error: %s\n"), SSLerrmessage());
+ /* fall through */
+ case SSL_ERROR_ZERO_RETURN:
+ pqsecure_close(conn);
+ SOCK_ERRNO = ECONNRESET;
+ n = -1;
+ break;
}
}
else
#endif
- n = recv(conn->sock, ptr, len, 0);
+ n = recv(conn->sock, ptr, len, 0);
return n;
}
@@ -295,12 +295,12 @@ pqsecure_read (PGconn *conn, void *ptr, size_t len)
* Write data to a secure connection.
*/
ssize_t
-pqsecure_write (PGconn *conn, const void *ptr, size_t len)
+pqsecure_write(PGconn *conn, const void *ptr, size_t len)
{
- ssize_t n;
+ ssize_t n;
#ifndef WIN32
- pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
+ pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
#endif
#ifdef USE_SSL
@@ -309,30 +309,30 @@ pqsecure_write (PGconn *conn, const void *ptr, size_t len)
n = SSL_write(conn->ssl, ptr, len);
switch (SSL_get_error(conn->ssl, n))
{
- case SSL_ERROR_NONE:
- break;
- case SSL_ERROR_WANT_WRITE:
- break;
- case SSL_ERROR_SYSCALL:
- SOCK_ERRNO = get_last_socket_error();
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO));
- break;
- case SSL_ERROR_SSL:
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), SSLerrmessage());
- /* fall through */
- case SSL_ERROR_ZERO_RETURN:
- pqsecure_close(conn);
- SOCK_ERRNO = ECONNRESET;
- n = -1;
- break;
+ case SSL_ERROR_NONE:
+ break;
+ case SSL_ERROR_WANT_WRITE:
+ break;
+ case SSL_ERROR_SYSCALL:
+ SOCK_ERRNO = get_last_socket_error();
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("SSL SYSCALL error: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO));
+ break;
+ case SSL_ERROR_SSL:
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("SSL error: %s\n"), SSLerrmessage());
+ /* fall through */
+ case SSL_ERROR_ZERO_RETURN:
+ pqsecure_close(conn);
+ SOCK_ERRNO = ECONNRESET;
+ n = -1;
+ break;
}
}
else
#endif
- n = send(conn->sock, ptr, len, 0);
+ n = send(conn->sock, ptr, len, 0);
#ifndef WIN32
pqsignal(SIGPIPE, oldsighandler);
@@ -342,7 +342,7 @@ pqsecure_write (PGconn *conn, const void *ptr, size_t len)
}
/* ------------------------------------------------------------ */
-/* SSL specific code */
+/* SSL specific code */
/* ------------------------------------------------------------ */
#ifdef USE_SSL
/*
@@ -357,7 +357,7 @@ pqsecure_write (PGconn *conn, const void *ptr, size_t len)
* for now we accept the default checks.
*/
static int
-verify_cb (int ok, X509_STORE_CTX *ctx)
+verify_cb(int ok, X509_STORE_CTX *ctx)
{
return ok;
}
@@ -367,13 +367,13 @@ verify_cb (int ok, X509_STORE_CTX *ctx)
* This function is not thread-safe due to gethostbyname2().
*/
static int
-verify_peer (PGconn *conn)
+verify_peer(PGconn *conn)
{
struct hostent *h = NULL;
struct sockaddr addr;
struct sockaddr_in *sin;
- socklen_t len;
- char **s;
+ socklen_t len;
+ char **s;
unsigned long l;
/* get the address on the other side of the socket */
@@ -381,8 +381,8 @@ verify_peer (PGconn *conn)
if (getpeername(conn->sock, &addr, &len) == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error querying socket: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO));
+ libpq_gettext("error querying socket: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO));
return -1;
}
@@ -394,31 +394,33 @@ verify_peer (PGconn *conn)
if ((h = gethostbyname2(conn->peer_cn, addr.sa_family)) == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error getting information about host (%s): %s\n"),
- conn->peer_cn, hstrerror(h_errno));
+ libpq_gettext("error getting information about host (%s): %s\n"),
+ conn->peer_cn, hstrerror(h_errno));
return -1;
}
/* does the address match? */
switch (addr.sa_family)
{
- case AF_INET:
- sin = (struct sockaddr_in *) &addr;
- for (s = h->h_addr_list; *s != NULL; s++)
- {
- if (!memcmp(&sin->sin_addr.s_addr, *s, h->h_length))
- return 0;
- }
- break;
+ case AF_INET:
+ sin = (struct sockaddr_in *) & addr;
+ for (s = h->h_addr_list; *s != NULL; s++)
+ {
+ if (!memcmp(&sin->sin_addr.s_addr, *s, h->h_length))
+ return 0;
+ }
+ break;
- default:
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("sorry, this protocol not yet supported\n"));
- return -1;
+ default:
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("sorry, this protocol not yet supported\n"));
+ return -1;
}
- /* the prior test should be definitive, but in practice
- * it sometimes fails. So we also check the aliases. */
+ /*
+ * the prior test should be definitive, but in practice it sometimes
+ * fails. So we also check the aliases.
+ */
for (s = h->h_aliases; *s != NULL; s++)
{
if (strcasecmp(conn->peer_cn, *s) == 0)
@@ -428,20 +430,20 @@ verify_peer (PGconn *conn)
/* generate protocol-aware error message */
switch (addr.sa_family)
{
- case AF_INET:
- sin = (struct sockaddr_in *) &addr;
- l = ntohl(sin->sin_addr.s_addr);
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext(
- "server common name '%s' does not resolve to %ld.%ld.%ld.%ld\n"),
- conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100,
- (l >> 8) % 0x100, l % 0x100);
- break;
- default:
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext(
- "server common name '%s' does not resolve to peer address\n"),
- conn->peer_cn);
+ case AF_INET:
+ sin = (struct sockaddr_in *) & addr;
+ l = ntohl(sin->sin_addr.s_addr);
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext(
+ "server common name '%s' does not resolve to %ld.%ld.%ld.%ld\n"),
+ conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100,
+ (l >> 8) % 0x100, l % 0x100);
+ break;
+ default:
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext(
+ "server common name '%s' does not resolve to peer address\n"),
+ conn->peer_cn);
}
return -1;
@@ -451,24 +453,24 @@ verify_peer (PGconn *conn)
* Load precomputed DH parameters.
*
* To prevent "downgrade" attacks, we perform a number of checks
- * to verify that the DBA-generated DH parameters file contains
+ * to verify that the DBA-generated DH parameters file contains
* what we expect it to contain.
*/
-static DH *
-load_dh_file (int keylength)
+static DH *
+load_dh_file(int keylength)
{
struct passwd *pwd;
- FILE *fp;
- char fnbuf[2048];
- DH *dh = NULL;
- int codes;
+ FILE *fp;
+ char fnbuf[2048];
+ DH *dh = NULL;
+ int codes;
if ((pwd = getpwuid(getuid())) == NULL)
return NULL;
/* attempt to open file. It's not an error if it doesn't exist. */
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem",
- pwd->pw_dir, keylength);
+ pwd->pw_dir, keylength);
if ((fp = fopen(fnbuf, "r")) == NULL)
return NULL;
@@ -478,27 +480,19 @@ load_dh_file (int keylength)
fclose(fp);
/* is the prime the correct size? */
- if (dh != NULL && 8*DH_size(dh) < keylength)
- {
+ if (dh != NULL && 8 * DH_size(dh) < keylength)
dh = NULL;
- }
/* make sure the DH parameters are usable */
if (dh != NULL)
{
if (DH_check(dh, &codes))
- {
return NULL;
- }
if (codes & DH_CHECK_P_NOT_PRIME)
- {
return NULL;
- }
- if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
+ if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
(codes & DH_CHECK_P_NOT_SAFE_PRIME))
- {
return NULL;
- }
}
return dh;
@@ -510,11 +504,11 @@ load_dh_file (int keylength)
* To prevent problems if the DH parameters files don't even
* exist, we can load DH parameters hardcoded into this file.
*/
-static DH *
-load_dh_buffer (const char *buffer, size_t len)
+static DH *
+load_dh_buffer(const char *buffer, size_t len)
{
- BIO *bio;
- DH *dh = NULL;
+ BIO *bio;
+ DH *dh = NULL;
bio = BIO_new_mem_buf((char *) buffer, len);
if (bio == NULL)
@@ -538,62 +532,60 @@ load_dh_buffer (const char *buffer, size_t len)
* the OpenSSL library can efficiently generate random keys from
* the information provided.
*/
-static DH *
-tmp_dh_cb (SSL *s, int is_export, int keylength)
+static DH *
+tmp_dh_cb(SSL *s, int is_export, int keylength)
{
- DH *r = NULL;
- static DH *dh = NULL;
- static DH *dh512 = NULL;
- static DH *dh1024 = NULL;
- static DH *dh2048 = NULL;
- static DH *dh4096 = NULL;
+ DH *r = NULL;
+ static DH *dh = NULL;
+ static DH *dh512 = NULL;
+ static DH *dh1024 = NULL;
+ static DH *dh2048 = NULL;
+ static DH *dh4096 = NULL;
switch (keylength)
{
- case 512:
- if (dh512 == NULL)
- dh512 = load_dh_file(keylength);
- if (dh512 == NULL)
- dh512 = load_dh_buffer(file_dh512, sizeof file_dh512);
- r = dh512;
- break;
-
- case 1024:
- if (dh1024 == NULL)
- dh1024 = load_dh_file(keylength);
- if (dh1024 == NULL)
- dh1024 = load_dh_buffer(file_dh1024, sizeof file_dh1024);
- r = dh1024;
- break;
-
- case 2048:
- if (dh2048 == NULL)
- dh2048 = load_dh_file(keylength);
- if (dh2048 == NULL)
- dh2048 = load_dh_buffer(file_dh2048, sizeof file_dh2048);
- r = dh2048;
- break;
-
- case 4096:
- if (dh4096 == NULL)
- dh4096 = load_dh_file(keylength);
- if (dh4096 == NULL)
- dh4096 = load_dh_buffer(file_dh4096, sizeof file_dh4096);
- r = dh4096;
- break;
-
- default:
- if (dh == NULL)
- dh = load_dh_file(keylength);
- r = dh;
+ case 512:
+ if (dh512 == NULL)
+ dh512 = load_dh_file(keylength);
+ if (dh512 == NULL)
+ dh512 = load_dh_buffer(file_dh512, sizeof file_dh512);
+ r = dh512;
+ break;
+
+ case 1024:
+ if (dh1024 == NULL)
+ dh1024 = load_dh_file(keylength);
+ if (dh1024 == NULL)
+ dh1024 = load_dh_buffer(file_dh1024, sizeof file_dh1024);
+ r = dh1024;
+ break;
+
+ case 2048:
+ if (dh2048 == NULL)
+ dh2048 = load_dh_file(keylength);
+ if (dh2048 == NULL)
+ dh2048 = load_dh_buffer(file_dh2048, sizeof file_dh2048);
+ r = dh2048;
+ break;
+
+ case 4096:
+ if (dh4096 == NULL)
+ dh4096 = load_dh_file(keylength);
+ if (dh4096 == NULL)
+ dh4096 = load_dh_buffer(file_dh4096, sizeof file_dh4096);
+ r = dh4096;
+ break;
+
+ default:
+ if (dh == NULL)
+ dh = load_dh_file(keylength);
+ r = dh;
}
/* this may take a long time, but it may be necessary... */
- if (r == NULL || 8*DH_size(r) < keylength)
- {
+ if (r == NULL || 8 * DH_size(r) < keylength)
r = DH_generate_parameters(keylength, DH_GENERATOR_2, NULL, NULL);
- }
-
+
return r;
}
@@ -605,39 +597,40 @@ tmp_dh_cb (SSL *s, int is_export, int keylength)
* Returns 1 on success, 0 on no data, -1 on error.
*/
static int
-client_cert_cb (SSL *ssl, X509 **x509, EVP_PKEY **pkey)
+client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{
struct passwd *pwd;
- struct stat buf, buf2;
- char fnbuf[2048];
- FILE *fp;
- PGconn *conn = (PGconn *) SSL_get_app_data(ssl);
- int (*cb)() = NULL; /* how to read user password */
+ struct stat buf,
+ buf2;
+ char fnbuf[2048];
+ FILE *fp;
+ PGconn *conn = (PGconn *) SSL_get_app_data(ssl);
+ int (*cb) () = NULL; /* how to read user password */
if ((pwd = getpwuid(getuid())) == NULL)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unable to get user information\n"));
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to get user information\n"));
return -1;
}
/* read the user certificate */
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/postgresql.crt",
- pwd->pw_dir);
+ pwd->pw_dir);
if (stat(fnbuf, &buf) == -1)
return 0;
if ((fp = fopen(fnbuf, "r")) == NULL)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unable to open certificate (%s): %s\n"),
- fnbuf, strerror(errno));
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to open certificate (%s): %s\n"),
+ fnbuf, strerror(errno));
return -1;
}
if (PEM_read_X509(fp, x509, NULL, NULL) == NULL)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unable to read certificate (%s): %s\n"),
- fnbuf, SSLerrmessage());
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to read certificate (%s): %s\n"),
+ fnbuf, SSLerrmessage());
fclose(fp);
return -1;
}
@@ -645,44 +638,44 @@ client_cert_cb (SSL *ssl, X509 **x509, EVP_PKEY **pkey)
/* read the user key */
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/postgresql.key",
- pwd->pw_dir);
+ pwd->pw_dir);
if (stat(fnbuf, &buf) == -1)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate present, but not private key (%s)\n"),
- fnbuf);
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("certificate present, but not private key (%s)\n"),
+ fnbuf);
X509_free(*x509);
return 0;
}
if (!S_ISREG(buf.st_mode) || (buf.st_mode & 0077) ||
buf.st_uid != getuid())
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("private key has bad permissions (%s)\n"), fnbuf);
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("private key has bad permissions (%s)\n"), fnbuf);
X509_free(*x509);
return -1;
}
if ((fp = fopen(fnbuf, "r")) == NULL)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unable to open private key file (%s): %s\n"),
- fnbuf, strerror(errno));
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to open private key file (%s): %s\n"),
+ fnbuf, strerror(errno));
X509_free(*x509);
return -1;
}
if (fstat(fileno(fp), &buf2) == -1 ||
buf.st_dev != buf2.st_dev || buf.st_ino != buf2.st_ino)
{
- printfPQExpBuffer(&conn->errorMessage,
+ printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("private key changed under us (%s)\n"), fnbuf);
X509_free(*x509);
return -1;
}
if (PEM_read_PrivateKey(fp, pkey, cb, NULL) == NULL)
{
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unable to read private key (%s): %s\n"),
- fnbuf, SSLerrmessage());
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to read private key (%s): %s\n"),
+ fnbuf, SSLerrmessage());
X509_free(*x509);
fclose(fp);
return -1;
@@ -692,9 +685,9 @@ 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))
{
- printfPQExpBuffer(&conn->errorMessage,
+ printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("certificate/private key mismatch (%s): %s\n"),
- fnbuf, SSLerrmessage());
+ fnbuf, SSLerrmessage());
X509_free(*x509);
EVP_PKEY_free(*pkey);
return -1;
@@ -707,11 +700,11 @@ client_cert_cb (SSL *ssl, X509 **x509, EVP_PKEY **pkey)
* Initialize global SSL context.
*/
static int
-initialize_SSL (PGconn *conn)
+initialize_SSL(PGconn *conn)
{
struct stat buf;
struct passwd *pwd;
- char fnbuf[2048];
+ char fnbuf[2048];
if (!SSL_context)
{
@@ -721,7 +714,7 @@ initialize_SSL (PGconn *conn)
if (!SSL_context)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create SSL context: %s\n"),
+ libpq_gettext("could not create SSL context: %s\n"),
SSLerrmessage());
return -1;
}
@@ -730,25 +723,25 @@ initialize_SSL (PGconn *conn)
if ((pwd = getpwuid(getuid())) != NULL)
{
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt",
- pwd->pw_dir);
+ pwd->pw_dir);
if (stat(fnbuf, &buf) == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not read root cert list(%s): %s"),
- fnbuf, strerror(errno));
+ libpq_gettext("could not read root cert list(%s): %s"),
+ fnbuf, strerror(errno));
return -1;
}
if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, 0))
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not read root cert list (%s): %s"),
- fnbuf, SSLerrmessage());
+ libpq_gettext("could not read root cert list (%s): %s"),
+ fnbuf, SSLerrmessage());
return -1;
}
}
- SSL_CTX_set_verify(SSL_context,
- SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, verify_cb);
+ SSL_CTX_set_verify(SSL_context,
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, verify_cb);
SSL_CTX_set_verify_depth(SSL_context, 1);
/* set up empheral DH keys */
@@ -765,7 +758,7 @@ initialize_SSL (PGconn *conn)
* Destroy global SSL context.
*/
static void
-destroy_SSL (void)
+destroy_SSL(void)
{
if (SSL_context)
{
@@ -778,9 +771,9 @@ destroy_SSL (void)
* Attempt to negotiate SSL connection.
*/
static int
-open_client_SSL (PGconn *conn)
+open_client_SSL(PGconn *conn)
{
- int r;
+ int r;
if (!(conn->ssl = SSL_new(SSL_context)) ||
!SSL_set_app_data(conn->ssl, conn) ||
@@ -788,21 +781,24 @@ open_client_SSL (PGconn *conn)
SSL_connect(conn->ssl) <= 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not establish SSL connection: %s\n"),
+ libpq_gettext("could not establish SSL connection: %s\n"),
SSLerrmessage());
close_SSL(conn);
return -1;
}
/* check the certificate chain of the server */
- /* this eliminates simple man-in-the-middle attacks and
- * simple impersonations */
+
+ /*
+ * this eliminates simple man-in-the-middle attacks and simple
+ * impersonations
+ */
r = SSL_get_verify_result(conn->ssl);
if (r != X509_V_OK)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate could not be validated: %s\n"),
- X509_verify_cert_error_string(r));
+ libpq_gettext("certificate could not be validated: %s\n"),
+ X509_verify_cert_error_string(r));
close_SSL(conn);
return -1;
}
@@ -812,24 +808,27 @@ open_client_SSL (PGconn *conn)
if (conn->peer == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate could not be obtained: %s\n"),
- SSLerrmessage());
+ libpq_gettext("certificate could not be obtained: %s\n"),
+ SSLerrmessage());
close_SSL(conn);
return -1;
}
X509_NAME_oneline(X509_get_subject_name(conn->peer),
- conn->peer_dn, sizeof(conn->peer_dn));
- conn->peer_dn[sizeof(conn->peer_dn)-1] = '\0';
+ conn->peer_dn, sizeof(conn->peer_dn));
+ conn->peer_dn[sizeof(conn->peer_dn) - 1] = '\0';
X509_NAME_get_text_by_NID(X509_get_subject_name(conn->peer),
- NID_commonName, conn->peer_cn, SM_USER);
+ NID_commonName, conn->peer_cn, SM_USER);
conn->peer_cn[SM_USER] = '\0';
/* verify that the common name resolves to peer */
- /* this is necessary to eliminate man-in-the-middle attacks
- * and impersonations where the attacker somehow learned
- * the server's private key */
+
+ /*
+ * this is necessary to eliminate man-in-the-middle attacks and
+ * impersonations where the attacker somehow learned the server's
+ * private key
+ */
if (verify_peer(conn) == -1)
{
close_SSL(conn);
@@ -843,7 +842,7 @@ open_client_SSL (PGconn *conn)
* Close SSL connection.
*/
static void
-close_SSL (PGconn *conn)
+close_SSL(PGconn *conn)
{
if (conn->ssl)
{
@@ -863,9 +862,9 @@ close_SSL (PGconn *conn)
static const char *
SSLerrmessage(void)
{
- unsigned long errcode;
- const char *errreason;
- static char errbuf[32];
+ unsigned long errcode;
+ const char *errreason;
+ static char errbuf[32];
errcode = ERR_get_error();
if (errcode == 0)
@@ -888,4 +887,4 @@ PQgetssl(PGconn *conn)
return conn->ssl;
}
-#endif /* USE_SSL */
+#endif /* USE_SSL */
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 47606fc211..49045d37b9 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fe.h,v 1.85 2002/06/20 20:29:54 momjian Exp $
+ * $Id: libpq-fe.h,v 1.86 2002/09/04 20:31:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -105,7 +105,7 @@ typedef struct pg_result PGresult;
*/
typedef struct pgNotify
{
- char *relname; /* name of relation containing data */
+ char *relname; /* name of relation containing data */
int be_pid; /* process id of backend */
} PGnotify;
@@ -252,7 +252,7 @@ extern size_t PQescapeString(char *to, const char *from, size_t length);
extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen,
size_t *bytealen);
extern unsigned char *PQunescapeBytea(unsigned char *strtext,
- size_t *retbuflen);
+ size_t *retbuflen);
/* Simple synchronous query */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 83022f70bf..daf2f9ae0b 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-int.h,v 1.56 2002/09/03 21:45:44 petere Exp $
+ * $Id: libpq-int.h,v 1.57 2002/09/04 20:31:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,8 +25,9 @@
#include <sys/types.h>
#if defined(WIN32) && (!defined(ssize_t))
- typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast not VC6) */
-#endif
+typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast
+ * not VC6) */
+#endif
/* We assume libpq-fe.h has already been included. */
#include "postgres_fe.h"
@@ -278,8 +279,8 @@ struct pg_conn
bool require_ssl; /* Require SSL to make connection */
SSL *ssl; /* SSL status, if have SSL connection */
X509 *peer; /* X509 cert of server */
- char peer_dn[256+1]; /* peer distinguished name */
- char peer_cn[SM_USER+1]; /* peer common name */
+ char peer_dn[256 + 1]; /* peer distinguished name */
+ char peer_cn[SM_USER + 1]; /* peer common name */
#endif
/* Buffer for current error message */
@@ -290,7 +291,7 @@ struct pg_conn
int client_encoding; /* encoding id */
- char *connect_timeout;
+ char *connect_timeout;
};
/* String descriptions of the ExecStatusTypes.
@@ -337,15 +338,15 @@ extern int pqReadData(PGconn *conn);
extern int pqFlush(PGconn *conn);
extern int pqSendSome(PGconn *conn);
extern int pqWait(int forRead, int forWrite, PGconn *conn);
-extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval* timeout);
+extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout);
extern int pqReadReady(PGconn *conn);
extern int pqWriteReady(PGconn *conn);
/* === in fe-secure.c === */
-extern int pqsecure_initialize(PGconn *);
+extern int pqsecure_initialize(PGconn *);
extern void pqsecure_destroy(void);
-extern int pqsecure_open_client(PGconn *);
+extern int 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);
diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c
index 4b577e3bfc..17fe9ca93e 100644
--- a/src/interfaces/libpq/win32.c
+++ b/src/interfaces/libpq/win32.c
@@ -9,7 +9,7 @@
* descriptions. But will/may contain other win32 helper functions
* for libpq.
*
- * The error constants are taken from the Frambak Bakfram LGSOCKET
+ * The error constants are taken from the Frambak Bakfram LGSOCKET
* library guys who in turn took them from the Winsock FAQ.
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
@@ -30,100 +30,232 @@
#include <stdio.h>
#include "win32.h"
-static struct WSErrorEntry {
- DWORD error;
- const char* description;
-} WSErrors [] = {
- {0, "No error"},
- {WSAEINTR, "Interrupted system call"},
- {WSAEBADF, "Bad file number"},
- {WSAEACCES, "Permission denied"},
- {WSAEFAULT, "Bad address"},
- {WSAEINVAL, "Invalid argument"},
- {WSAEMFILE, "Too many open sockets"},
- {WSAEWOULDBLOCK, "Operation would block"},
- {WSAEINPROGRESS, "Operation now in progress"},
- {WSAEALREADY, "Operation already in progress"},
- {WSAENOTSOCK, "Socket operation on non-socket"},
- {WSAEDESTADDRREQ, "Destination address required"},
- {WSAEMSGSIZE, "Message too long"},
- {WSAEPROTOTYPE, "Protocol wrong type for socket"},
- {WSAENOPROTOOPT, "Bad protocol option"},
- {WSAEPROTONOSUPPORT, "Protocol not supported"},
- {WSAESOCKTNOSUPPORT, "Socket type not supported"},
- {WSAEOPNOTSUPP, "Operation not supported on socket"},
- {WSAEPFNOSUPPORT, "Protocol family not supported"},
- {WSAEAFNOSUPPORT, "Address family not supported"},
- {WSAEADDRINUSE, "Address already in use"},
- {WSAEADDRNOTAVAIL, "Can't assign requested address"},
- {WSAENETDOWN, "Network is down"},
- {WSAENETUNREACH, "Network is unreachable"},
- {WSAENETRESET, "Net connection reset"},
- {WSAECONNABORTED, "Software caused connection abort"},
- {WSAECONNRESET, "Connection reset by peer"},
- {WSAENOBUFS, "No buffer space available"},
- {WSAEISCONN, "Socket is already connected"},
- {WSAENOTCONN, "Socket is not connected"},
- {WSAESHUTDOWN, "Can't send after socket shutdown"},
- {WSAETOOMANYREFS, "Too many references, can't splice"},
- {WSAETIMEDOUT, "Connection timed out"},
- {WSAECONNREFUSED, "Connection refused"},
- {WSAELOOP, "Too many levels of symbolic links"},
- {WSAENAMETOOLONG, "File name too long"},
- {WSAEHOSTDOWN, "Host is down"},
- {WSAEHOSTUNREACH, "No route to host"},
- {WSAENOTEMPTY, "Directory not empty"},
- {WSAEPROCLIM, "Too many processes"},
- {WSAEUSERS, "Too many users"},
- {WSAEDQUOT, "Disc quota exceeded"},
- {WSAESTALE, "Stale NFS file handle"},
- {WSAEREMOTE, "Too many levels of remote in path"},
- {WSASYSNOTREADY, "Network system is unavailable"},
- {WSAVERNOTSUPPORTED, "Winsock version out of range"},
- {WSANOTINITIALISED, "WSAStartup not yet called"},
- {WSAEDISCON, "Graceful shutdown in progress"},
- {WSAHOST_NOT_FOUND, "Host not found"},
- {WSATRY_AGAIN, "NA Host not found / SERVFAIL"},
- {WSANO_RECOVERY, "Non recoverable FORMERR||REFUSED||NOTIMP"},
- {WSANO_DATA, "No host data of that type was found"},
- {0,0} /* End of table */
+static struct WSErrorEntry
+{
+ DWORD error;
+ const char *description;
+} WSErrors[] =
+
+{
+ {
+ 0, "No error"
+ },
+ {
+ WSAEINTR, "Interrupted system call"
+ },
+ {
+ WSAEBADF, "Bad file number"
+ },
+ {
+ WSAEACCES, "Permission denied"
+ },
+ {
+ WSAEFAULT, "Bad address"
+ },
+ {
+ WSAEINVAL, "Invalid argument"
+ },
+ {
+ WSAEMFILE, "Too many open sockets"
+ },
+ {
+ WSAEWOULDBLOCK, "Operation would block"
+ },
+ {
+ WSAEINPROGRESS, "Operation now in progress"
+ },
+ {
+ WSAEALREADY, "Operation already in progress"
+ },
+ {
+ WSAENOTSOCK, "Socket operation on non-socket"
+ },
+ {
+ WSAEDESTADDRREQ, "Destination address required"
+ },
+ {
+ WSAEMSGSIZE, "Message too long"
+ },
+ {
+ WSAEPROTOTYPE, "Protocol wrong type for socket"
+ },
+ {
+ WSAENOPROTOOPT, "Bad protocol option"
+ },
+ {
+ WSAEPROTONOSUPPORT, "Protocol not supported"
+ },
+ {
+ WSAESOCKTNOSUPPORT, "Socket type not supported"
+ },
+ {
+ WSAEOPNOTSUPP, "Operation not supported on socket"
+ },
+ {
+ WSAEPFNOSUPPORT, "Protocol family not supported"
+ },
+ {
+ WSAEAFNOSUPPORT, "Address family not supported"
+ },
+ {
+ WSAEADDRINUSE, "Address already in use"
+ },
+ {
+ WSAEADDRNOTAVAIL, "Can't assign requested address"
+ },
+ {
+ WSAENETDOWN, "Network is down"
+ },
+ {
+ WSAENETUNREACH, "Network is unreachable"
+ },
+ {
+ WSAENETRESET, "Net connection reset"
+ },
+ {
+ WSAECONNABORTED, "Software caused connection abort"
+ },
+ {
+ WSAECONNRESET, "Connection reset by peer"
+ },
+ {
+ WSAENOBUFS, "No buffer space available"
+ },
+ {
+ WSAEISCONN, "Socket is already connected"
+ },
+ {
+ WSAENOTCONN, "Socket is not connected"
+ },
+ {
+ WSAESHUTDOWN, "Can't send after socket shutdown"
+ },
+ {
+ WSAETOOMANYREFS, "Too many references, can't splice"
+ },
+ {
+ WSAETIMEDOUT, "Connection timed out"
+ },
+ {
+ WSAECONNREFUSED, "Connection refused"
+ },
+ {
+ WSAELOOP, "Too many levels of symbolic links"
+ },
+ {
+ WSAENAMETOOLONG, "File name too long"
+ },
+ {
+ WSAEHOSTDOWN, "Host is down"
+ },
+ {
+ WSAEHOSTUNREACH, "No route to host"
+ },
+ {
+ WSAENOTEMPTY, "Directory not empty"
+ },
+ {
+ WSAEPROCLIM, "Too many processes"
+ },
+ {
+ WSAEUSERS, "Too many users"
+ },
+ {
+ WSAEDQUOT, "Disc quota exceeded"
+ },
+ {
+ WSAESTALE, "Stale NFS file handle"
+ },
+ {
+ WSAEREMOTE, "Too many levels of remote in path"
+ },
+ {
+ WSASYSNOTREADY, "Network system is unavailable"
+ },
+ {
+ WSAVERNOTSUPPORTED, "Winsock version out of range"
+ },
+ {
+ WSANOTINITIALISED, "WSAStartup not yet called"
+ },
+ {
+ WSAEDISCON, "Graceful shutdown in progress"
+ },
+ {
+ WSAHOST_NOT_FOUND, "Host not found"
+ },
+ {
+ WSATRY_AGAIN, "NA Host not found / SERVFAIL"
+ },
+ {
+ WSANO_RECOVERY, "Non recoverable FORMERR||REFUSED||NOTIMP"
+ },
+ {
+ WSANO_DATA, "No host data of that type was found"
+ },
+ {
+ 0, 0
+ } /* End of table */
};
-/*
+/*
* Returns 0 if not found, linear but who cares, at this moment
* we're already in pain :)
*/
-static int LookupWSErrorMessage(DWORD err,char*dest)
-{
- struct WSErrorEntry *e;
- for (e = WSErrors;e->description;e++)
- {
- if (e->error == err)
- {
- strcpy(dest,e->description);
- return 1;
- }
- }
- return 0;
+static int
+LookupWSErrorMessage(DWORD err, char *dest)
+{
+ struct WSErrorEntry *e;
+
+ for (e = WSErrors; e->description; e++)
+ {
+ if (e->error == err)
+ {
+ strcpy(dest, e->description);
+ return 1;
+ }
+ }
+ return 0;
}
-struct MessageDLL{
- const char *dll_name;
- void *handle;
- int loaded; /* BOOL */
-}dlls[]={
- {"netmsg.dll",0,0},
- {"winsock.dll",0,0},
- {"wsock32.dll",0,0},
- {"ws2_32.dll",0,0},
- {"wsock32n.dll",0,0},
- {"mswsock.dll",0,0},
- {"ws2help.dll",0,0},
- {"ws2thk.dll",0,0},
- {0,0,1} /* Last one, no dll, always loaded */
+struct MessageDLL
+{
+ const char *dll_name;
+ void *handle;
+ int loaded; /* BOOL */
+} dlls[] =
+
+{
+ {
+ "netmsg.dll", 0, 0
+ },
+ {
+ "winsock.dll", 0, 0
+ },
+ {
+ "wsock32.dll", 0, 0
+ },
+ {
+ "ws2_32.dll", 0, 0
+ },
+ {
+ "wsock32n.dll", 0, 0
+ },
+ {
+ "mswsock.dll", 0, 0
+ },
+ {
+ "ws2help.dll", 0, 0
+ },
+ {
+ "ws2thk.dll", 0, 0
+ },
+ {
+ 0, 0, 1
+ } /* Last one, no dll, always loaded */
};
#define DLLS_SIZE (sizeof(dlls)/sizeof(struct MessageDLL))
@@ -132,58 +264,58 @@ struct MessageDLL{
* Returns a description of the socket error by first trying
* to find it in the lookup table, and if that fails, tries
* to load any of the winsock dlls to find that message.
- * The DLL thing works from Nt4 (spX ?) up, but some special
+ * The DLL thing works from Nt4 (spX ?) up, but some special
* versions of winsock might have this aswell (seen on Win98 SE
- * special install) / Magnus Naeslund (mag@fbab.net)
+ * special install) / Magnus Naeslund (mag@fbab.net)
*
*/
-const char *winsock_strerror(int err){
- static char buf[512]; /* Not threadsafe */
- unsigned long flags;
- int offs,i;
- int success = LookupWSErrorMessage(err,buf);
-
- for (i=0;!success && i<DLLS_SIZE;i++)
- {
-
- if (!dlls[i].loaded)
- {
- dlls[i].loaded = 1; /* Only load once */
- dlls[i].handle = (void*)LoadLibraryEx(
- dlls[i].dll_name,
- 0,
- LOAD_LIBRARY_AS_DATAFILE);
- }
-
- if (dlls[i].dll_name && !dlls[i].handle)
- continue; /* Didn't load */
-
- flags = FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_IGNORE_INSERTS
- | (dlls[i].handle?FORMAT_MESSAGE_FROM_HMODULE:0);
-
- success = 0 != FormatMessage(
- flags,
- dlls[i].handle,err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- buf,sizeof(buf)-64,
- 0
- );
- }
-
- if (!success)
- {
- sprintf(buf,"Unknown socket error (0x%08X/%lu)",err,err);
- }
- else
- {
- buf[sizeof(buf)-1]='\0';
- offs = strlen(buf);
- if (offs>sizeof(buf)-64)
- offs = sizeof(buf)-64;
- sprintf(buf+offs," (0x%08X/%lu)",err,err);
- }
- return buf;
-}
+const char *
+winsock_strerror(int err)
+{
+ static char buf[512]; /* Not threadsafe */
+ unsigned long flags;
+ int offs,
+ i;
+ int success = LookupWSErrorMessage(err, buf);
+
+ for (i = 0; !success && i < DLLS_SIZE; i++)
+ {
+ if (!dlls[i].loaded)
+ {
+ dlls[i].loaded = 1; /* Only load once */
+ dlls[i].handle = (void *) LoadLibraryEx(
+ dlls[i].dll_name,
+ 0,
+ LOAD_LIBRARY_AS_DATAFILE);
+ }
+
+ if (dlls[i].dll_name && !dlls[i].handle)
+ continue; /* Didn't load */
+
+ flags = FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS
+ | (dlls[i].handle ? FORMAT_MESSAGE_FROM_HMODULE : 0);
+
+ success = 0 != FormatMessage(
+ flags,
+ dlls[i].handle, err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buf, sizeof(buf) - 64,
+ 0
+ );
+ }
+
+ if (!success)
+ sprintf(buf, "Unknown socket error (0x%08X/%lu)", err, err);
+ else
+ {
+ buf[sizeof(buf) - 1] = '\0';
+ offs = strlen(buf);
+ if (offs > sizeof(buf) - 64)
+ offs = sizeof(buf) - 64;
+ sprintf(buf + offs, " (0x%08X/%lu)", err, err);
+ }
+ return buf;
+}
diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c
index fcda897deb..4dd85e0eea 100644
--- a/src/interfaces/python/pgmodule.c
+++ b/src/interfaces/python/pgmodule.c
@@ -1966,9 +1966,9 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
* one */
s++;
- for (k = 0;
- *s && k < sizeof(cashbuf)/sizeof(cashbuf[0])-1;
- s++)
+ for (k = 0;
+ *s && k < sizeof(cashbuf) / sizeof(cashbuf[0]) - 1;
+ s++)
{
if (*s != ',')
cashbuf[k++] = *s;