diff --git a/contrib/array/Makefile b/contrib/array/Makefile index 85e8d42ade4239dfc1b6e6144a54575a9be15058..951250a29dd48110e92f57e83052e7d5dacf81d2 100644 --- a/contrib/array/Makefile +++ b/contrib/array/Makefile @@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src include $(SRCDIR)/Makefile.global -INCLUDE_OPT = -I ./ \ - -I $(SRCDIR)/ \ - -I $(SRCDIR)/include \ - -I $(SRCDIR)/port/$(PORTNAME) +INCLUDE_OPT = -I./ \ + -I$(SRCDIR)/ \ + -I$(SRCDIR)/include \ + -I$(SRCDIR)/port/$(PORTNAME) CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c index 5417d2da52f69050b1d87f926eb33208ea122c98..cadda58a8f47973b84c836450a6c2664cbf71ebf 100644 --- a/contrib/array/array_iterator.c +++ b/contrib/array/array_iterator.c @@ -66,7 +66,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) } /* Lookup element type information */ - typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype), 0, 0, 0); + typ_tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(elemtype), 0, 0, 0); if (!HeapTupleIsValid(typ_tuple)) { elog(ERROR, "array_iterator: cache lookup failed for type %d", elemtype); @@ -183,7 +183,7 @@ array_all_textregexeq(ArrayType *array, char *value) int32 array_varchareq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* varchar */ + return array_iterator((Oid) 1043, /* varchar */ (Oid) 1070, /* varchareq */ 0, /* logical or */ array, (Datum) value); @@ -192,7 +192,7 @@ array_varchareq(ArrayType *array, char *value) int32 array_all_varchareq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* varchar */ + return array_iterator((Oid) 1043, /* varchar */ (Oid) 1070, /* varchareq */ 1, /* logical and */ array, (Datum) value); @@ -201,7 +201,7 @@ array_all_varchareq(ArrayType *array, char *value) int32 array_varcharregexeq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* varchar */ + return array_iterator((Oid) 1043, /* varchar */ (Oid) 1254, /* textregexeq */ 0, /* logical or */ array, (Datum) value); @@ -210,7 +210,7 @@ array_varcharregexeq(ArrayType *array, char *value) int32 array_all_varcharregexeq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* varchar */ + return array_iterator((Oid) 1043, /* varchar */ (Oid) 1254, /* textregexeq */ 1, /* logical and */ array, (Datum) value); @@ -224,7 +224,7 @@ array_all_varcharregexeq(ArrayType *array, char *value) int32 array_bpchareq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* bpchar */ + return array_iterator((Oid) 1042, /* bpchar */ (Oid) 1048, /* bpchareq */ 0, /* logical or */ array, (Datum) value); @@ -233,7 +233,7 @@ array_bpchareq(ArrayType *array, char *value) int32 array_all_bpchareq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* bpchar */ + return array_iterator((Oid) 1042, /* bpchar */ (Oid) 1048, /* bpchareq */ 1, /* logical and */ array, (Datum) value); @@ -242,7 +242,7 @@ array_all_bpchareq(ArrayType *array, char *value) int32 array_bpcharregexeq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* bpchar */ + return array_iterator((Oid) 1042, /* bpchar */ (Oid) 1254, /* textregexeq */ 0, /* logical or */ array, (Datum) value); @@ -251,7 +251,7 @@ array_bpcharregexeq(ArrayType *array, char *value) int32 array_all_bpcharregexeq(ArrayType *array, char *value) { - return array_iterator((Oid) 20, /* bpchar */ + return array_iterator((Oid) 1042, /* bpchar */ (Oid) 1254, /* textregexeq */ 1, /* logical and */ array, (Datum) value); diff --git a/contrib/datetime/Makefile b/contrib/datetime/Makefile index b53293e172234420a608abc6c89cc7c0d24b88b6..195c0f8d689e2dcd57bcf288b3758c9a20d144eb 100644 --- a/contrib/datetime/Makefile +++ b/contrib/datetime/Makefile @@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src include $(SRCDIR)/Makefile.global -INCLUDE_OPT = -I ./ \ - -I $(SRCDIR)/ \ - -I $(SRCDIR)/include \ - -I $(SRCDIR)/port/$(PORTNAME) +INCLUDE_OPT = -I./ \ + -I$(SRCDIR)/ \ + -I$(SRCDIR)/include \ + -I$(SRCDIR)/port/$(PORTNAME) CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) diff --git a/contrib/datetime/datetime_functions.c b/contrib/datetime/datetime_functions.c index 910647118aa772bf78dee2c34139c68bb5f2e5ec..c5b8bc25e9d2789611846cb849850b2e1b81270b 100644 --- a/contrib/datetime/datetime_functions.c +++ b/contrib/datetime/datetime_functions.c @@ -5,6 +5,8 @@ * * Copyright (C) 1999, Massimo Dal Zotto <dz@cs.unitn.it> * + * Date2mjd code contributed by Reiner Dassing <dassing@wettzell.ifag.de> + * * This software is distributed under the GNU General Public License * either version 2, or (at your option) any later version. */ @@ -73,7 +75,7 @@ decode_24h_time(char *str, struct tm *tm, double *fsec) if ( (tm->tm_hour < 0) || (tm->tm_hour > 24) || (tm->tm_min < 0) || (tm->tm_min > 59) || (tm->tm_sec < 0) || (tm->tm_sec > 59) - || (fsec < 0) ) + || (*fsec < 0) ) return -1; return 0; @@ -260,6 +262,16 @@ currentdate() return (date); } +int4 +date2mjd(DateADT val) +{ + int result; + + result = val + JDATE_2000 - 2400000.5; + + return result; +} + /* end of file */ /* diff --git a/contrib/miscutil/Makefile b/contrib/miscutil/Makefile index fa3c99fa1db415ff372f6d910b38f7d6a9d605c4..fd0065b86ef6510e791ad26baea10d1c7ad9806e 100644 --- a/contrib/miscutil/Makefile +++ b/contrib/miscutil/Makefile @@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src include $(SRCDIR)/Makefile.global -INCLUDE_OPT = -I ./ \ - -I $(SRCDIR)/ \ - -I $(SRCDIR)/include \ - -I $(SRCDIR)/port/$(PORTNAME) +INCLUDE_OPT = -I./ \ + -I$(SRCDIR)/ \ + -I$(SRCDIR)/include \ + -I$(SRCDIR)/port/$(PORTNAME) CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) diff --git a/contrib/miscutil/misc_utils.c b/contrib/miscutil/misc_utils.c index 21341dc73c9e750a174b9f0ff1338e4a707a9fd4..6745b5b8bb9a9e049c19e181b875f64e45fae7ab 100644 --- a/contrib/miscutil/misc_utils.c +++ b/contrib/miscutil/misc_utils.c @@ -121,6 +121,7 @@ active_listeners(text *relname) return count; } +#ifdef USE_ASSERT_CHECKING int assert_enable(int val) { @@ -134,6 +135,7 @@ assert_test(int val) return assertTest(val); } #endif +#endif /* end of file */ diff --git a/contrib/miscutil/misc_utils.h b/contrib/miscutil/misc_utils.h index 61217244a2d26539781a13eef124f08b85b041ef..139df3bc775cadc75e3a75cac7e2a812c601cd58 100644 --- a/contrib/miscutil/misc_utils.h +++ b/contrib/miscutil/misc_utils.h @@ -6,13 +6,15 @@ int backend_pid(void); int unlisten(char *relname); int max(int x, int y); int min(int x, int y); -int assert_enable(int val); +int active_listeners(text *relname); +#ifdef USE_ASSERT_CHECKING +int assert_enable(int val); #ifdef ASSERT_CHECKING_TEST int assert_test(int val); #endif +#endif -int active_listeners(text *relname); #endif /* diff --git a/contrib/string/Makefile b/contrib/string/Makefile index b77ace937cf85842c6edc153bdc1b7f478f47dfa..dd8f0e6f2a6071a4039a0067523be9cdb5fa4069 100644 --- a/contrib/string/Makefile +++ b/contrib/string/Makefile @@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src include $(SRCDIR)/Makefile.global -INCLUDE_OPT = -I ./ \ - -I $(SRCDIR)/ \ - -I $(SRCDIR)/include \ - -I $(SRCDIR)/port/$(PORTNAME) +INCLUDE_OPT = -I./ \ + -I$(SRCDIR)/ \ + -I$(SRCDIR)/include \ + -I$(SRCDIR)/port/$(PORTNAME) CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c index e1fc867497fdb4f121cb4c6202f2629b4fb50f78..9407e6a21b3d37425140ad96b43f1e08affedca8 100644 --- a/contrib/string/string_io.c +++ b/contrib/string/string_io.c @@ -50,8 +50,8 @@ * representation of data. */ -char * -string_output(char *data, int size) +unsigned char * +string_output(unsigned char *data, int size) { register unsigned char c, *p, @@ -79,8 +79,6 @@ string_output(char *data, int size) { case '\\': case '"': - case '{': - case '}': case '\b': case '\f': case '\n': @@ -89,6 +87,12 @@ string_output(char *data, int size) case '\v': len++; break; + case '{': + /* Escape beginning of string, to distinguish from arrays */ + if (p == data) { + len++; + } + break; default: if (NOTPRINTABLE(*p)) len += 3; @@ -104,8 +108,6 @@ string_output(char *data, int size) { case '\\': case '"': - case '{': - case '}': *r++ = '\\'; *r++ = c; break; @@ -133,6 +135,13 @@ string_output(char *data, int size) *r++ = '\\'; *r++ = 'v'; break; + case '{': + /* Escape beginning of string, to distinguish from arrays */ + if (p == data) { + *r++ = '\\'; + } + *r++ = c; + break; default: if (NOTPRINTABLE(c)) { @@ -180,8 +189,8 @@ string_output(char *data, int size) * a pointer to the new string or the header. */ -char * -string_input(char *str, int size, int hdrsize, int *rtn_size) +unsigned char * +string_input(unsigned char *str, int size, int hdrsize, int *rtn_size) { register unsigned char *p, *r; @@ -285,7 +294,7 @@ string_input(char *str, int size, int hdrsize, int *rtn_size) return ((char *) result); } -char * +unsigned char * c_charout(int32 c) { char str[2]; @@ -300,7 +309,7 @@ c_charout(int32 c) * This can be used for SET, bytea, text and unknown data types */ -char * +unsigned char * c_textout(struct varlena * vlena) { int len = 0; @@ -318,8 +327,8 @@ c_textout(struct varlena * vlena) * This can be used for varchar and bpchar strings */ -char * -c_varcharout(char *s) +unsigned char * +c_varcharout(unsigned char *s) { int len = 0; @@ -333,7 +342,7 @@ c_varcharout(char *s) #if 0 struct varlena * -c_textin(char *str) +c_textin(unsigned char *str) { struct varlena *result; int len; @@ -348,7 +357,7 @@ c_textin(char *str) } int32 * -c_charin(char *str) +c_charin(unsigned char *str) { return (string_input(str, 1, 0, NULL)); } diff --git a/contrib/string/string_io.h b/contrib/string/string_io.h index b1d2b7e2c28fd9b4c7eae76f0230aa2955988289..e79d7fd28febc7392d56c8102c166561c2182883 100644 --- a/contrib/string/string_io.h +++ b/contrib/string/string_io.h @@ -1,19 +1,16 @@ #ifndef STRING_IO_H #define STRING_IO_H -char *string_output(char *data, int size); -char *string_input(char *str, int size, int hdrsize, int *rtn_size); -char *c_charout(int32 c); -char *c_char2out(uint16 s); -char *c_char4out(uint32 s); -char *c_char8out(char *s); -char *c_char16out(char *s); -char *c_textout(struct varlena * vlena); -char *c_varcharout(char *s); +unsigned char* string_output(unsigned char *data, int size); +unsigned char* string_input(unsigned char *str, int size, int hdrsize, + int *rtn_size); +unsigned char* c_charout(int32 c); +unsigned char* c_textout(struct varlena * vlena); +unsigned char* c_varcharout(unsigned char *s); #if 0 -struct varlena *c_textin(char *str); -char *c_char16in(char *str); +struct varlena* c_textin(unsigned char *str); +int32* c_charin(unsigned char *str) #endif #endif diff --git a/contrib/userlock/Makefile b/contrib/userlock/Makefile index 391956ad7e77189822ff91bafdcdce1d67628b8a..23975185b2a8f78f10583ac3e8e86e66fc5cd4e6 100644 --- a/contrib/userlock/Makefile +++ b/contrib/userlock/Makefile @@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src include $(SRCDIR)/Makefile.global -INCLUDE_OPT = -I ./ \ - -I $(SRCDIR)/ \ - -I $(SRCDIR)/include \ - -I $(SRCDIR)/port/$(PORTNAME) +INCLUDE_OPT = -I./ \ + -I$(SRCDIR)/ \ + -I$(SRCDIR)/include \ + -I$(SRCDIR)/port/$(PORTNAME) CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 7a23a063aaf7bc8e78ecf4ea0641daecc2050921..85a50c103988345bbc48aefb020cd620961fca4c 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 71fd9c8354f2c7b5b9d2da3cb68be7116947f148..1a61d7e6d17828c628c51206df6d4c6f0a8ff3cd 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 044afe165193a563434730c0e54f45c79e1c6421..33ca0ce0a6b8fadb3fecfbc6bbb63aed9a2d28d9 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); diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h index 6f8c79676a2cb4079a1df40786457ea6564d0f6d..ecdb9bbb4e8578b0be1f4137f855054b70fe22eb 100644 --- a/src/include/commands/copy.h +++ b/src/include/commands/copy.h @@ -7,13 +7,14 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: copy.h,v 1.9 2000/01/26 05:58:00 momjian Exp $ + * $Id: copy.h,v 1.10 2000/02/13 18:59:52 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef COPY_H #define COPY_H +extern int lineno; void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filename, char *delim, char *null_print); diff --git a/src/include/utils/trace.h b/src/include/utils/trace.h index 61f0b27da13ef31b7265a0f46be36acb7513dcdc..3cb2d9e28f1d7e18ebd7b2db0641da9877eb4ae5 100644 --- a/src/include/utils/trace.h +++ b/src/include/utils/trace.h @@ -18,7 +18,7 @@ #ifdef ELOG_TIMESTAMPS char *tprintf_timestamp(void); -#define TIMESTAMP_SIZE 30 +#define TIMESTAMP_SIZE 28 #else #define TIMESTAMP_SIZE 0 #endif diff --git a/src/pl/plperl/Makefile.PL b/src/pl/plperl/Makefile.PL index 43773debb5e8cf4623cdaabb344922e678665be9..9285668917b580a5d7478e1d79c17bc0a8c193b8 100644 --- a/src/pl/plperl/Makefile.PL +++ b/src/pl/plperl/Makefile.PL @@ -107,7 +107,7 @@ plperl : plperl.o SPI.o \$(CC) -c \$(CFLAGS) \$< %.o : %.xs - \$(XSUBPP} \$(TYPEMAP) \$< > xtmp.c + \$(XSUBPP) \$(TYPEMAP) \$< > xtmp.c \$(CC) -c \$(CFLAGS) -o \$@ xtmp.c