Re: [HACKERS] MIN not defined for OID types - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] MIN not defined for OID types
Date
Msg-id 35F187D8.790116A2@alumni.caltech.edu
Whole thread Raw
In response to Re: [HACKERS] MIN not defined for OID types  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
> Yes, well, in this case, it comes about as a result of trying to make
> something database independent.  Keystone has functions for both
> PostgreSQL and MySQL, and the MySQL way of doing things seems to be
> limitation.  As a result, the DB-independent code does a "select *
> from <table>" then queries to find what the column names are.
> Obviously, we don't need to do it that way with PostgreSQL.  My "hack"
> was to change the query so it wouldn't pull back the whole table just
> to find the column names, so I did a "select * from <table> where
> oid=min(oid)".

Ah. Try another hack:

  SELECT * from <table> WHERE FALSE;

That will return zero rows but tell you about the columns. Even better,
it won't traverse the table or an index as a min() operation would since
the optimizer can tell apriori that there will be no matching rows.

I haven't done it myself, but psql seems to get the information it needs
about the columns with a query as above. And if that doesn't work then
there will be another trick which does work for you; someone on the list
will tell us :)

                      - Tom

pgsql-hackers by date:

Previous
From: Roland Roberts
Date:
Subject: Re: [HACKERS] MIN not defined for OID types
Next
From: Roland Roberts
Date:
Subject: Re: [HACKERS] MIN not defined for OID types