Re: Weird type selection choice

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Weird type selection choice
Date: 2007-11-07 16:02:00
Message-ID: 17278.1194451320@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacques Caron 2007-11-07 16:18:29 pg_statistic "forced" values
Previous Message Peter Eisentraut 2007-11-07 15:50:56 interval * numeric operator