Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Michael Glaesemann
On May 21, 2011, at 13:44, Pavel Stehule wrote: > 2011/5/21 Michael Glaesemann : >> >> It looks like it's just column names stomping on variable names, which is a >> known issue. This is why a lot of developers (including myself) have >> conventions of prefixing parameters and variable names (

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Pavel Stehule
2011/5/21 Michael Glaesemann : > > On May 21, 2011, at 9:41, Dan S wrote: > >> Hi ! >> >> I'm running "PostgreSQL 9.0.2, compiled by Visual C++ build 1500, 32-bit" >> >> I have found an odd behaviour in pl/pgsql when using 'return query execute' >> The function produce the dynamic query 'select * f

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Dan S
Yes throwing an error would probably be good to catch these kind of mistakes which silently gives you the wrong answer otherwise. Best Regards Dan S 2011/5/21 Tom Lane > Dan S writes: > > And yes I do know that I can fix the problem by renaming the output > column > > to something else than i

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Michael Glaesemann
On May 21, 2011, at 9:41, Dan S wrote: > Hi ! > > I'm running "PostgreSQL 9.0.2, compiled by Visual C++ build 1500, 32-bit" > > I have found an odd behaviour in pl/pgsql when using 'return query execute' > The function produce the dynamic query 'select * from tbl1 where col1 < 4' > and executes

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Tom Lane
Dan S writes: > And yes I do know that I can fix the problem by renaming the output column > to something else than i , I'm just curious about the behaviour and if it > should work like this and why. > CREATE OR REPLACE FUNCTION dynamic_query(i int) RETURNS TABLE (i int) as $$ This should probab

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Björn Häuser
Hello, seems like you cannot name your input parameters the same as your tableoutputcolumns? Rename one of them and it works. Something like: RETURNS TABLE (j int) Regards Am 21.05.11 16:25, schrieb Pavel Stehule: Hello yes, this behave is strange, and should be fixed Regards Pavel Steh

Re: [GENERAL] counterintuitive behaviour in pl/pgsql

2011-05-21 Thread Pavel Stehule
Hello yes, this behave is strange, and should be fixed Regards Pavel Stehule 2011/5/21 Dan S : > Hi ! > > I'm running "PostgreSQL 9.0.2, compiled by Visual C++ build 1500, 32-bit" > > I have found an odd behaviour in pl/pgsql when using 'return query execute' > The function produce the dynamic