Create a new type category for "internal use" types.
Tom Lane <tgl@sss.pgh.pa.us>
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
Files
| Path | Change | +/− |
|---|---|---|
| contrib/citext/expected/citext_1.out | modified | +6 −1 |
| contrib/citext/expected/citext.out | modified | +6 −1 |
| contrib/citext/sql/citext.sql | modified | +2 −1 |
| doc/src/sgml/catalogs.sgml | modified | +4 −0 |
| src/bin/psql/describe.c | modified | +2 −2 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_type.dat | modified | +7 −7 |
| src/include/catalog/pg_type.h | modified | +1 −0 |
Documentation touched
Discussion
- Dubious usage of TYPCATEGORY_STRING 14 messages · 2021-12-02 → 2022-01-03