Re: Regarding select distinct ...query

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, "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-19 00:12:40
Message-ID: 87vg1q3lzb.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

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

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2002-12-19 00:41:12 Batch Insert Performance
Previous Message Peter Eisentraut 2002-12-19 00:06:37 Re: trouble caused by change in 7.3 handling of '' in