pgsql: Replace the hard-wired type knowledge in TypeCategory() and - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Replace the hard-wired type knowledge in TypeCategory() and
Date
Msg-id 20080730170505.84246754A86@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        catalogs.sgml (r2.171 -> r2.172)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/catalogs.sgml?r1=2.171&r2=2.172)
        typeconv.sgml (r1.55 -> r1.56)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/typeconv.sgml?r1=1.55&r2=1.56)
    pgsql/doc/src/sgml/ref:
        create_type.sgml (r1.74 -> r1.75)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_type.sgml?r1=1.74&r2=1.75)
    pgsql/src/backend/catalog:
        heap.c (r1.334 -> r1.335)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/heap.c?r1=1.334&r2=1.335)
        pg_type.c (r1.119 -> r1.120)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/pg_type.c?r1=1.119&r2=1.120)
    pgsql/src/backend/commands:
        indexcmds.c (r1.177 -> r1.178)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/indexcmds.c?r1=1.177&r2=1.178)
        typecmds.c (r1.119 -> r1.120)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/typecmds.c?r1=1.119&r2=1.120)
    pgsql/src/backend/parser:
        parse_coerce.c (r2.161 -> r2.162)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_coerce.c?r1=2.161&r2=2.162)
        parse_func.c (r1.203 -> r1.204)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_func.c?r1=1.203&r2=1.204)
    pgsql/src/backend/utils/cache:
        lsyscache.c (r1.157 -> r1.158)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/lsyscache.c?r1=1.157&r2=1.158)
    pgsql/src/bin/pg_dump:
        pg_dump.c (r1.497 -> r1.498)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/pg_dump/pg_dump.c?r1=1.497&r2=1.498)
    pgsql/src/include/catalog:
        catversion.h (r1.471 -> r1.472)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.471&r2=1.472)
        pg_attribute.h (r1.139 -> r1.140)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_attribute.h?r1=1.139&r2=1.140)
        pg_class.h (r1.106 -> r1.107)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_class.h?r1=1.106&r2=1.107)
        pg_type.h (r1.197 -> r1.198)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_type.h?r1=1.197&r2=1.198)
        pg_type_fn.h (r1.1 -> r1.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_type_fn.h?r1=1.1&r2=1.2)
    pgsql/src/include/parser:
        parse_coerce.h (r1.75 -> r1.76)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/parse_coerce.h?r1=1.75&r2=1.76)
    pgsql/src/include/utils:
        lsyscache.h (r1.123 -> r1.124)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/lsyscache.h?r1=1.123&r2=1.124)
    pgsql/src/test/regress/expected:
        create_type.out (r1.14 -> r1.15)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/create_type.out?r1=1.14&r2=1.15)
    pgsql/src/test/regress/sql:
        create_type.sql (r1.10 -> r1.11)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/create_type.sql?r1=1.10&r2=1.11)

pgsql-committers by date:

Previous
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Add a new, improved version of citext as a contrib module.
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Adjust citext to make use of the new ability to declare its type