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

Run pgindent on 9.2 source tree in preparation for first 9.3

commit-fest.
This commit is contained in:
Bruce Momjian
2012-06-10 15:20:04 -04:00
parent 60801944fa
commit 927d61eeff
494 changed files with 7343 additions and 7046 deletions

View File

@ -267,7 +267,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
struct sqlca_t *sqlca = ECPGget_sqlca();
enum COMPAT_MODE compat = c;
struct connection *this;
int i, connect_params = 0;
int i,
connect_params = 0;
char *dbname = name ? ecpg_strdup(name, lineno) : NULL,
*host = NULL,
*tmp,
@ -505,10 +506,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
connect_params++;
/* allocate enough space for all connection parameters */
conn_keywords = (const char **) ecpg_alloc((connect_params + 1) * sizeof (char *), lineno);
conn_values = (const char **) ecpg_alloc(connect_params * sizeof (char *), lineno);
conn_keywords = (const char **) ecpg_alloc((connect_params + 1) * sizeof(char *), lineno);
conn_values = (const char **) ecpg_alloc(connect_params * sizeof(char *), lineno);
if (conn_keywords == NULL || conn_values == NULL)
{
{
if (host)
ecpg_free(host);
if (port)
@ -560,23 +561,25 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
if (options)
{
char *str;
char *str;
/* options look like this "option1 = value1 option2 = value2 ... */
/* we have to break up the string into single options */
for (str = options; *str;)
{
int e, a;
char *token1, *token2;
int e,
a;
char *token1,
*token2;
for (token1 = str; *token1 && *token1 == ' '; token1++);
for (token1 = str; *token1 && *token1 == ' '; token1++);
for (e = 0; token1[e] && token1[e] != '='; e++);
if (token1[e]) /* found "=" */
if (token1[e]) /* found "=" */
{
token1[e] = '\0';
for (token2 = token1 + e + 1; *token2 && *token2 == ' '; token2++);
for (a = 0; token2[a] && token2[a] != '&'; a++);
if (token2[a]) /* found "&" => another option follows */
if (token2[a]) /* found "&" => another option follows */
{
token2[a] = '\0';
str = token2 + a + 1;
@ -587,10 +590,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
conn_keywords[i] = token1;
conn_values[i] = token2;
i++;
}
}
else
/* the parser should not be able to create this invalid option */
str = token1 + e;
str = token1 + e;
}
}

View File

@ -1441,7 +1441,7 @@ ecpg_execute(struct statement * stmt)
ecpg_log("ecpg_execute on line %d: query: %s; with %d parameter(s) on connection %s\n", stmt->lineno, stmt->command, nParams, stmt->connection->name);
if (stmt->statement_type == ECPGst_execute)
{
results = PQexecPrepared(stmt->connection->connection, stmt->name, nParams, (const char *const*) paramValues, NULL, NULL, 0);
results = PQexecPrepared(stmt->connection->connection, stmt->name, nParams, (const char *const *) paramValues, NULL, NULL, 0);
ecpg_log("ecpg_execute on line %d: using PQexecPrepared for \"%s\"\n", stmt->lineno, stmt->command);
}
else
@ -1453,7 +1453,7 @@ ecpg_execute(struct statement * stmt)
}
else
{
results = PQexecParams(stmt->connection->connection, stmt->command, nParams, NULL, (const char *const*) paramValues, NULL, NULL, 0);
results = PQexecParams(stmt->connection->connection, stmt->command, nParams, NULL, (const char *const *) paramValues, NULL, NULL, 0);
ecpg_log("ecpg_execute on line %d: using PQexecParams\n", stmt->lineno);
}
}

View File

@ -123,8 +123,8 @@ struct variable
struct var_list
{
int number;
void *pointer;
int number;
void *pointer;
struct var_list *next;
};
@ -170,7 +170,7 @@ void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
char *ecpg_prepared(const char *, struct connection *);
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn);
void ecpg_log(const char *format, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
void ecpg_log(const char *format,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t * sqlca);

View File

@ -334,12 +334,12 @@ do { \
int DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
int DecodeTime(char *, int *, struct tm *, fsec_t *);
int EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
int EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
int EncodeDateTime(struct tm * tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
int DecodeUnits(int field, char *lowtoken, int *val);
bool CheckDateTokenTables(void);
int EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
int EncodeDateOnly(struct tm * tm, int style, char *str, bool EuroDates);
int GetEpochTime(struct tm *);
int ParseDateTime(char *, char *, char **, int *, int *, char **);
int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);

View File

@ -396,7 +396,10 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
/* If we created a varchar structure atomatically, counter is greater than 0. */
/*
* If we created a varchar structure atomatically, counter is
* greater than 0.
*/
if (counter)
sprintf(offset, "sizeof(struct varchar_%d)", counter);
else

View File

@ -298,7 +298,7 @@ static void closePGconn(PGconn *conn);
static PQconninfoOption *conninfo_init(PQExpBuffer errorMessage);
static PQconninfoOption *parse_connection_string(const char *conninfo,
PQExpBuffer errorMessage, bool use_defaults);
static int uri_prefix_length(const char *connstr);
static int uri_prefix_length(const char *connstr);
static bool recognized_connection_string(const char *connstr);
static PQconninfoOption *conninfo_parse(const char *conninfo,
PQExpBuffer errorMessage, bool use_defaults);
@ -308,7 +308,7 @@ static PQconninfoOption *conninfo_array_parse(const char *const * keywords,
static bool conninfo_add_defaults(PQconninfoOption *options,
PQExpBuffer errorMessage);
static PQconninfoOption *conninfo_uri_parse(const char *uri,
PQExpBuffer errorMessage, bool use_defaults);
PQExpBuffer errorMessage, bool use_defaults);
static bool conninfo_uri_parse_options(PQconninfoOption *options,
const char *uri, PQExpBuffer errorMessage);
static bool conninfo_uri_parse_params(char *params,
@ -319,8 +319,8 @@ static bool get_hexdigit(char digit, int *value);
static const char *conninfo_getval(PQconninfoOption *connOptions,
const char *keyword);
static PQconninfoOption *conninfo_storeval(PQconninfoOption *connOptions,
const char *keyword, const char *value,
PQExpBuffer errorMessage, bool ignoreMissing, bool uri_decode);
const char *keyword, const char *value,
PQExpBuffer errorMessage, bool ignoreMissing, bool uri_decode);
static PQconninfoOption *conninfo_find(PQconninfoOption *connOptions,
const char *keyword);
static void defaultNoticeReceiver(void *arg, const PGresult *res);
@ -605,7 +605,7 @@ PQconnectStart(const char *conninfo)
static void
fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
{
const char *tmp;
const char *tmp;
/*
* Move option values into conn structure
@ -903,8 +903,8 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
return NULL;
/*
* If the dbName parameter contains what looks like a connection
* string, parse it into conn struct using connectOptions1.
* If the dbName parameter contains what looks like a connection string,
* parse it into conn struct using connectOptions1.
*/
if (dbName && recognized_connection_string(dbName))
{
@ -2094,7 +2094,7 @@ keep_going: /* We will come back to here until there is
{
/*
* Server failure of some sort, such as failure to
* fork a backend process. We need to process and
* fork a backend process. We need to process and
* report the error message, which might be formatted
* according to either protocol 2 or protocol 3.
* Rather than duplicate the code for that, we flip
@ -4305,9 +4305,9 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
if (strcmp(pname, "dbname") == 0 && pvalue)
{
/*
* If value is a connection string, parse it, but do not use defaults
* here -- those get picked up later. We only want to override for
* those parameters actually passed.
* If value is a connection string, parse it, but do not use
* defaults here -- those get picked up later. We only want to
* override for those parameters actually passed.
*/
if (recognized_connection_string(pvalue))
{
@ -4558,14 +4558,15 @@ static bool
conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
PQExpBuffer errorMessage)
{
int prefix_len;
char *p;
char *buf = strdup(uri); /* need a modifiable copy of the input URI */
char *start = buf;
char prevchar = '\0';
char *user = NULL;
char *host = NULL;
bool retval = false;
int prefix_len;
char *p;
char *buf = strdup(uri); /* need a modifiable copy of the input
* URI */
char *start = buf;
char prevchar = '\0';
char *user = NULL;
char *host = NULL;
bool retval = false;
if (buf == NULL)
{
@ -4657,7 +4658,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
if (p == host)
{
printfPQExpBuffer(errorMessage,
libpq_gettext("IPv6 host address may not be empty in URI: %s\n"),
libpq_gettext("IPv6 host address may not be empty in URI: %s\n"),
uri);
goto cleanup;
}
@ -4683,8 +4684,8 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
host = p;
/*
* Look for port specifier (colon) or end of host specifier
* (slash), or query (question mark).
* Look for port specifier (colon) or end of host specifier (slash),
* or query (question mark).
*/
while (*p && *p != ':' && *p != '/' && *p != '?')
++p;
@ -4718,7 +4719,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
if (prevchar && prevchar != '?')
{
const char *dbname = ++p; /* advance past host terminator */
const char *dbname = ++p; /* advance past host terminator */
/* Look for query parameters */
while (*p && *p != '?')
@ -4740,7 +4741,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
if (prevchar)
{
++p; /* advance past terminator */
++p; /* advance past terminator */
if (!conninfo_uri_parse_params(p, options, errorMessage))
goto cleanup;
@ -4758,7 +4759,7 @@ cleanup:
* Connection URI parameters parser routine
*
* If successful, returns true while connOptions is filled with parsed
* parameters. Otherwise, returns false and fills errorMessage appropriately.
* parameters. Otherwise, returns false and fills errorMessage appropriately.
*
* Destructively modifies 'params' buffer.
*/
@ -4769,10 +4770,10 @@ conninfo_uri_parse_params(char *params,
{
while (*params)
{
char *keyword = params;
char *value = NULL;
char *p = params;
bool malloced = false;
char *keyword = params;
char *value = NULL;
char *p = params;
bool malloced = false;
/*
* Scan the params string for '=' and '&', marking the end of keyword
@ -4796,7 +4797,7 @@ conninfo_uri_parse_params(char *params,
}
else if (*p == '&' || *p == '\0')
{
char prevchar;
char prevchar;
/* Cut off value, remember old value */
prevchar = *p;
@ -4810,6 +4811,7 @@ conninfo_uri_parse_params(char *params,
params);
return false;
}
/*
* If not at the end, advance; now pointing to start of the
* next parameter, if any.
@ -4876,7 +4878,7 @@ conninfo_uri_parse_params(char *params,
printfPQExpBuffer(errorMessage,
libpq_gettext(
"invalid URI query parameter \"%s\"\n"),
"invalid URI query parameter \"%s\"\n"),
keyword);
return false;
}
@ -4908,8 +4910,8 @@ conninfo_uri_parse_params(char *params,
static char *
conninfo_uri_decode(const char *str, PQExpBuffer errorMessage)
{
char *buf = malloc(strlen(str) + 1);
char *p = buf;
char *buf = malloc(strlen(str) + 1);
char *p = buf;
const char *q = str;
if (buf == NULL)
@ -4928,20 +4930,20 @@ conninfo_uri_decode(const char *str, PQExpBuffer errorMessage)
}
else
{
int hi;
int lo;
int c;
int hi;
int lo;
int c;
++q; /* skip the percent sign itself */
++q; /* skip the percent sign itself */
/*
* Possible EOL will be caught by the first call to get_hexdigit(),
* so we never dereference an invalid q pointer.
* Possible EOL will be caught by the first call to
* get_hexdigit(), so we never dereference an invalid q pointer.
*/
if (!(get_hexdigit(*q++, &hi) && get_hexdigit(*q++, &lo)))
{
printfPQExpBuffer(errorMessage,
libpq_gettext("invalid percent-encoded token: %s\n"),
libpq_gettext("invalid percent-encoded token: %s\n"),
str);
free(buf);
return NULL;
@ -5025,14 +5027,14 @@ conninfo_storeval(PQconninfoOption *connOptions,
bool uri_decode)
{
PQconninfoOption *option;
char *value_copy;
char *value_copy;
option = conninfo_find(connOptions, keyword);
if (option == NULL)
{
if (!ignoreMissing)
printfPQExpBuffer(errorMessage,
libpq_gettext("invalid connection option \"%s\"\n"),
libpq_gettext("invalid connection option \"%s\"\n"),
keyword);
return NULL;
}

View File

@ -1052,7 +1052,7 @@ pqStdRowProcessor(PGresult *res, const PGdataValue *columns,
* copy the data over.
*
* Note: on malloc failure, we return -1 leaving *errmsgp still NULL,
* which caller will take to mean "out of memory". This is preferable to
* which caller will take to mean "out of memory". This is preferable to
* trying to set up such a message here, because evidently there's not
* enough memory for gettext() to do anything.
*/
@ -1063,7 +1063,7 @@ pqStdRowProcessor(PGresult *res, const PGdataValue *columns,
for (i = 0; i < nfields; i++)
{
int clen = columns[i].len;
int clen = columns[i].len;
if (clen < 0)
{
@ -1743,7 +1743,7 @@ PQgetResult(PGconn *conn)
*
* This is mainly useful for cleaning up after a longjmp out of a row
* processor, when resuming processing of the current query result isn't
* wanted. Note that this is of little value in an async-style application,
* wanted. Note that this is of little value in an async-style application,
* since any preceding calls to PQisBusy would have already called the regular
* row processor.
*/

View File

@ -773,10 +773,11 @@ getRowDescriptions(PGconn *conn)
goto set_error_result;
advance_and_error:
/*
* Discard the failed message. Unfortunately we don't know for sure
* where the end is, so just throw away everything in the input buffer.
* This is not very desirable but it's the best we can do in protocol v2.
* Discard the failed message. Unfortunately we don't know for sure where
* the end is, so just throw away everything in the input buffer. This is
* not very desirable but it's the best we can do in protocol v2.
*/
conn->inStart = conn->inEnd;
@ -829,6 +830,7 @@ getAnotherTuple(PGconn *conn, bool binary)
int nfields = result->numAttributes;
const char *errmsg;
PGdataValue *rowbuf;
/* the backend sends us a bitmap of which attributes are null */
char std_bitmap[64]; /* used unless it doesn't fit */
char *bitmap = std_bitmap;
@ -962,10 +964,11 @@ getAnotherTuple(PGconn *conn, bool binary)
goto set_error_result;
advance_and_error:
/*
* Discard the failed message. Unfortunately we don't know for sure
* where the end is, so just throw away everything in the input buffer.
* This is not very desirable but it's the best we can do in protocol v2.
* Discard the failed message. Unfortunately we don't know for sure where
* the end is, so just throw away everything in the input buffer. This is
* not very desirable but it's the best we can do in protocol v2.
*/
conn->inStart = conn->inEnd;

View File

@ -627,7 +627,7 @@ set_error_result:
pqSaveErrorResult(conn);
/*
* Return zero to allow input parsing to continue. Subsequent "D"
* Return zero to allow input parsing to continue. Subsequent "D"
* messages will be ignored until we get to end of data, since an error
* result is already set up.
*/
@ -829,7 +829,7 @@ set_error_result:
pqSaveErrorResult(conn);
/*
* Return zero to allow input parsing to continue. Subsequent "D"
* Return zero to allow input parsing to continue. Subsequent "D"
* messages will be ignored until we get to end of data, since an error
* result is already set up.
*/

View File

@ -361,19 +361,19 @@ rloop:
result_errno == ECONNRESET)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
else
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: %s\n"),
libpq_gettext("SSL SYSCALL error: %s\n"),
SOCK_STRERROR(result_errno,
sebuf, sizeof(sebuf)));
sebuf, sizeof(sebuf)));
}
else
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
/* assume the connection is broken */
result_errno = ECONNRESET;
n = -1;
@ -392,6 +392,7 @@ rloop:
break;
}
case SSL_ERROR_ZERO_RETURN:
/*
* Per OpenSSL documentation, this error code is only returned
* for a clean connection closure, so we should not report it
@ -415,7 +416,7 @@ rloop:
RESTORE_SIGPIPE(conn, spinfo);
}
else
#endif /* USE_SSL */
#endif /* USE_SSL */
{
n = recv(conn->sock, ptr, len, 0);
@ -440,15 +441,15 @@ rloop:
case ECONNRESET:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
break;
#endif
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not receive data from server: %s\n"),
libpq_gettext("could not receive data from server: %s\n"),
SOCK_STRERROR(result_errno,
sebuf, sizeof(sebuf)));
break;
@ -521,19 +522,19 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
result_errno == ECONNRESET)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
else
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: %s\n"),
libpq_gettext("SSL SYSCALL error: %s\n"),
SOCK_STRERROR(result_errno,
sebuf, sizeof(sebuf)));
sebuf, sizeof(sebuf)));
}
else
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
/* assume the connection is broken */
result_errno = ECONNRESET;
n = -1;
@ -552,6 +553,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
break;
}
case SSL_ERROR_ZERO_RETURN:
/*
* Per OpenSSL documentation, this error code is only returned
* for a clean connection closure, so we should not report it
@ -573,7 +575,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
}
}
else
#endif /* USE_SSL */
#endif /* USE_SSL */
{
int flags = 0;
@ -629,14 +631,14 @@ retry_masked:
#endif
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
break;
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not send data to server: %s\n"),
libpq_gettext("could not send data to server: %s\n"),
SOCK_STRERROR(result_errno,
sebuf, sizeof(sebuf)));
break;
@ -1346,11 +1348,12 @@ initialize_SSL(PGconn *conn)
}
/*
* If the OpenSSL version used supports it (from 1.0.0 on)
* and the user requested it, disable SSL compression.
* If the OpenSSL version used supports it (from 1.0.0 on) and the user
* requested it, disable SSL compression.
*/
#ifdef SSL_OP_NO_COMPRESSION
if (conn->sslcompression && conn->sslcompression[0] == '0') {
if (conn->sslcompression && conn->sslcompression[0] == '0')
{
SSL_set_options(conn->ssl, SSL_OP_NO_COMPRESSION);
}
#endif

View File

@ -163,7 +163,7 @@ typedef struct pgNotify
/* Function type for row-processor callback */
typedef int (*PQrowProcessor) (PGresult *res, const PGdataValue *columns,
const char **errmsgp, void *param);
const char **errmsgp, void *param);
/* Function types for notice-handling callbacks */
typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);

View File

@ -310,7 +310,7 @@ struct pg_conn
char *keepalives_count; /* maximum number of TCP keepalive
* retransmits */
char *sslmode; /* SSL mode (require,prefer,allow,disable) */
char *sslcompression; /* SSL compression (0 or 1) */
char *sslcompression; /* SSL compression (0 or 1) */
char *sslkey; /* client key filename */
char *sslcert; /* client certificate filename */
char *sslrootcert; /* root certificate filename */
@ -326,7 +326,7 @@ struct pg_conn
/* Callback procedure for per-row processing */
PQrowProcessor rowProcessor; /* function pointer */
void *rowProcessorParam; /* passthrough argument */
void *rowProcessorParam; /* passthrough argument */
/* Callback procedures for notice message processing */
PGNoticeHooks noticeHooks;

View File

@ -1,8 +1,8 @@
/*
* uri-regress.c
* A test program for libpq URI format
* A test program for libpq URI format
*
* This is a helper for libpq conninfo regression testing. It takes a single
* This is a helper for libpq conninfo regression testing. It takes a single
* conninfo string as a parameter, parses it using PQconninfoParse, and then
* prints out the values from the parsed PQconninfoOption struct that differ
* from the defaults (obtained from PQconndefaults).
@ -10,7 +10,7 @@
* Portions Copyright (c) 2012, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/interfaces/libpq/test/uri-regress.c
* src/interfaces/libpq/test/uri-regress.c
*/
#include "postgres_fe.h"