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

2010-08-17 Thread Cédric Villemain
2010/8/17 Tom Lane : > =?ISO-8859-1?Q?C=E9dric_Villemain?= > 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 Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= 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 uid = 'cfcd208495d565ef66e7dff9f98

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

2010-08-17 Thread Cédric Villemain
2010/8/17 Cédric Villemain : > 2010/8/17 Tom Lane : >> =?ISO-8859-1?Q?C=E9dric_Villemain?= >> writes: >>> 2010/8/16 Tom Lane : =?ISO-8859-1?Q?C=E9dric_Villemain?= 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 : > =?ISO-8859-1?Q?C=E9dric_Villemain?= > writes: >> 2010/8/16 Tom Lane : >>> =?ISO-8859-1?Q?C=E9dric_Villemain?= >>> writes: Unfortunely the current implementation of EXECUTE USING is not working this way. >>> >>> Uh ... what do you base that statement on? > >> Abo

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

2010-08-17 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= writes: > 2010/8/16 Tom Lane : >> =?ISO-8859-1?Q?C=E9dric_Villemain?= >> writes: >>> Unfortunely the current implementation of EXECUTE USING is not working >>> this way. >> >> Uh ... what do you base that statement on? > About the planning behavior ? > With

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

2010-08-17 Thread Cédric Villemain
2010/8/16 Tom Lane : > =?ISO-8859-1?Q?C=E9dric_Villemain?= > 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 Linnakangas 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 right typ

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

2010-08-16 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= 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. Uh ... what do you base that

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

2010-08-16 Thread Cédric Villemain
2010/8/5 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 c

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

2010-08-15 Thread Tom Lane
Heikki Linnakangas 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 right type at runtime. That's quite

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

2010-08-06 Thread Heikki Linnakangas
On 06/08/10 01:13, Tom Lane wrote: Andrew Dunstan 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 b

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

2010-08-06 Thread Heikki Linnakangas
On 06/08/10 01:13, Tom Lane wrote: Andrew Dunstan 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 b

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

2010-08-05 Thread Tom Lane
Andrew Dunstan 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 justification,

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 Linnakangas 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 Tom Lane
Heikki Linnakangas 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; > $$; > ERROR: failed to find c

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

2010-08-05 Thread Pavel Stehule
Hello 2010/8/5 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

[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 CONT