From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | enums |
Date: | 2005-10-27 19:47:53 |
Message-ID: | 43612EE9.5010209@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
If people would like to play, I have created a little kit to help in
creating first class enum types in a few seconds. It works something
like this:
make TYPENAME=rainbow ENUMS=' "red", "orange", "yellow", "green",
"blue", "indigo", "violet" '
make TYPENAME=rainbow install
psql -f /path/to/contrib/rainbow-install.sql yourdb
and you are done. Now you can do:
create table foo( r rainbow);
insert into foo values('red');
select 'red'::rainbow < 'green'::rainbow; <-- yields true
select rainbow_order('yellow'); <-- yields 2
The kit is at http://developer.postgresql.org/~adunstan/enumkit.tgz
Needs 8.0 or later, since it use PGXS.
Maximum number of values is 32767 - but if you use that many you're
insane anyway :-)
I did this as part of thinking about how we might do enums properly. AS
Chris KL recently noted - it is very often asked for. So this is not the
end of the road, just a tiny step at the beginning.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-10-27 20:09:20 | Re: [GENERAL] aix build question re: duplicate symbol warning |
Previous Message | Tom Lane | 2005-10-27 19:46:08 | Re: aix build question re: duplicate symbol warning |