Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Enticing interns to PostgreSQL

From: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
To: Chris Travers <chris(at)travelamericas(dot)com>
Cc: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>,PostgreSQL advocacy <pgsql-advocacy(at)postgresql(dot)org>
Subject: Re: [HACKERS] Enticing interns to PostgreSQL
Date: 2005-07-26 20:09:11
Message-ID: 42E69867.5000106@empires.org (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-advocacypgsql-hackers
Chris Travers wrote:
>>
> How hard would it be to automatically create enum_ tables in the back
> ground to emulate MySQL's enum type?  Sort of like we do with SERIAL
> datatypes...  Part of the problem is that MySQL's enum type is so
> braindead from a database design perspective that most of us would not
> be interested in using it.  Emulating an int foreign key for another
> created table might make it ok, though.
> 

The thing that occurs to me is that if you really want the enum type in
PostgreSQL (assuming that there exists a real need), a PostgreSQL person
would create their own type. Or, if not, just create a wrapper function
that handles the input/output display and call it explicitly.

So to me, the need seems very weak. However, if your goal is
compatibility, I guess we need it. The problem is it's very difficult to
do in a general way. We'd probably have to do it specifically for enum,
and have it generate the types automatically on the fly. Someone would
have to do some interesting things with the parser, too. Right now even
the varchar() type, for instance, is kind of a hack.

Ultimately to do it in a general way I think we'd need functions that
return a type that can be used in a table definition. Aside from the
many problems I don't know about, there are two other problems:
(1) After the table (or column?) is dropped, we need to drop the type.
(2) Functions currently don't support variable numbers of arguments, so
enum still wouldn't be simple. We could do something kinda dumb-looking
like:
CREATE TABLE mytable (
  color ENUM("red,green,blue,orange,purple,yellow");
);
And have the hypothetical ENUM function then parse the single argument
and return a type that could be used by that table.

Is this achievable with a reasonable amount of effort? Is this
function-returning-a-type a reasonable behavior?

If nothing else it would clean up the clutter of varchar() and the like,
that currently use the hacked-in catalog entry "atttypmod" or something
like that.

Regards,
	Jeff Davis

In response to

Responses

  • ENUM type at 2005-07-26 20:22:35 from Jim C. Nasby

pgsql-hackers by date

Next:From: Palle GirgensohnDate: 2005-07-26 20:17:05
Subject: Re: More buildfarm stuff
Previous:From: Jim C. NasbyDate: 2005-07-26 19:50:40
Subject: Re: [HACKERS] Enticing interns to PostgreSQL

pgsql-advocacy by date

Next:From: Chris TraversDate: 2005-07-26 20:20:58
Subject: Re: [HACKERS] Enticing interns to PostgreSQL
Previous:From: Jim C. NasbyDate: 2005-07-26 19:50:40
Subject: Re: [HACKERS] Enticing interns to PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group