Thread: pgsql: Allow the syntax CREATE TYPE foo, with no parameters, to permit

pgsql: Allow the syntax CREATE TYPE foo, with no parameters, to permit

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Allow the syntax CREATE TYPE foo, with no parameters, to permit explicit
creation of a shell type.  This allows a less hacky way of dealing with
the mutual dependency between a datatype and its I/O functions: make a
shell type, then make the functions, then define the datatype fully.
We should fix pg_dump to handle things this way, but this commit just deals
with the backend.

Martijn van Oosterhout, with some corrections by Tom Lane.

Modified Files:
--------------
    pgsql/doc/src/sgml/ref:
        create_type.sgml (r1.60 -> r1.61)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_type.sgml.diff?r1=1.60&r2=1.61)
    pgsql/doc/src/sgml:
        xtypes.sgml (r1.25 -> r1.26)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/xtypes.sgml.diff?r1=1.25&r2=1.26)
    pgsql/src/backend/catalog:
        pg_type.c (r1.104 -> r1.105)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/pg_type.c.diff?r1=1.104&r2=1.105)
    pgsql/src/backend/commands:
        typecmds.c (r1.86 -> r1.87)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/typecmds.c.diff?r1=1.86&r2=1.87)
    pgsql/src/backend/parser:
        gram.y (r2.530 -> r2.531)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/gram.y.diff?r1=2.530&r2=2.531)
    pgsql/src/backend/utils/adt:
        pseudotypes.c (r1.15 -> r1.16)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/pseudotypes.c.diff?r1=1.15&r2=1.16)
    pgsql/src/include/catalog:
        catversion.h (r1.316 -> r1.317)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h.diff?r1=1.316&r2=1.317)
        pg_operator.h (r1.140 -> r1.141)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_operator.h.diff?r1=1.140&r2=1.141)
        pg_proc.h (r1.398 -> r1.399)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h.diff?r1=1.398&r2=1.399)
    pgsql/src/include/utils:
        builtins.h (r1.274 -> r1.275)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/builtins.h.diff?r1=1.274&r2=1.275)
    pgsql/src/test/regress/expected:
        create_type.out (r1.12 -> r1.13)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/create_type.out.diff?r1=1.12&r2=1.13)
    pgsql/src/test/regress/sql:
        create_type.sql (r1.8 -> r1.9)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/create_type.sql.diff?r1=1.8&r2=1.9)

Re: pgsql: Allow the syntax CREATE TYPE foo, with no

From
Neil Conway
Date:
On Tue, 2006-02-28 at 18:37 -0400, Tom Lane wrote:
> Allow the syntax CREATE TYPE foo, with no parameters, to permit explicit
> creation of a shell type.

BTW, I noticed that it would be nice to make use of this syntax among
for contrib/ -- if nothing else to avoid the ugly "NOTICE" that is
currently emitted in many cases describing the implicit creation of a
shell type.

-Neil



Neil Conway <neilc@samurai.com> writes:
> On Tue, 2006-02-28 at 18:37 -0400, Tom Lane wrote:
>> Allow the syntax CREATE TYPE foo, with no parameters, to permit explicit
>> creation of a shell type.

> BTW, I noticed that it would be nice to make use of this syntax among
> for contrib/ --

No objection here, if you want to have at it.

> if nothing else to avoid the ugly "NOTICE" that is
> currently emitted in many cases describing the implicit creation of a
> shell type.

As things currently stand, you'll still get some annoying "NOTICE: foo
is a shell type" messages from a completely-kosher creation sequence.
Ideally we should get rid of these, but on the other hand random
references to an incomplete shell type are probably worth warning
about.  Any thoughts about the best approach here?

            regards, tom lane

Re: pgsql: Allow the syntax CREATE TYPE foo, with no parameters, to permit

From
Martijn van Oosterhout
Date:
On Wed, Mar 01, 2006 at 01:52:51AM -0500, Tom Lane wrote:
> > if nothing else to avoid the ugly "NOTICE" that is
> > currently emitted in many cases describing the implicit creation of a
> > shell type.
>
> As things currently stand, you'll still get some annoying "NOTICE: foo
> is a shell type" messages from a completely-kosher creation sequence.
> Ideally we should get rid of these, but on the other hand random
> references to an incomplete shell type are probably worth warning
> about.  Any thoughts about the best approach here?

Yeah, I know. Currently there is no actual way to distinguish between a
shell type created explicitly and one created inplicitly. As long as we
support the old way there's not a lot we can do about that.

My only thought was that the message could be supressed if the shell
type was created in the same transaction as you are currently running.
In that case wrapping everything in a BEGIN/END would supress all the
messages. I don't know whether this kind of behaviour is desirable
though or if it is even feasable.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment