mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Eliminate elog()'s hardwired limit on length of an error message.
This change seems necessary in conjunction with long queries, and it cleans up some bogosity in connection with long EXPLAIN texts anyway. Note that current libpq will accept any length error message (at least until it runs out of memory); prior versions have a limit of 8K, but will cleanly discard excess error text, so there shouldn't be any big compatibility problems with old clients.
This commit is contained in:
@ -2,22 +2,21 @@
|
||||
*
|
||||
* trace.c
|
||||
*
|
||||
* Conditional trace ans logging functions.
|
||||
* Conditional trace and logging functions.
|
||||
*
|
||||
* Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
@ -25,6 +24,13 @@
|
||||
#include "miscadmin.h"
|
||||
#include "utils/trace.h"
|
||||
|
||||
/*
|
||||
* We could support trace messages of indefinite length, as elog() does,
|
||||
* but it's probably not worth the trouble. Instead limit trace message
|
||||
* length to this.
|
||||
*/
|
||||
#define TRACEMSG_MAXLEN 1024
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
/*
|
||||
* Global option to control the use of syslog(3) for logging:
|
||||
@ -87,15 +93,14 @@ int
|
||||
tprintf(int flag, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
|
||||
char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
#ifdef USE_SYSLOG
|
||||
int log_level;
|
||||
#endif
|
||||
|
||||
if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0))
|
||||
{
|
||||
/* uconditional trace or trace all option set */
|
||||
/* unconditional trace or trace all option set */
|
||||
}
|
||||
else if (pg_options[TRACE_ALL] == 0)
|
||||
{
|
||||
@ -105,11 +110,11 @@ tprintf(int flag, const char *fmt,...)
|
||||
else if (pg_options[TRACE_ALL] < 0)
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
strcpy(line, tprintf_timestamp());
|
||||
#endif
|
||||
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
@ -134,13 +139,13 @@ int
|
||||
tprintf1(const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
|
||||
va_start(ap, fmt);
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
strcpy(line, tprintf_timestamp());
|
||||
#endif
|
||||
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
@ -164,13 +169,13 @@ int
|
||||
eprintf(const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
|
||||
|
||||
va_start(ap, fmt);
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
strcpy(line, tprintf_timestamp());
|
||||
#endif
|
||||
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
|
Reference in New Issue
Block a user