Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Merlin Moncure
On 8/30/07, Tom Lane [EMAIL PROTECTED] wrote: Merlin Moncure [EMAIL PROTECTED] writes: I noticed that enums are not available to be queried as binary through the protocol. What do you think the binary representation ought to be? Copying OIDs seems pretty useless. I'm on the fence on this

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Andrew Dunstan
Merlin Moncure wrote: One other very small observation: afaict, there appears to be no way to list enum contents in psql (although you can list the enums themselves in the type listing). select enum_range(null::myenumtype); I'm willing to take a stab at these things if Andrew is busy.

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Tom Lane
Merlin Moncure [EMAIL PROTECTED] writes: On 8/30/07, Tom Lane [EMAIL PROTECTED] wrote: What do you think the binary representation ought to be? Copying OIDs seems pretty useless. I actually think this would be ok, if you mean pg_enum.oid, or the string would be fine too. I agree that

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Gregory Stark
Merlin Moncure [EMAIL PROTECTED] writes: On 8/30/07, Tom Lane [EMAIL PROTECTED] wrote: Merlin Moncure [EMAIL PROTECTED] writes: I noticed that enums are not available to be queried as binary through the protocol. What do you think the binary representation ought to be? Copying OIDs

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Alvaro Herrera
Gregory Stark escribió: I think it would be ok only if a pg_dump/pg_restore reliably restored the same oid-enum value mapping. Otherwise a binary dump is useless. But as I understand it that's the case currently, is it? That doesn't work if the dump is restored on a database that already has

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Gregory Stark
Alvaro Herrera [EMAIL PROTECTED] writes: Gregory Stark escribió: I think it would be ok only if a pg_dump/pg_restore reliably restored the same oid-enum value mapping. Otherwise a binary dump is useless. But as I understand it that's the case currently, is it? er, lost a not in the

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Tom Lane
Gregory Stark [EMAIL PROTECTED] writes: enum OIDs are unique across enums? This seems like a strange way to do it. That decision was already made, we are not revisiting it (at least not for 8.3). regards, tom lane ---(end of

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Andrew Dunstan
Gregory Stark wrote: enum OIDs are unique across enums? This seems like a strange way to do it. I recall conversations about this a while back though and there were limitations of the type system that led to this, right? No, not the type system as such. It stems from this quote from Tom:

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Decibel!
On Fri, Aug 31, 2007 at 08:49:05AM -0400, Merlin Moncure wrote: On 8/30/07, Tom Lane [EMAIL PROTECTED] wrote: Merlin Moncure [EMAIL PROTECTED] writes: I noticed that enums are not available to be queried as binary through the protocol. What do you think the binary representation ought

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Andrew Dunstan
Decibel! wrote: The last time I worked on a project where we had C code access the database, we added stuff to map C enums to ints in the database (along with a parent table to store the enum label). ISTM it'd be good if we had a way to get the numeric index out of an enum. If you mean

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Decibel!
On Fri, Aug 31, 2007 at 01:41:47PM -0400, Andrew Dunstan wrote: The technique of using a lookup table that you seem to refer to doesn't need any special support from the catalogs or the type system. It's used today in millions of applications. But it can have quite a high cost in extra

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Andrew Dunstan
Decibel! wrote: On Fri, Aug 31, 2007 at 01:41:47PM -0400, Andrew Dunstan wrote: The technique of using a lookup table that you seem to refer to doesn't need any special support from the catalogs or the type system. It's used today in millions of applications. But it can have quite a high

Re: [HACKERS] enum types and binary queries

2007-08-31 Thread Andrew Dunstan
Andrew Dunstan wrote: This is a furfy that has been raised before and explained before. Of course, as usual I misspelled it, the word is furphy. I didn't realise that it was an Australianism. It means more or less a red herring. Wikipedia says that it is a term particularly popular in

Re: [HACKERS] enum types and binary queries

2007-08-30 Thread Andrew Dunstan
Merlin Moncure wrote: I noticed that enums are not available to be queried as binary through the protocol. Is this a known issue? Too late to fix for 8.3? This is kind of a pain, because it forces any query that returns an enum to return the entire result as text. afaik, enums are the only

Re: [HACKERS] enum types and binary queries

2007-08-30 Thread Tom Lane
Merlin Moncure [EMAIL PROTECTED] writes: I noticed that enums are not available to be queried as binary through the protocol. What do you think the binary representation ought to be? Copying OIDs seems pretty useless. regards, tom lane ---(end

Re: [HACKERS] enum types and binary queries

2007-08-30 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: Merlin Moncure wrote: I noticed that enums are not available to be queried as binary through the protocol. The trouble is that an enum doesn't have an immutable internal binary value. I guess we could say that the binary value is the integer offset

Re: [HACKERS] enum types and binary queries

2007-08-30 Thread korry.douglas
What if we just defined the binary format as being identical to the text format, ie, the enum label? A bit silly but at least it would eliminate the gotcha that binary I/O fails. Seems like it would make a lot more sense to the client application that way too... -- Korry

Re: [HACKERS] enum types and binary queries

2007-08-30 Thread Andrew Dunstan
Tom Lane wrote: What if we just defined the binary format as being identical to the text format, ie, the enum label? A bit silly but at least it would eliminate the gotcha that binary I/O fails. So we should pretty much mimic text_send/text_recv? If so I can probably get that