1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Initial pgindent run for v12.

This is still using the 2.0 version of pg_bsd_indent.
I thought it would be good to commit this separately,
so as to document the differences between 2.0 and 2.1 behavior.

Discussion: https://postgr.es/m/16296.1558103386@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2019-05-22 12:55:34 -04:00
parent 66a4bad83a
commit be76af171c
221 changed files with 1433 additions and 1302 deletions

View File

@ -25,14 +25,14 @@ static bool find_cursor(const char *, const struct connection *);
* others --- keep same as the parameters in ECPGdo() function
*/
bool
ECPGopen(const char *cursor_name,const char *prepared_name,
const int lineno, const int compat,const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
ECPGopen(const char *cursor_name, const char *prepared_name,
const int lineno, const int compat, const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
{
va_list args;
bool status;
const char *real_connection_name = NULL;
const char *real_connection_name = NULL;
if (!query)
{
@ -53,8 +53,8 @@ ECPGopen(const char *cursor_name,const char *prepared_name,
else
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -81,13 +81,13 @@ ECPGopen(const char *cursor_name,const char *prepared_name,
*/
bool
ECPGfetch(const char *cursor_name,
const int lineno, const int compat,const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
const int lineno, const int compat, const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
{
va_list args;
bool status;
const char *real_connection_name = NULL;
const char *real_connection_name = NULL;
if (!query)
{
@ -99,8 +99,8 @@ ECPGfetch(const char *cursor_name,
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by cursor name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by cursor name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -123,13 +123,13 @@ ECPGfetch(const char *cursor_name,
*/
bool
ECPGclose(const char *cursor_name,
const int lineno, const int compat,const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
const int lineno, const int compat, const int force_indicator,
const char *connection_name, const bool questionmarks,
const int st, const char *query,...)
{
va_list args;
bool status;
const char *real_connection_name = NULL;
const char *real_connection_name = NULL;
struct connection *con = NULL;
if (!query)
@ -142,8 +142,8 @@ ECPGclose(const char *cursor_name,
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by cursor name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by cursor name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -192,12 +192,12 @@ add_cursor(const int lineno, const char *cursor_name, const char *connection_nam
if (!con)
{
ecpg_raise(lineno, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
connection_name ? connection_name : ecpg_gettext("NULL"));
connection_name ? connection_name : ecpg_gettext("NULL"));
return;
}
/* allocate a node to store the new cursor */
new = (struct cursor_statement *)ecpg_alloc(sizeof(struct cursor_statement), lineno);
new = (struct cursor_statement *) ecpg_alloc(sizeof(struct cursor_statement), lineno);
if (new)
{
new->name = ecpg_strdup(cursor_name, lineno);

View File

@ -589,7 +589,7 @@ ECPGset_desc_header(int lineno, const char *desc_name, int count)
static void
set_desc_attr(struct descriptor_item *desc_item, struct variable *var,
char *tobeinserted)
char *tobeinserted)
{
if (var->type != ECPGt_bytea)
desc_item->is_binary = false;
@ -603,8 +603,7 @@ set_desc_attr(struct descriptor_item *desc_item, struct variable *var,
desc_item->data_len = variable->len;
}
ecpg_free(desc_item->data); /* free() takes care of a
* potential NULL value */
ecpg_free(desc_item->data); /* free() takes care of a potential NULL value */
desc_item->data = (char *) tobeinserted;
}
@ -875,8 +874,8 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}

View File

@ -90,9 +90,9 @@ struct statement
/* structure to store declared statements */
struct declared_statement
{
char *name; /* declared name */
char *connection_name;
char *cursor_name;
char *name; /* declared name */
char *connection_name;
char *cursor_name;
struct declared_statement *next;
};
@ -107,7 +107,7 @@ struct prepared_statement
struct cursor_statement
{
char *name; /*cursor name*/
char *name; /* cursor name */
struct cursor_statement *next;
};
@ -204,10 +204,10 @@ struct descriptor *ecpg_find_desc(int line, const char *name);
struct prepared_statement *ecpg_find_prepared_statement(const char *,
struct connection *, struct prepared_statement **);
void ecpg_update_declare_statement(const char *, const char *, const int);
char *ecpg_get_con_name_by_declared_name(const char *);
void ecpg_update_declare_statement(const char *, const char *, const int);
char *ecpg_get_con_name_by_declared_name(const char *);
const char *ecpg_get_con_name_by_cursor_name(const char *);
void ecpg_release_declared_statement(const char *);
void ecpg_release_declared_statement(const char *);
bool ecpg_store_result(const PGresult *results, int act_field,
const struct statement *stmt, struct variable *var);

View File

@ -201,10 +201,10 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
break;
case ECPG_INVALID_CURSOR:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
/*------
translator: this string will be truncated at 149 characters expanded. */
ecpg_gettext("The cursor is invalid on line %d"),line);
ecpg_gettext("The cursor is invalid on line %d"), line);
break;
default:

View File

@ -488,11 +488,12 @@ sprintf_float_value(char *ptr, float value, const char *delim)
sprintf(ptr, "%.15g%s", value, delim);
}
static char*
static char *
convert_bytea_to_string(char *from_data, int from_len, int lineno)
{
char *to_data;
int to_len = ecpg_hex_enc_len(from_len) + 4 + 1; /* backslash + 'x' + quote + quote */
char *to_data;
int to_len = ecpg_hex_enc_len(from_len) + 4 + 1; /* backslash + 'x' +
* quote + quote */
to_data = ecpg_alloc(to_len, lineno);
if (!to_data)
@ -1080,16 +1081,16 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
static void
print_param_value(char *value, int len, int is_binary, int lineno, int nth)
{
char *value_s;
bool malloced = false;
char *value_s;
bool malloced = false;
if (value == NULL)
value_s = "null";
else if (! is_binary)
else if (!is_binary)
value_s = value;
else
{
value_s = ecpg_alloc(ecpg_hex_enc_len(len)+1, lineno);
value_s = ecpg_alloc(ecpg_hex_enc_len(len) + 1, lineno);
if (value_s != NULL)
{
ecpg_hex_encode(value, len, value_s);
@ -1101,7 +1102,7 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
}
ecpg_log("ecpg_free_params on line %d: parameter %d = %s\n",
lineno, nth, value_s);
lineno, nth, value_s);
if (malloced)
ecpg_free(value_s);
@ -1116,7 +1117,7 @@ ecpg_free_params(struct statement *stmt, bool print)
{
if (print)
print_param_value(stmt->paramvalues[n], stmt->paramlengths[n],
stmt->paramformats[n], stmt->lineno, n + 1);
stmt->paramformats[n], stmt->lineno, n + 1);
ecpg_free(stmt->paramvalues[n]);
}
ecpg_free(stmt->paramvalues);
@ -1162,13 +1163,13 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe
static bool
store_input_from_desc(struct statement *stmt, struct descriptor_item *desc_item,
char **tobeinserted)
char **tobeinserted)
{
struct variable var;
/*
* In case of binary data, only allocate memory and memcpy because
* binary data have been already stored into desc_item->data with
* In case of binary data, only allocate memory and memcpy because binary
* data have been already stored into desc_item->data with
* ecpg_store_input() at ECPGset_desc().
*/
if (desc_item->is_binary)
@ -1454,7 +1455,8 @@ ecpg_build_params(struct statement *stmt)
stmt->statement_type == ECPGst_exec_with_exprlist)
{
/* Add double quote both side for embedding statement name. */
char *str = ecpg_alloc(strlen(tobeinserted) + 2 + 1, stmt->lineno);
char *str = ecpg_alloc(strlen(tobeinserted) + 2 + 1, stmt->lineno);
sprintf(str, "\"%s\"", tobeinserted);
ecpg_free(tobeinserted);
tobeinserted = str;
@ -1471,7 +1473,8 @@ ecpg_build_params(struct statement *stmt)
if (binary_format)
{
char *p = convert_bytea_to_string(tobeinserted, binary_length, stmt->lineno);
char *p = convert_bytea_to_string(tobeinserted, binary_length, stmt->lineno);
if (!p)
{
ecpg_free_params(stmt, false);
@ -1541,8 +1544,8 @@ ecpg_build_params(struct statement *stmt)
}
/*
* Check if there are unmatched things left.
* PREPARE AS has no parameter. Check other statement.
* Check if there are unmatched things left. PREPARE AS has no parameter.
* Check other statement.
*/
if (stmt->statement_type != ECPGst_prepare &&
next_insert(stmt->command, position, stmt->questionmarks, std_strings) >= 0)
@ -1617,7 +1620,7 @@ ecpg_execute(struct statement *stmt)
if (stmt->statement_type == ECPGst_prepare)
{
if(! ecpg_register_prepared_stmt(stmt))
if (!ecpg_register_prepared_stmt(stmt))
{
ecpg_free_params(stmt, true);
return false;
@ -2266,7 +2269,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
{
va_list args;
bool ret;
const char *real_connection_name = NULL;
const char *real_connection_name = NULL;
real_connection_name = connection_name;
@ -2283,11 +2286,11 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
}
}
va_start(args, query);

View File

@ -63,51 +63,51 @@ ecpg_register_prepared_stmt(struct statement *stmt)
struct prepared_statement *this;
struct connection *con = NULL;
struct prepared_statement *prev = NULL;
char *real_connection_name;
int lineno = stmt->lineno;
char *real_connection_name;
int lineno = stmt->lineno;
real_connection_name = ecpg_get_con_name_by_declared_name(stmt->name);
if (real_connection_name == NULL)
real_connection_name = stmt->connection->name;
real_connection_name = ecpg_get_con_name_by_declared_name(stmt->name);
if (real_connection_name == NULL)
real_connection_name = stmt->connection->name;
con = ecpg_get_connection(real_connection_name);
if (!ecpg_init(con, real_connection_name, stmt->lineno))
return false;
con = ecpg_get_connection(real_connection_name);
if (!ecpg_init(con, real_connection_name, stmt->lineno))
return false;
/* check if we already have prepared this statement */
this = ecpg_find_prepared_statement(stmt->name, con, &prev);
if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
return false;
/* check if we already have prepared this statement */
this = ecpg_find_prepared_statement(stmt->name, con, &prev);
if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
return false;
/* allocate new statement */
this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno);
if (!this)
return false;
/* allocate new statement */
this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno);
if (!this)
return false;
prep_stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno);
if (!stmt)
{
ecpg_free(this);
return false;
}
memset(prep_stmt, 0, sizeof(struct statement));
prep_stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno);
if (!stmt)
{
ecpg_free(this);
return false;
}
memset(prep_stmt, 0, sizeof(struct statement));
/* create statement */
prep_stmt->lineno = lineno;
prep_stmt->connection = con;
prep_stmt->command = ecpg_strdup(stmt->command, lineno);
prep_stmt->inlist = prep_stmt->outlist = NULL;
this->name = ecpg_strdup(stmt->name, lineno);
this->stmt = prep_stmt;
this->prepared = true;
/* create statement */
prep_stmt->lineno = lineno;
prep_stmt->connection = con;
prep_stmt->command = ecpg_strdup(stmt->command, lineno);
prep_stmt->inlist = prep_stmt->outlist = NULL;
this->name = ecpg_strdup(stmt->name, lineno);
this->stmt = prep_stmt;
this->prepared = true;
if (con->prep_stmts == NULL)
this->next = NULL;
else
this->next = con->prep_stmts;
if (con->prep_stmts == NULL)
this->next = NULL;
else
this->next = con->prep_stmts;
con->prep_stmts = this;
return true;
con->prep_stmts = this;
return true;
}
static bool
@ -239,8 +239,8 @@ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks,
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -345,8 +345,8 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -408,8 +408,8 @@ ECPGprepared_statement(const char *connection_name, const char *name, int lineno
if (real_connection_name == NULL)
{
/*
* If can't get the connection name by declared name then using connection name
* coming from the parameter connection_name
* If can't get the connection name by declared name then using
* connection name coming from the parameter connection_name
*/
real_connection_name = connection_name;
}
@ -667,11 +667,11 @@ ECPGdeclare(int lineno, const char *connection_name, const char *name)
{
/*
* Going to here means not using AT clause in the DECLARE STATEMENT
* ECPG pre-processor allows this case.
* However, we don't allocate a node to store the declared name
* because the DECLARE STATEMENT without using AT clause will be ignored.
* The following statement such as PREPARE, EXECUTE are executed
* as usual on the current connection.
* ECPG pre-processor allows this case. However, we don't allocate a
* node to store the declared name because the DECLARE STATEMENT
* without using AT clause will be ignored. The following statement
* such as PREPARE, EXECUTE are executed as usual on the current
* connection.
*/
return true;
}
@ -682,7 +682,10 @@ ECPGdeclare(int lineno, const char *connection_name, const char *name)
if (ecpg_find_declared_statement(name))
{
/* Should not go to here because the pre-compiler has check the duplicate name */
/*
* Should not go to here because the pre-compiler has check the
* duplicate name
*/
return false;
}
@ -751,7 +754,7 @@ ecpg_update_declare_statement(const char *declared_name, const char *cursor_name
/* Find the declared node by declared name */
p = ecpg_find_declared_statement(declared_name);
if (p)
p->cursor_name = ecpg_strdup(cursor_name,lineno);
p->cursor_name = ecpg_strdup(cursor_name, lineno);
}
/*
@ -831,7 +834,10 @@ ecpg_release_declared_statement(const char *connection_name)
ecpg_free(cur->cursor_name);
ecpg_free(cur);
/* One connection can be used by multiple declared name, so no break here */
/*
* One connection can be used by multiple declared name, so no
* break here
*/
}
else
prev = cur;

View File

@ -56,9 +56,9 @@ bool ECPGprepare(int, const char *, const bool, const char *, const char *);
bool ECPGdeallocate(int, int, const char *, const char *);
bool ECPGdeallocate_all(int, int, const char *);
bool ECPGdeclare(int, const char *, const char *);
bool ECPGopen(const char*, const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGfetch(const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGclose(const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGopen(const char *, const char *, const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGfetch(const char *, const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGclose(const char *, const int, const int, const int, const char *, const bool, const int, const char *,...);
char *ECPGprepared_statement(const char *, const char *, int);
PGconn *ECPGget_PGconn(const char *);
PGTransactionStatusType ECPGtransactionStatus(const char *);

View File

@ -121,8 +121,8 @@ free_argument(struct arguments *arg)
free_argument(arg->next);
/*
* Don't free variables in it because the original codes don't free it either
* variables are static structures instead of allocating
* Don't free variables in it because the original codes don't free it
* either variables are static structures instead of allocating
*/
free(arg);
}
@ -520,13 +520,13 @@ main(int argc, char *const argv[])
free(input_filename);
}
if(g_declared_list)
if (g_declared_list)
{
free_declared_stmt(g_declared_list);
g_declared_list = NULL;
}
if(cur)
if (cur)
{
free_cursor(cur);
cur = NULL;

View File

@ -142,9 +142,9 @@ output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
st = ECPGst_normal;
/*
* In following cases, stmt is CSTRING or char_variable. They must be output directly.
* - prepared_name of EXECUTE without exprlist
* - execstring of EXECUTE IMMEDIATE
* In following cases, stmt is CSTRING or char_variable. They must be
* output directly. - prepared_name of EXECUTE without exprlist -
* execstring of EXECUTE IMMEDIATE
*/
fprintf(base_yyout, "%s, ", ecpg_statement_type_name[st]);
if (st == ECPGst_execute || st == ECPGst_exec_immediate)
@ -317,9 +317,9 @@ output_cursor_name(char *str)
j++;
} while (str[j] == ' ' || str[j] == '\t');
if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a
* newline */
fputs("\\\\",base_yyout);
if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a
* newline */
fputs("\\\\", base_yyout);
}
else if (str[i] == '\r' && str[i + 1] == '\n')
{
@ -362,7 +362,7 @@ output_declare_statement(char *name)
void
output_cursor_statement(int cursor_stmt, char *cursor_name, char *prepared_name, char *stmt, int whenever_mode, enum ECPG_statement_type st)
{
switch(cursor_stmt)
switch (cursor_stmt)
{
case ECPGcst_open:
fprintf(base_yyout, "{ ECPGopen(");

View File

@ -72,7 +72,7 @@ extern void output_prepare_statement(char *, char *);
extern void output_deallocate_prepare_statement(char *);
extern void output_simple_statement(char *, int);
extern void output_declare_statement(char *);
extern void output_cursor_statement(int , char *, char *, char *, int , enum ECPG_statement_type);
extern void output_cursor_statement(int, char *, char *, char *, int, enum ECPG_statement_type);
extern char *hashline_number(void);
extern int base_yyparse(void);
extern int base_yylex(void);

View File

@ -145,7 +145,7 @@ struct cursor
/* structure to store declared name */
struct declared_name_st
{
char *name; /* declared name */
char *name; /* declared name */
struct declared_name_st *next;
};

View File

@ -313,7 +313,7 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
* and "prefer".
*/
{"gssencmode", "PGGSSENCMODE", DefaultGSSMode, NULL,
"GSSENC-Mode", "", 7, /* sizeof("disable") == 7 */
"GSSENC-Mode", "", 7, /* sizeof("disable") == 7 */
offsetof(struct pg_conn, gssencmode)},
#if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
@ -2420,6 +2420,7 @@ keep_going: /* We will come back to here until there is
getHostaddr(conn, host_addr, NI_MAXHOST);
if (strlen(host_addr) > 0)
conn->connip = strdup(host_addr);
/*
* purposely ignore strdup failure; not a big problem if
* it fails anyway.

View File

@ -349,7 +349,7 @@ extern void PQinitSSL(int do_init);
extern void PQinitOpenSSL(int do_ssl, int do_crypto);
/* Return true if GSSAPI encryption is in use */
extern int PQgssEncInUse(PGconn *conn);
extern int PQgssEncInUse(PGconn *conn);
/* Returns GSSAPI context if GSSAPI is in use */
extern void *PQgetgssctx(PGconn *conn);

View File

@ -36,8 +36,9 @@
/* All "broken" PQExpBuffers point to this string. */
static const char oom_buffer[1] = "";
/* Need a char * for unconstify() compatiblity */
static const char * oom_buffer_ptr = oom_buffer;
static const char *oom_buffer_ptr = oom_buffer;
static bool appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args) pg_attribute_printf(2, 0);
@ -93,7 +94,7 @@ initPQExpBuffer(PQExpBuffer str)
str->data = (char *) malloc(INITIAL_EXPBUFFER_SIZE);
if (str->data == NULL)
{
str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */
str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */
str->maxlen = 0;
str->len = 0;
}
@ -132,7 +133,7 @@ termPQExpBuffer(PQExpBuffer str)
if (str->data != oom_buffer)
free(str->data);
/* just for luck, make the buffer validly empty. */
str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */
str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */
str->maxlen = 0;
str->len = 0;
}