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

From Greg Stark
Subject Re: Regarding select distinct ...query
Date
Msg-id 87vg1q3lzb.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: Regarding select distinct ...query  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Regarding select distinct ...query  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Regarding select distinct ...query  (Christoph Dalitz <christoph.dalitz@hs-niederrhein.de>)
List pgsql-general
Tom Lane <tgl@sss.pgh.pa.us> writes:

> 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).

Well, if that what the spec says then I would imagine you should at least
follow it in the absence of other information. I don't see what's "dangerous"
about the assumption that valid standard SQL code should be interpreted as
such.

In the current situation we have a perfectly fine standard SQL query that runs
fine on other databases but fails on postgres. And the only way to "fix" it
for postgres is to add a non-standard cast to it that won't work on the other
databases.

I'm kind of surprised actually that it doesn't work the other way around. It
seems like the standard datatypes ought to be the default for all constants
and the kludges should only be necessary to automatically cast strings and
numbers to other datatypes for programmer convenience.

--
greg

pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: trouble caused by change in 7.3 handling of '' in
Next
From: Greg Stark
Date:
Subject: Batch Insert Performance