diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-11 19:06:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-11 19:06:42 +0000 |
commit | b399805e221b5407f4f459c41661c86bb580680f (patch) | |
tree | fdab78c0187b25724fe31b456fd79f3a15a3ed6b /src/backend/utils/misc/trace.c | |
parent | 1e4f0197bb3271b4ed2427b8c661a34aaaf7c220 (diff) |
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.
Diffstat (limited to 'src/backend/utils/misc/trace.c')
-rw-r--r-- | src/backend/utils/misc/trace.c | 35 |
1 files changed, 20 insertions, 15 deletions
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 <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 |