diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/commands/copy.c | 9 | ||||
-rw-r--r-- | src/backend/utils/error/elog.c | 13 | ||||
-rw-r--r-- | src/backend/utils/misc/trace.c | 4 |
3 files changed, 19 insertions, 7 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 7a23a063aaf..85a50c10398 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.100 2000/02/09 00:10:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.101 2000/02/13 18:59:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ static int CountTuples(Relation relation); * Static communication variables ... pretty grotty, but COPY has * never been reentrant... */ -static int lineno; +int lineno = 0; /* used by elog() -- dz */ static bool fe_eof; /* @@ -726,8 +726,10 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null while (!done) { - if (QueryCancel) + if (QueryCancel) { + lineno = 0; CancelQuery(); + } if (!binary) { @@ -931,6 +933,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null if (!reading_to_eof && ntuples == tuples_read) done = true; } + lineno = 0; pfree(values); pfree(nulls); pfree(index_nulls); diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 71fd9c8354f..1a61d7e6d17 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.54 2000/01/26 05:57:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.55 2000/02/13 18:59:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,7 @@ #include "storage/proc.h" #include "tcop/tcopprot.h" #include "utils/trace.h" +#include "commands/copy.h" extern int errno; extern int sys_nerr; @@ -164,7 +165,7 @@ elog(int lev, const char *fmt, ...) * (since vsnprintf won't know what to do with %m). To keep * space calculation simple, we only allow one %m. */ - space_needed = TIMESTAMP_SIZE + strlen(prefix) + indent + space_needed = TIMESTAMP_SIZE + strlen(prefix) + indent + (lineno ? 24 : 0) + strlen(fmt) + strlen(errorstr) + 1; if (space_needed > (int) sizeof(fmt_fixedbuf)) { @@ -186,6 +187,14 @@ elog(int lev, const char *fmt, ...) bp = fmt_buf + strlen(fmt_buf); while (indent-- > 0) *bp++ = ' '; + + /* If error was in CopyFrom() print the offending line number -- dz */ + if (lineno) { + sprintf(bp, "copy: line %d, ", lineno); + bp = fmt_buf + strlen(fmt_buf); + lineno = 0; + } + for (cp = fmt; *cp; cp++) { if (cp[0] == '%' && cp[1] != '\0') diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index 044afe16519..33ca0ce0a6b 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -233,8 +233,8 @@ tprintf_timestamp() time = localtime(&tm); sprintf(pid, "[%d]", MyProcPid); - sprintf(timestamp, "%04d%02d%02d.%02d:%02d:%02d.%03d %7s ", - time->tm_year+1900, time->tm_mon + 1, time->tm_mday, + sprintf(timestamp, "%02d%02d%02d.%02d:%02d:%02d.%03d %7s ", + time->tm_year % 100, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec, (int) (tv.tv_usec/1000), pid); |