Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Merlin Moncure
On Tue, May 31, 2011 at 5:01 PM, Tom Lane wrote: > Merlin Moncure writes: >> I've never taken the time to really get my head around 'lateral' >> enough to say for sure if it provides clean workarounds for all the >> cases that get people into hot water.  The case that used to get me a >> lot is (

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Tom Lane
Merlin Moncure writes: > I've never taken the time to really get my head around 'lateral' > enough to say for sure if it provides clean workarounds for all the > cases that get people into hot water. The case that used to get me a > lot is (the unfortunately generally under utilized) custom aggre

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Merlin Moncure
On Tue, May 31, 2011 at 3:28 PM, Tom Lane wrote: > Merlin Moncure writes: >> There have been multiple complaints about this in the archives.  In >> the old days, you would have to rewrite your query to use the 'select >> * from func()' form (which isn't always so easy) or use a subquery and >> th

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Tom Lane
Merlin Moncure writes: > There have been multiple complaints about this in the archives. In > the old days, you would have to rewrite your query to use the 'select > * from func()' form (which isn't always so easy) or use a subquery and > the 'offset 0' hack. Running in to this problem has actua

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Merlin Moncure
On Tue, May 31, 2011 at 11:57 AM, David Johnston wrote: > See my thoughts below.  Other user's opinions (or a pointer to where this > topic has been previously discussed) are greatly welcomed. > Thank you for the technical detail on how  ().* gets expanded by the engine. > I still believe it would

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread David Johnston
Cc: Tom Lane; pgsql-general@postgresql.org > Subject: Re: [GENERAL] Function Column Expansion Causes Inserts To Fail > > The basic issue is that: > select (func()).*, if the return type has fields, 'a', 'b', gets expanded to: > > select (func()).a, (func()).b;

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread Merlin Moncure
On Tue, May 31, 2011 at 9:24 AM, David Johnston wrote: > From syntax works fine for literals but how would you then get table.column > values into the function call - where you want to evaluate multiple rows > from the source table?  In order to feed rows to a function you need the > function in t

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-31 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Tom Lane > Sent: Monday, May 30, 2011 11:10 PM > To: David Johnston > Cc: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Function Co

Re: [GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-30 Thread Tom Lane
"David Johnston" writes: > SELECT ( createpkrecord('1')).*; > [ results in function being called more than once ] Yeah. Don't do that. Better style is SELECT * FROM createpkrecord('1'); regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@pos

[GENERAL] Function Column Expansion Causes Inserts To Fail

2011-05-30 Thread David Johnston
PostgreSQL 9.0.4 The following script fails even though the "pkonlytest" table is empty since we just created it. >> BEGIN SCRIPT CREATE TABLE pkonlytest ( pkid text PRIMARY KEY ); CREATE OR REPLACE FUNCTION createpkrecord(INOUT pkvalue text, OUT col