]> granicus.if.org Git - postgresql/commit
Replace the hard-wired type knowledge in TypeCategory() and IsPreferredType()
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Jul 2008 17:05:05 +0000 (17:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Jul 2008 17:05:05 +0000 (17:05 +0000)
commitbac3e83622b588eb449eb4e26c4b1e62e7cca3d5
tree419f9079e41450aaaaa5ed0b8c8fa849a46d5bf9
parentab9907f5e5eba6e4e17a279d07a1a9df21ec5b19
Replace the hard-wired type knowledge in TypeCategory() and IsPreferredType()
with system catalog lookups, as was foreseen to be necessary almost since
their creation.  Instead put the information into two new pg_type columns,
typcategory and typispreferred.  Add support for setting these when
creating a user-defined base type.

The category column is just a "char" (i.e. a poor man's enum), allowing
a crude form of user extensibility of the category list: just use an
otherwise-unused character.  This seems sufficient for foreseen uses,
but we could upgrade to having an actual category catalog someday, if
there proves to be a huge demand for custom type categories.

In this patch I have attempted to hew exactly to the behavior of the
previous hardwired logic, except for introducing new type categories for
arrays, composites, and enums.  In particular the default preferred state
for user-defined types remains TRUE.  That seems worth revisiting, but it
should be done as a separate patch from introducing the infrastructure.
Likewise, any adjustment of the standard set of categories should be done
separately.
20 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/ref/create_type.sgml
doc/src/sgml/typeconv.sgml
src/backend/catalog/heap.c
src/backend/catalog/pg_type.c
src/backend/commands/indexcmds.c
src/backend/commands/typecmds.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_func.c
src/backend/utils/cache/lsyscache.c
src/bin/pg_dump/pg_dump.c
src/include/catalog/catversion.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_class.h
src/include/catalog/pg_type.h
src/include/catalog/pg_type_fn.h
src/include/parser/parse_coerce.h
src/include/utils/lsyscache.h
src/test/regress/expected/create_type.out
src/test/regress/sql/create_type.sql