pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Create a new type category for "internal use" types.
Date: Sat, 11 Dec 2021 19:11:01 +0000
Message-ID: <E1mw7lt-0002wT-Ua@gemulon.postgresql.org> (raw)

Create a new type category for "internal use" types.

Historically we've put type "char" into the S (String) typcategory,
although calling it a string is a stretch considering it can only
store one byte.  (In our actual usage, it's more like an enum.)
This choice now seems wrong in view of the special heuristics
that parse_func.c and parse_coerce.c have for TYPCATEGORY_STRING:
it's not a great idea for "char" to have those preferential casting
behaviors.

Worse than that, recent patches inventing special-purpose types
like pg_node_tree have assigned typcategory S to those types,
meaning they also get preferential casting treatment that's designed
on the assumption that they can hold arbitrary text.

To fix, invent a new category TYPCATEGORY_INTERNAL for internal-use
types, and assign that to all these types.  I used code 'Z' for
lack of a better idea ('I' was already taken).

This change breaks one query in psql/describe.c, which now needs to
explicitly cast a catalog "char" column to text before concatenating
it with an undecorated literal.  Also, a test case in contrib/citext
now needs an explicit cast to convert citext to "char".  Since the
point of this change is to not have "char" be a surprisingly-available
cast target, these breakages seem OK.

Per report from Ian Campbell.

Discussion: https://postgr.es/m/2216388.1638480141@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/07eee5a0dc642d26f44d65c4e6263304208e8583

Modified Files
--------------
contrib/citext/expected/citext.out   |  7 ++++++-
contrib/citext/expected/citext_1.out |  7 ++++++-
contrib/citext/sql/citext.sql        |  3 ++-
doc/src/sgml/catalogs.sgml           |  4 ++++
src/bin/psql/describe.c              |  4 ++--
src/include/catalog/catversion.h     |  2 +-
src/include/catalog/pg_type.dat      | 14 +++++++-------
src/include/catalog/pg_type.h        |  1 +
8 files changed, 29 insertions(+), 13 deletions(-)



Message-ID: <E1mw7lt-0002wT-Ua@gemulon.postgresql.org>
Permalink:  ../E1mw7lt-0002wT-Ua@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mw7lt-0002wT-Ua@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Create a new type category for "internal use" types.
  In-Reply-To: <E1mw7lt-0002wT-Ua@gemulon.postgresql.org>
  References: <E1mw7lt-0002wT-Ua@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox