From: | Jov <amutu(at)amutu(dot)com> |
---|---|
To: | David Gould <daveg(at)sonic(dot)net> |
Cc: | pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #13805: plpgsql execute using expression evaluate wrong |
Date: | 2015-12-08 06:15:56 |
Message-ID: | CADyrUxNKv6k6Oi5JTUO28xCYVfWO3364RUy96Na22UGA2Xa0xg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Yes,I think this trigger an error is reasonable.It take me 2 hours to find
the problem,not friendly.
Jov
blog: http:amutu.com/blog <http://amutu.com/blog>
2015-12-08 14:08 GMT+08:00 David Gould <daveg(at)sonic(dot)net>:
> On Tue, 08 Dec 2015 03:54:44 +0000
> amutu(at)amutu(dot)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(at)sonic(dot)net
> If simplicity worked, the world would be overrun with insects.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-12-08 06:36:39 | Re: BUG #13805: plpgsql execute using expression evaluate wrong |
Previous Message | David Gould | 2015-12-08 06:08:47 | Re: BUG #13805: plpgsql execute using expression evaluate wrong |