Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Cédric Villemain
2010/8/16 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Yes, and you point out another thing. EXECUTE is a way to bypass the named prepare statement, to be sure query is replanned each time. Unfortunely the current implementation

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: 2010/8/16 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Unfortunely the current implementation of EXECUTE USING is not working this way. Uh ... what

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Cédric Villemain
2010/8/17 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: 2010/8/16 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Unfortunely the current implementation of EXECUTE USING

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Cédric Villemain
2010/8/17 Cédric Villemain cedric.villemain.deb...@gmail.com: 2010/8/17 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: 2010/8/16 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Here we are. A simple usecase. The reason you have an issue here is that the column is char(n) while the parameter is text. So the non-USING execute is equivalent to regression=# explain SELECT flag FROM foo where

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-17 Thread Cédric Villemain
2010/8/17 Tom Lane t...@sss.pgh.pa.us: =?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Here we are. A simple usecase. The reason you have an issue here is that the column is char(n) while the parameter is text.  So the non-USING execute is equivalent to

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-16 Thread Cédric Villemain
2010/8/5 Heikki Linnakangas heikki.linnakan...@enterprisedb.com: There's a little problem with EXECUTE USING when the parameters are of type unknown (going back to 8.4 where EXECUTE USING was introduced): do $$ BEGIN  EXECUTE 'SELECT to_date($1, $2)' USING '17-DEC-80', 'DD-MON-YY'; END;

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-16 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= cedric.villemain.deb...@gmail.com writes: Yes, and you point out another thing. EXECUTE is a way to bypass the named prepare statement, to be sure query is replanned each time. Unfortunely the current implementation of EXECUTE USING is not working this way.

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-16 Thread Heikki Linnakangas
On 16/08/10 03:35, Tom Lane wrote: Heikki Linnakangasheikki.linnakan...@enterprisedb.com writes: One approach is to handle the conversion from unknown to the right data type transparently in the backend. Attached patch adds a coerce-param-hook for fixed params that returns a CoerceViaIO node

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-15 Thread Tom Lane
Heikki Linnakangas heikki.linnakan...@enterprisedb.com writes: One approach is to handle the conversion from unknown to the right data type transparently in the backend. Attached patch adds a coerce-param-hook for fixed params that returns a CoerceViaIO node to convert the param to the

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-06 Thread Heikki Linnakangas
On 06/08/10 01:13, Tom Lane wrote: Andrew Dunstanand...@dunslane.net writes: On 08/05/2010 05:11 PM, Tom Lane wrote: This example doesn't seem terribly compelling. Why would you bother using USING with constants? In a more complex example you might use $1 in more than one place in the

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-06 Thread Heikki Linnakangas
On 06/08/10 01:13, Tom Lane wrote: Andrew Dunstanand...@dunslane.net writes: On 08/05/2010 05:11 PM, Tom Lane wrote: This example doesn't seem terribly compelling. Why would you bother using USING with constants? In a more complex example you might use $1 in more than one place in the

[HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-05 Thread Heikki Linnakangas
There's a little problem with EXECUTE USING when the parameters are of type unknown (going back to 8.4 where EXECUTE USING was introduced): do $$ BEGIN EXECUTE 'SELECT to_date($1, $2)' USING '17-DEC-80', 'DD-MON-YY'; END; $$; ERROR: failed to find conversion function from unknown to text

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-05 Thread Pavel Stehule
Hello 2010/8/5 Heikki Linnakangas heikki.linnakan...@enterprisedb.com: There's a little problem with EXECUTE USING when the parameters are of type unknown (going back to 8.4 where EXECUTE USING was introduced): do $$ BEGIN  EXECUTE 'SELECT to_date($1, $2)' USING '17-DEC-80', 'DD-MON-YY';

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-05 Thread Tom Lane
Heikki Linnakangas heikki.linnakan...@enterprisedb.com writes: There's a little problem with EXECUTE USING when the parameters are of type unknown (going back to 8.4 where EXECUTE USING was introduced): do $$ BEGIN EXECUTE 'SELECT to_date($1, $2)' USING '17-DEC-80', 'DD-MON-YY'; END;

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-05 Thread Andrew Dunstan
On 08/05/2010 05:11 PM, Tom Lane wrote: Heikki Linnakangasheikki.linnakan...@enterprisedb.com writes: There's a little problem with EXECUTE USING when the parameters are of type unknown (going back to 8.4 where EXECUTE USING was introduced): do $$ BEGIN EXECUTE 'SELECT to_date($1, $2)'

Re: [HACKERS] PL/pgSQL EXECUTE '..' USING with unknown

2010-08-05 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: On 08/05/2010 05:11 PM, Tom Lane wrote: This example doesn't seem terribly compelling. Why would you bother using USING with constants? In a more complex example you might use $1 in more than one place in the query. Well, that's better than no