Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Vincenzo Romano
2010/1/15 Vincenzo Romano : > 2010/1/15 Pavel Stehule : >> look on this page - maybe it could be useful for you >> http://wiki.postgresql.org/wiki/Sprintf > > This one could save my day! > Thanks Pavel. EXECUTE PRINTF( ); It's great. It's working. It's a must-have-as-builtin! -- Vincenzo

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Pavel Stehule
2010/1/15 Pavel Stehule : > 2010/1/15 Vincenzo Romano : >> 2010/1/15 Pavel Stehule : 3. Then I need to add the TABLE-level CHECK condition in order to exploit the "constraint_exclusion = on":            execute $l2$              alter table $l2$||ct||$l2$              

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Pavel Stehule
2010/1/15 Vincenzo Romano : > 2010/1/15 Pavel Stehule : >>> >>> 3. Then I need to add the TABLE-level CHECK condition in order to >>> exploit the "constraint_exclusion = on": >>>            execute $l2$ >>>              alter table $l2$||ct||$l2$ >>>                add check(  $l0$||co||$l0$ ) >>>

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Vincenzo Romano
2010/1/15 Pavel Stehule : > look on this page - maybe it could be useful for you > http://wiki.postgresql.org/wiki/Sprintf This one could save my day! Thanks Pavel. -- Vincenzo Romano NotOrAnd Information Technologies NON QVIETIS MARIBVS NAVTA PERITVS -- Sent via pgsql-general mailing list (pg

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Vincenzo Romano
2010/1/15 Pavel Stehule : >> >> 3. Then I need to add the TABLE-level CHECK condition in order to >> exploit the "constraint_exclusion = on": >>            execute $l2$ >>              alter table $l2$||ct||$l2$ >>                add check(  $l0$||co||$l0$ ) >>            $l2$ using $l0$||va||$l0$;

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-15 Thread Pavel Stehule
> > 3. Then I need to add the TABLE-level CHECK condition in order to > exploit the "constraint_exclusion = on": >            execute $l2$ >              alter table $l2$||ct||$l2$ >                add check(  $l0$||co||$l0$ ) >            $l2$ using $l0$||va||$l0$; > I am sorry, I am out. Your co

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Vincenzo Romano
2010/1/14 Pavel Stehule : > 2010/1/14 Vincenzo Romano : >> 2010/1/14 Pavel Stehule : >>> 2010/1/14 Vincenzo Romano : 2010/1/14 Adrian Klaver : > On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: >> ... CREATE OR REPLACE FUNCTION f() RETURNS VOID LANGUAGE plpgsq

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Pavel Stehule
2010/1/14 Vincenzo Romano : > 2010/1/14 Pavel Stehule : >> 2010/1/14 Vincenzo Romano : >>> 2010/1/14 Adrian Klaver : On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: > ... >>> CREATE OR REPLACE FUNCTION f() >>> RETURNS VOID >>> LANGUAGE plpgsql >>> AS $function$ >>> DECLARE >>>

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Vincenzo Romano
2010/1/14 Vincenzo Romano : > 2010/1/14 Pavel Stehule : >> 2010/1/14 Vincenzo Romano : >>> 2010/1/14 Adrian Klaver : On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: > ... >>> CREATE OR REPLACE FUNCTION f() >>> RETURNS VOID >>> LANGUAGE plpgsql >>> AS $function$ >>> DECLARE >>>

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Vincenzo Romano
2010/1/14 Pavel Stehule : > 2010/1/14 Vincenzo Romano : >> 2010/1/14 Adrian Klaver : >>> On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: ... >> CREATE OR REPLACE FUNCTION f() >> RETURNS VOID >> LANGUAGE plpgsql >> AS $function$ >> DECLARE >>  cmd TEXT; >> BEGIN >>  EXECUTE ' >>    S

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Pavel Stehule
2010/1/14 Vincenzo Romano : > 2010/1/14 Adrian Klaver : >> On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: >> >>> > >>> > Scott, thanks for that I must have read through that section several >>> > times at least with out picking up on it. >>> > >>> > -- >>> > Adrian Klaver >>> > adr

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Vincenzo Romano
2010/1/14 Adrian Klaver : > On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: > >> > >> > Scott, thanks for that I must have read through that section several >> > times at least with out picking up on it. >> > >> > -- >> > Adrian Klaver >> > adrian.kla...@gmail.com >> >> Really? >> >

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Adrian Klaver
On Wednesday 13 January 2010 10:19:57 pm Vincenzo Romano wrote: > > > > Scott, thanks for that I must have read through that section several > > times at least with out picking up on it. > > > > -- > > Adrian Klaver > > adrian.kla...@gmail.com > > Really? > > That section is not in any page of the

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Pavel Stehule
2010/1/14 Vincenzo Romano : > The documentation says (also in v8.5) "These symbols refer to values > supplied in the USING clause". > "values"and not "variable name or reference". This leads to the useful > feature mentioned a line later in the same page. > Once you have a value replaced you can av

R: Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-14 Thread Vincenzo Romano
The documentation says (also in v8.5) "These symbols refer to values supplied in the USING clause". "values"and not "variable name or reference". This leads to the useful feature mentioned a line later in the same page. Once you have a value replaced you can avoid the restrictions you now mention o

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Tom Lane
Scott Mead writes: >Well it is in 8.5 Devel, so it could have been added immediately after > your thread started yesterday, I'm honestly not sure. The particular paragraph mentioned was committed here http://archives.postgresql.org/pgsql-committers/2009-11/msg00094.php but as you note it was

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Scott Mead
On Thu, Jan 14, 2010 at 7:19 AM, Vincenzo Romano < vincenzo.rom...@notorand.it> wrote: > 2010/1/14 Adrian Klaver : > > On Wednesday 13 January 2010 2:17:51 pm Scott Mead wrote: > >> On Wed, Jan 13, 2010 at 11:00 PM, Vincenzo Romano < > >> > >> vincenzo.rom...@notorand.it> wrote: > >> > It is not t

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
2010/1/14 Adrian Klaver : > On Wednesday 13 January 2010 2:17:51 pm Scott Mead wrote: >> On Wed, Jan 13, 2010 at 11:00 PM, Vincenzo Romano < >> >> vincenzo.rom...@notorand.it> wrote: >> > It is not the check or the select. >> > It is the way the substitution has been implemented. It looks like the

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Adrian Klaver
On Wednesday 13 January 2010 2:17:51 pm Scott Mead wrote: > On Wed, Jan 13, 2010 at 11:00 PM, Vincenzo Romano < > > vincenzo.rom...@notorand.it> wrote: > > It is not the check or the select. > > It is the way the substitution has been implemented. It looks like the > > code replaces the variable na

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Scott Mead
On Wed, Jan 13, 2010 at 11:00 PM, Vincenzo Romano < vincenzo.rom...@notorand.it> wrote: > It is not the check or the select. > It is the way the substitution has been implemented. It looks like the code > replaces the variable name and not the value. > Which is different from what is written at pa

R: Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
It is not the check or the select. It is the way the substitution has been implemented. It looks like the code replaces the variable name and not the value. Which is different from what is written at page 800. I only hope they won't change the manual to match the feature/bug (warning: new joke) Il

Re: R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Adrian Klaver
On 01/13/2010 01:39 PM, Vincenzo Romano wrote: My issue involves the USING predicates, though. WARNING:Old joke Doctor: What is wrong? Patient: My elbow hurts when I do this, what should I do? Doctor: Quit doing that. USING is not working the way you want, mainly for the reason you found, t

R: Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
My issue involves the USING predicates, though. Il giorno 13 gen, 2010 10:26 p., "Adrian Klaver" ha scritto: On 01/13/2010 09:37 AM, Vincenzo Romano wrote: > > 2010/1/13 Vincenzo Romano

Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Adrian Klaver
On 01/13/2010 09:37 AM, Vincenzo Romano wrote: 2010/1/13 Vincenzo Romano: 2010/1/13 Vincenzo Romano: 2010/1/13 Adrian Klaver: On Tuesday 12 January 2010 9:38:06 pm Vincenzo Romano wrote: The static binding worked fine in the second EXECUTE USING statement but not in the first one. I still thi

Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
2010/1/13 Vincenzo Romano : > 2010/1/13 Vincenzo Romano : >> 2010/1/13 Adrian Klaver : >>> On Tuesday 12 January 2010 9:38:06 pm Vincenzo Romano wrote: The static binding worked fine in the second EXECUTE USING statement but not in the first one. I still think that it's weird more th

Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
2010/1/13 Vincenzo Romano : > 2010/1/13 Adrian Klaver : >> On Tuesday 12 January 2010 9:38:06 pm Vincenzo Romano wrote: >>> The static binding worked fine in the second EXECUTE USING statement but >>> not in the first one. >>> I still think that it's weird more than wishful. >>> I can work it aroun

Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
2010/1/13 Adrian Klaver : > On Tuesday 12 January 2010 9:38:06 pm Vincenzo Romano wrote: >> The static binding worked fine in the second EXECUTE USING statement but >> not in the first one. >> I still think that it's weird more than wishful. >> I can work it around, though. >> >> Il giorno 12 gen,

Re: R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Adrian Klaver
On Tuesday 12 January 2010 9:38:06 pm Vincenzo Romano wrote: > The static binding worked fine in the second EXECUTE USING statement but > not in the first one. > I still think that it's weird more than wishful. > I can work it around, though. > > Il giorno 12 gen, 2010 4:13 p., "Tom Lane" ha scrit

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-13 Thread Vincenzo Romano
2010/1/13 Vincenzo Romano : > The static binding worked fine in the second EXECUTE USING statement but not > in the first one. > I still think that it's weird more than wishful. > I can work it around, though. > > Il giorno 12 gen, 2010 4:13 p., "Tom Lane" ha scritto: > > Vincenzo Romano writes:

R: Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Vincenzo Romano
The static binding worked fine in the second EXECUTE USING statement but not in the first one. I still think that it's weird more than wishful. I can work it around, though. Il giorno 12 gen, 2010 4:13 p., "Tom Lane" ha scritto: Vincenzo Romano writes: > I don't think so. Those variables shoul

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Tom Lane
Vincenzo Romano writes: > I don't think so. Those variables should be evaluated with the USING > *before* the actual execution. > Thus my statements only contain columns and constants. Unfortunately, that's just wishful thinking, not how EXECUTE USING actually works. rega

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Vincenzo Romano
2010/1/12 Adrian Klaver : > On Tuesday 12 January 2010 6:24:13 am Vincenzo Romano wrote: >> 2010/1/12 Tom Lane : >> > Vincenzo Romano writes: >> >> In a PL/PgSQL function I have the following: >> >> >> >>             execute $l2$ >> >>               alter table $l2$||ct||$l2$ add check( >> >>

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Adrian Klaver
On Tuesday 12 January 2010 6:24:13 am Vincenzo Romano wrote: > 2010/1/12 Tom Lane : > > Vincenzo Romano writes: > >> In a PL/PgSQL function I have the following: > >> > >>             execute $l2$ > >>               alter table $l2$||ct||$l2$ add check( > >> data>=$1::timestamp and data<$2::t

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Vincenzo Romano
2010/1/12 Tom Lane : > Vincenzo Romano writes: >> In a PL/PgSQL function I have the following: >> >>             execute $l2$ >>               alter table $l2$||ct||$l2$ add check( >> data>=$1::timestamp and data<$2::timestamp and maga=$3 ) >>             $l2$ using rec.d0,rec.d1,rec.maga; >>

Re: [GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Tom Lane
Vincenzo Romano writes: > In a PL/PgSQL function I have the following: > > execute $l2$ > alter table $l2$||ct||$l2$ add check( > data>=$1::timestamp and data<$2::timestamp and maga=$3 ) > $l2$ using rec.d0,rec.d1,rec.maga; > > which yields to this e

[GENERAL] Weird EXECUTE ... USING behaviour

2010-01-12 Thread Vincenzo Romano
In a PL/PgSQL function I have the following: execute $l2$ alter table $l2$||ct||$l2$ add check( data>=$1::timestamp and data<$2::timestamp and maga=$3 ) $l2$ using rec.d0,rec.d1,rec.maga; which yields to this error messsge: ERROR: there is no p