pg_upgrade: adjust logging to use QUERY_ALLOC lengths
Allows the logging to print the entire text of failed queries, rather than a truncated version.
This commit is contained in:
parent
02587dcddc
commit
7567d94910
@ -104,22 +104,22 @@ cluster_conn_opts(ClusterInfo *cluster)
|
|||||||
PGresult *
|
PGresult *
|
||||||
executeQueryOrDie(PGconn *conn, const char *fmt,...)
|
executeQueryOrDie(PGconn *conn, const char *fmt,...)
|
||||||
{
|
{
|
||||||
static char command[8192];
|
static char query[QUERY_ALLOC];
|
||||||
va_list args;
|
va_list args;
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
ExecStatusType status;
|
ExecStatusType status;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(command, sizeof(command), fmt, args);
|
vsnprintf(query, sizeof(query), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
pg_log(PG_VERBOSE, "executing: %s\n", command);
|
pg_log(PG_VERBOSE, "executing: %s\n", query);
|
||||||
result = PQexec(conn, command);
|
result = PQexec(conn, query);
|
||||||
status = PQresultStatus(result);
|
status = PQresultStatus(result);
|
||||||
|
|
||||||
if ((status != PGRES_TUPLES_OK) && (status != PGRES_COMMAND_OK))
|
if ((status != PGRES_TUPLES_OK) && (status != PGRES_COMMAND_OK))
|
||||||
{
|
{
|
||||||
pg_log(PG_REPORT, "SQL command failed\n%s\n%s\n", command,
|
pg_log(PG_REPORT, "SQL command failed\n%s\n%s\n", query,
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
@ -86,7 +86,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)))
|
|||||||
void
|
void
|
||||||
pg_log_v(eLogType type, const char *fmt, va_list ap)
|
pg_log_v(eLogType type, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char message[MAX_STRING];
|
char message[QUERY_ALLOC];
|
||||||
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
vsnprintf(message, sizeof(message), fmt, ap);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user