From: David Gould <daveg@sonic.net>
To: amutu@amutu.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13805: plpgsql execute using expression evaluate wrong
Date: Mon, 7 Dec 2015 22:08:47 -0800
Message-ID: <20151207220847.4da716e1@engels> (raw)
In-Reply-To: <20151208035444.5253.30717@wrigleys.postgresql.org>
References: <20151208035444.5253.30717@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Tue, 08 Dec 2015 03:54:44 +0000
amutu@amutu.com wrote:
> execute $$select ('$1 month')::interval $$ into rt2 using n;
> raise notice 'rt2 : %',rt2;
>
> execute $$select ($1::varchar || ' month')::interval $$ into rt2 using n;
> raise notice 'rt2 : %',rt2;
> end;
> NOTICE: rt2 : 1 mon-----wrong,should 4 mons
> NOTICE: rt2 : 4 mons
You may have found a bug, but if so, it is not where you think it is. The
expression: '$1 month' is a text literal. PL/PGsql does not interpolate $n
like a shell, it only does the substitution where a variable could
ordinarily exist.
However, it does seem a little odd that the literal syntax for
intervals accepts the '$':
postgres=# select '$1 month'::interval, '$4 month'::interval;
interval | interval
----------+----------
1 mon | 4 mons
(1 row)
I would have expected it to raise an error. The documentation does not shed
any light on this. Anyone?
-dg
--
David Gould 510 282 0869 daveg@sonic.net
If simplicity worked, the world would be overrun with insects.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: daveg@sonic.net, amutu@amutu.com
Subject: Re: BUG #13805: plpgsql execute using expression evaluate wrong
In-Reply-To: <20151207220847.4da716e1@engels>
References: <20151208035444.5253.30717@wrigleys.postgresql.org> <20151207220847.4da716e1@engels>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox