Re: Regarding select distinct ...query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: "Prachi Jain" <prachijain3(at)rediffmail(dot)com>, christoph(dot)dalitz(at)hs-niederrhein(dot)de, pgsql-general(at)postgresql(dot)org
Subject: Re: Regarding select distinct ...query
Date: 2002-12-18 23:27:24
Message-ID: 12885.1040254044@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greg Stark <gsstark(at)mit(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Benjamin Scherrey 2002-12-18 23:32:30 Re: trouble caused by change in 7.3 handling of '' in
Previous Message Simon Mitchell 2002-12-18 23:16:11 Re: ORDER BY random() LIMIT 1 slowness