From b399805e221b5407f4f459c41661c86bb580680f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 11 Sep 1999 19:06:42 +0000 Subject: 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. --- src/backend/utils/misc/trace.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/backend/utils/misc/trace.c') diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index baf8ce61218..3d9cbe607de 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -2,22 +2,21 @@ * * trace.c * - * Conditional trace ans logging functions. + * Conditional trace and logging functions. * * Massimo Dal Zotto * *------------------------------------------------------------------------- */ +#include "postgres.h" + #include #include #include #include #include #include - -#include "postgres.h" - #ifdef USE_SYSLOG #include #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 -- cgit v1.2.3