Re: Weird type selection choice - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Weird type selection choice
Date
Msg-id 17278.1194451320@sss.pgh.pa.us
Whole thread Raw
In response to Re: Weird type selection choice  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Am Mittwoch, 7. November 2007 schrieb Heikki Linnakangas:
>> Why would you run a query like that in the first place? It seems like a
>> useless query as it is. Is there a bigger story behind it?

> The "1" is substituted from somewhere else.

Seems like textual substitution is not the optimal approach for such a
thing anyway --- why aren't they using a parameter?  This is hardly the
only gotcha, as an unadorned numeric literal might be taken as either
int, bigint, or numeric depending on its value.  I am sure there are
contexts in which a bigint might cause some surprising choices.

If they really want to stick with textual substitution, an explicit cast
inserted into the query seems the safest bet.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: interval * numeric operator
Next
From: Jacques Caron
Date:
Subject: pg_statistic "forced" values