From e8e746de34d1f43a4b3936ff73630a70244cdc5f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 25 Sep 2008 03:28:56 +0000 Subject: [PATCH] Establish the rule that array types should have the same typdelim as their element types. Since the backend doesn't actually pay attention to the array type's delimiter, this has no functional effect, but it seems better for the catalog entries to be consistent. Per gripe from Greg Mullane and subsequent discussion. --- src/backend/commands/typecmds.c | 4 ++-- src/include/catalog/catversion.h | 4 ++-- src/include/catalog/pg_type.h | 4 ++-- src/test/regress/expected/type_sanity.out | 8 ++++++++ src/test/regress/sql/type_sanity.sql | 6 ++++++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index c0dc74bee79..3e573bc3943 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.123 2008/08/28 23:09:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.124 2008/09/25 03:28:56 tgl Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -497,7 +497,7 @@ DefineType(List *names, List *parameters) TYPTYPE_BASE, /* type-type (base type) */ TYPCATEGORY_ARRAY, /* type-category (array) */ false, /* array types are never preferred */ - DEFAULT_TYPDELIM, /* array element delimiter */ + delimiter, /* array element delimiter */ F_ARRAY_IN, /* input procedure */ F_ARRAY_OUT, /* output procedure */ F_ARRAY_RECV, /* receive procedure */ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index e7f96f78c14..d066cf6671d 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.488 2008/09/23 09:20:38 heikki Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.489 2008/09/25 03:28:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200809231 +#define CATALOG_VERSION_NO 200809241 #endif diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 8e82997b735..d4f4fc0968b 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.199 2008/07/30 19:35:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.200 2008/09/25 03:28:56 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -446,7 +446,7 @@ DATA(insert OID = 1016 ( _int8 PGNSP PGUID -1 f b A f t \054 0 20 0 array_in DATA(insert OID = 1017 ( _point PGNSP PGUID -1 f b A f t \054 0 600 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1018 ( _lseg PGNSP PGUID -1 f b A f t \054 0 601 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1019 ( _path PGNSP PGUID -1 f b A f t \054 0 602 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 1020 ( _box PGNSP PGUID -1 f b A f t \054 0 603 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 1020 ( _box PGNSP PGUID -1 f b A f t \073 0 603 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1021 ( _float4 PGNSP PGUID -1 f b A f t \054 0 700 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); #define FLOAT4ARRAYOID 1021 DATA(insert OID = 1022 ( _float8 PGNSP PGUID -1 f b A f t \054 0 701 0 array_in array_out array_recv array_send - - - d x f 0 -1 0 _null_ _null_ )); diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out index 48b51466061..be86ee313be 100644 --- a/src/test/regress/expected/type_sanity.out +++ b/src/test/regress/expected/type_sanity.out @@ -254,6 +254,14 @@ WHERE p1.typelem = p2.oid AND NOT -----+---------+-----+--------- (0 rows) +-- Array types should have same typdelim as their element types +SELECT p1.oid, p1.typname, p2.oid, p2.typname +FROM pg_type AS p1, pg_type AS p2 +WHERE p1.typarray = p2.oid AND NOT (p1.typdelim = p2.typdelim); + oid | typname | oid | typname +-----+---------+-----+--------- +(0 rows) + -- Check for bogus typanalyze routines SELECT p1.oid, p1.typname, p2.oid, p2.proname FROM pg_type AS p1, pg_proc AS p2 diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql index e28fccab6c9..265ef5e26e2 100644 --- a/src/test/regress/sql/type_sanity.sql +++ b/src/test/regress/sql/type_sanity.sql @@ -196,6 +196,12 @@ FROM pg_type AS p1, pg_type AS p2 WHERE p1.typelem = p2.oid AND NOT (p1.typmodin = p2.typmodin AND p1.typmodout = p2.typmodout); +-- Array types should have same typdelim as their element types + +SELECT p1.oid, p1.typname, p2.oid, p2.typname +FROM pg_type AS p1, pg_type AS p2 +WHERE p1.typarray = p2.oid AND NOT (p1.typdelim = p2.typdelim); + -- Check for bogus typanalyze routines SELECT p1.oid, p1.typname, p2.oid, p2.proname -- 2.30.2