Re: Regarding select distinct ...query - Mailing list pgsql-general

From Tom Lane
Subject Re: Regarding select distinct ...query
Date
Msg-id 12885.1040254044@sss.pgh.pa.us
Whole thread Raw
In response to Re: Regarding select distinct ...query  (Greg Stark <gsstark@mit.edu>)
Responses Re: Regarding select distinct ...query
List pgsql-general
Greg Stark <gsstark@mit.edu> writes:
> I ran into precisely the same issue here yesterday. This works perfectly fine
> in Oracle, does the standard really leave "select distinct 'foo'" undefined?

The standard has no notion of datatype extensibility, so it's got no
problem with legislating that anything between single quotes is of type
CHAR(n).  If we followed the spec closely on this point, you'd probably
need an explicit cast for *every* literal you wanted to be of a datatype
other than numeric (no quotes) or string (with quotes).

We do have some kluges in place to default to assuming that
string-looking literals are of type TEXT when we can't figure out
anything else, but those kluges didn't cover the SELECT DISTINCT 'foo'
case last time I looked.  It's a fairly dangerous default assumption
IMHO, so I think it's appropriate to make it only in very narrowly
defined cases ...

            regards, tom lane

pgsql-general by date:

Previous
From: Simon Mitchell
Date:
Subject: Re: ORDER BY random() LIMIT 1 slowness
Next
From: Benjamin Scherrey
Date:
Subject: Re: trouble caused by change in 7.3 handling of '' in