From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Subject: | [PATCH] WIP: Create shell-types explicitly |
Date: | 2006-02-20 11:57:24 |
Message-ID: | 20060220115724.GC12673@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
[Please CC any replies, thanks]
Persuant to the recent discussion, here is a patch to allow users to
create shell types by using the symtax:
CREATE TYPE foo;
It was actually much easier than I thought given that normal type
creation creates a shell type just before creating the real type. This
means it works just by stopping after creating the shell type before
creating the real type. This also means that issuing a "CREATE TYPE
foo;" on an already existing type succeeds without doing anything, just
like structure declarations in C.
Unfortuntly there are some minor issues not quite considered when this
was first brought up. Primarily this:
postgres=# create type text;
CREATE TYPE
postgres=# select * from pg_type where typname = 'text';
typname | typnamespace | typowner | typlen | typbyval | typtype | typisdefined | typdelim | typrelid | typelem | typinput | typoutput | typreceive | typsend | typanalyze | typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typdefaultbin | typdefault
---------+--------------+----------+--------+----------+---------+--------------+----------+----------+---------+----------+-----------+------------+----------+------------+----------+------------+------------+-------------+-----------+----------+---------------+------------
text | 11 | 10 | -1 | f | b | t | , | 0 | 0 | textin | textout | textrecv | textsend | - | i | x | f | 0 | -1 | 0 | |
text | 2200 | 10 | 4 | t | p | f | , | 0 | 0 | shell_in | shell_out | - | - | - | i | p | f | 0 | -1 | 0 | |
(2 rows)
postgres=# drop type text;
ERROR: cannot drop type text because it is required by the database system
postgres=# drop type public.text;
DROP TYPE
The first line creates public.text, but the drop tries to delete
pg_catalog.text. I'm not sure which we should make smarter, the create
or the drop, or whether just the error messages need to be made much
clearer as to what's going on.
Other points:
- Changed the shell create function to create a type with the same
parameters as a pseudotype. This should address Tom's issue with code
not paying attention to the fact the type is not complete yet.
- Created two functions shell_in and shell_out persuant to making shell
types look like pseudo types. I however didn't actually create a
pseudotype "shell" so shell_in actually returns "opaque". Do people
have a problem with this?
- I still think it would be useful to require people to create the
shell type and the complete type within the same transaction, if only
to prevent people filling up catalog with useless entries. Shell types
can be dropped as normal, but still...
- Includes documentation updates. Does not include regression tests,
yet.
Comments?
http://svana.org/kleptog/pgsql/shell.diff
--
Martijn van Oosterhout <kleptog(at)svana(dot)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 | Content-Type | Size |
---|---|---|
shell.diff | text/plain | 12.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Kreen | 2006-02-20 13:06:34 | Re: pgcrypto: fix memory leak in openssl.c |
Previous Message | Milorad Poluga | 2006-02-20 08:39:27 | Re: Interval subtracting |