Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muh1E-0003FQ-QV for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Dec 2021 20:24:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1muh1C-0004NJ-Gg for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Dec 2021 20:24:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muh1C-0004N8-68 for pgsql-hackers@lists.postgresql.org; Tue, 07 Dec 2021 20:24:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muh19-0005nI-GN for pgsql-hackers@lists.postgresql.org; Tue, 07 Dec 2021 20:24:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B7KOk5w3573878; Tue, 7 Dec 2021 15:24:46 -0500 From: Tom Lane To: Peter Eisentraut cc: pgsql-hackers@lists.postgresql.org Subject: Re: Dubious usage of TYPCATEGORY_STRING In-reply-to: <3495177.1638892306@sss.pgh.pa.us> References: <2216388.1638480141@sss.pgh.pa.us> <7f0de634-5f0c-315f-80cf-d1218cdc1cf2@enterprisedb.com> <3495177.1638892306@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 07 Dec 2021 10:51:46 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3573810.1638908622.0@sss.pgh.pa.us> Date: Tue, 07 Dec 2021 15:24:46 -0500 Message-ID: <3573877.1638908686@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3573810.1638908622.1@sss.pgh.pa.us> I wrote: > Peter Eisentraut writes: >> Could we add explicit casts (like polcmd::text) here? Or would it break >> too much? > I assumed it'd break too much to consider doing that. But I suppose > that since a typcategory change would be initdb-forcing anyway, maybe > it's not out of the question. I'll investigate and see exactly how > many places would need an explicit cast. Um, I definitely gave up too easily there. The one usage in \dp seems to be the *only* thing that breaks in describe.c, and pg_dump doesn't need any changes so far as check-world reveals. So let's just move "char" to another category, as attached. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name*0="0001-dont-put-special-purpose-types-in-string-category-2.pa"; name*1="tch"; charset="us-ascii" Content-ID: <3573810.1638908622.2@sss.pgh.pa.us> Content-Description: 0001-dont-put-special-purpose-types-in-string-category-2.patch Content-Transfer-Encoding: quoted-printable diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/= citext.out index ec99aaed5d..3bac0534fb 100644 --- a/contrib/citext/expected/citext.out +++ b/contrib/citext/expected/citext.out @@ -1089,7 +1089,12 @@ INSERT INTO caster (char) VALUES ('f'::cit= ext); INSERT INTO caster (citext) VALUES ('f'::char); INSERT INTO caster (chr) VALUES ('f'::text); INSERT INTO caster (text) VALUES ('f'::"char"); -INSERT INTO caster (chr) VALUES ('f'::citext); +INSERT INTO caster (chr) VALUES ('f'::citext); -- requires cas= t +ERROR: column "chr" is of type "char" but expression is of type citext +LINE 1: INSERT INTO caster (chr) VALUES ('f'::citext); + ^ +HINT: You will need to rewrite or cast the expression. +INSERT INTO caster (chr) VALUES ('f'::citext::text); INSERT INTO caster (citext) VALUES ('f'::"char"); INSERT INTO caster (name) VALUES ('foo'::text); INSERT INTO caster (text) VALUES ('foo'::name); diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expecte= d/citext_1.out index 75fd08b7cc..57fc863f7a 100644 --- a/contrib/citext/expected/citext_1.out +++ b/contrib/citext/expected/citext_1.out @@ -1089,7 +1089,12 @@ INSERT INTO caster (char) VALUES ('f'::cit= ext); INSERT INTO caster (citext) VALUES ('f'::char); INSERT INTO caster (chr) VALUES ('f'::text); INSERT INTO caster (text) VALUES ('f'::"char"); -INSERT INTO caster (chr) VALUES ('f'::citext); +INSERT INTO caster (chr) VALUES ('f'::citext); -- requires cas= t +ERROR: column "chr" is of type "char" but expression is of type citext +LINE 1: INSERT INTO caster (chr) VALUES ('f'::citext); + ^ +HINT: You will need to rewrite or cast the expression. +INSERT INTO caster (chr) VALUES ('f'::citext::text); INSERT INTO caster (citext) VALUES ('f'::"char"); INSERT INTO caster (name) VALUES ('foo'::text); INSERT INTO caster (text) VALUES ('foo'::name); diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql index 10232f5a9f..55fb1d11a6 100644 --- a/contrib/citext/sql/citext.sql +++ b/contrib/citext/sql/citext.sql @@ -361,7 +361,8 @@ INSERT INTO caster (citext) VALUES ('f'::char); = INSERT INTO caster (chr) VALUES ('f'::text); INSERT INTO caster (text) VALUES ('f'::"char"); -INSERT INTO caster (chr) VALUES ('f'::citext); +INSERT INTO caster (chr) VALUES ('f'::citext); -- requires cas= t +INSERT INTO caster (chr) VALUES ('f'::citext::text); INSERT INTO caster (citext) VALUES ('f'::"char"); = INSERT INTO caster (name) VALUES ('foo'::text); diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index c1d11be73f..216aa4510d 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -9305,6 +9305,10 @@ SCRAM-SHA-256$<iteration count><= /replaceable>:&l X unknown type + + Z + Internal-use types + diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index ea721d963a..72d8547628 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1142,7 +1142,7 @@ permissionsList(const char *pattern) ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" " || CASE WHEN polcmd !=3D '*' THEN\n" - " E' (' || polcmd || E'):'\n" + " E' (' || polcmd::pg_catalog.text || E'):'\n" " ELSE E':'\n" " END\n" " || CASE WHEN polqual IS NOT NULL THEN\n" @@ -1176,7 +1176,7 @@ permissionsList(const char *pattern) " E' (RESTRICTIVE)'\n" " ELSE '' END\n" " || CASE WHEN polcmd !=3D '*' THEN\n" - " E' (' || polcmd || E'):'\n" + " E' (' || polcmd::pg_catalog.text || E'):'\n" " ELSE E':'\n" " END\n" " || CASE WHEN polqual IS NOT NULL THEN\n" diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type= .dat index 41074c994b..f3d94f3cf5 100644 --- a/src/include/catalog/pg_type.dat +++ b/src/include/catalog/pg_type.dat @@ -42,7 +42,7 @@ typinput =3D> 'byteain', typoutput =3D> 'byteaout', typreceive =3D> 'by= tearecv', typsend =3D> 'byteasend', typalign =3D> 'i', typstorage =3D> 'x' }, { oid =3D> '18', array_type_oid =3D> '1002', descr =3D> 'single character= ', - typname =3D> 'char', typlen =3D> '1', typbyval =3D> 't', typcategory =3D= > 'S', + typname =3D> 'char', typlen =3D> '1', typbyval =3D> 't', typcategory =3D= > 'Z', typinput =3D> 'charin', typoutput =3D> 'charout', typreceive =3D> 'char= recv', typsend =3D> 'charsend', typalign =3D> 'c' }, { oid =3D> '19', array_type_oid =3D> '1003', @@ -145,24 +145,24 @@ typsend =3D> 'xml_send', typalign =3D> 'i', typstorage =3D> 'x' }, { oid =3D> '194', descr =3D> 'string representing an internal node tree', typname =3D> 'pg_node_tree', typlen =3D> '-1', typbyval =3D> 'f', - typcategory =3D> 'S', typinput =3D> 'pg_node_tree_in', + typcategory =3D> 'Z', typinput =3D> 'pg_node_tree_in', typoutput =3D> 'pg_node_tree_out', typreceive =3D> 'pg_node_tree_recv', typsend =3D> 'pg_node_tree_send', typalign =3D> 'i', typstorage =3D> 'x= ', typcollation =3D> 'default' }, { oid =3D> '3361', descr =3D> 'multivariate ndistinct coefficients', typname =3D> 'pg_ndistinct', typlen =3D> '-1', typbyval =3D> 'f', - typcategory =3D> 'S', typinput =3D> 'pg_ndistinct_in', + typcategory =3D> 'Z', typinput =3D> 'pg_ndistinct_in', typoutput =3D> 'pg_ndistinct_out', typreceive =3D> 'pg_ndistinct_recv', typsend =3D> 'pg_ndistinct_send', typalign =3D> 'i', typstorage =3D> 'x= ', typcollation =3D> 'default' }, { oid =3D> '3402', descr =3D> 'multivariate dependencies', typname =3D> 'pg_dependencies', typlen =3D> '-1', typbyval =3D> 'f', - typcategory =3D> 'S', typinput =3D> 'pg_dependencies_in', + typcategory =3D> 'Z', typinput =3D> 'pg_dependencies_in', typoutput =3D> 'pg_dependencies_out', typreceive =3D> 'pg_dependencies_= recv', typsend =3D> 'pg_dependencies_send', typalign =3D> 'i', typstorage =3D>= 'x', typcollation =3D> 'default' }, { oid =3D> '5017', descr =3D> 'multivariate MCV list', - typname =3D> 'pg_mcv_list', typlen =3D> '-1', typbyval =3D> 'f', typcat= egory =3D> 'S', + typname =3D> 'pg_mcv_list', typlen =3D> '-1', typbyval =3D> 'f', typcat= egory =3D> 'Z', typinput =3D> 'pg_mcv_list_in', typoutput =3D> 'pg_mcv_list_out', typreceive =3D> 'pg_mcv_list_recv', typsend =3D> 'pg_mcv_list_send', typalign =3D> 'i', typstorage =3D> 'x', typcollation =3D> 'default' }, @@ -681,13 +681,13 @@ typalign =3D> 'd', typstorage =3D> 'x' }, { oid =3D> '4600', descr =3D> 'BRIN bloom summary', typname =3D> 'pg_brin_bloom_summary', typlen =3D> '-1', typbyval =3D> '= f', - typcategory =3D> 'S', typinput =3D> 'brin_bloom_summary_in', + typcategory =3D> 'Z', typinput =3D> 'brin_bloom_summary_in', typoutput =3D> 'brin_bloom_summary_out', typreceive =3D> 'brin_bloom_summary_recv', typsend =3D> 'brin_bloom_sum= mary_send', typalign =3D> 'i', typstorage =3D> 'x', typcollation =3D> 'default' }, { oid =3D> '4601', descr =3D> 'BRIN minmax-multi summary', typname =3D> 'pg_brin_minmax_multi_summary', typlen =3D> '-1', typbyval= =3D> 'f', - typcategory =3D> 'S', typinput =3D> 'brin_minmax_multi_summary_in', + typcategory =3D> 'Z', typinput =3D> 'brin_minmax_multi_summary_in', typoutput =3D> 'brin_minmax_multi_summary_out', typreceive =3D> 'brin_minmax_multi_summary_recv', typsend =3D> 'brin_minmax_multi_summary_send', typalign =3D> 'i', diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index e568e21dee..5e891a0596 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -294,6 +294,7 @@ DECLARE_UNIQUE_INDEX(pg_type_typname_nsp_index, 2704, = TypeNameNspIndexId, on pg_ #define TYPCATEGORY_USER 'U' #define TYPCATEGORY_BITSTRING 'V' /* er ... "varbit"? */ #define TYPCATEGORY_UNKNOWN 'X' +#define TYPCATEGORY_INTERNAL 'Z' = #define TYPALIGN_CHAR 'c' /* char alignment (i.e. unaligned) */ #define TYPALIGN_SHORT 's' /* short alignment (typically 2 bytes) */ ------- =_aaaaaaaaaa0--