Re: function expression in FROM may not refer to other relations
От | Stephan Szabo |
---|---|
Тема | Re: function expression in FROM may not refer to other relations |
Дата | |
Msg-id | 20040812073151.G56533@megazone.bigpanda.com обсуждение исходный текст |
Ответ на | Re: function expression in FROM may not refer to other relations of same query level ("Philippe Lang" <philippe.lang@attiksystem.ch>) |
Список | pgsql-sql |
On Thu, 12 Aug 2004, Philippe Lang wrote: > > > The problem now is that get_lines is being called twice per line. > > > > Is get_lines() defined as IMMUTABLE? Should it be? > > I have tried defining get_lines as "IMMUTABLE", or "WITH (iscachable)", > but it keeps on getting called twice per line in the following query... > > select > id, > usr, > code, > (get_lines(code)).line1, > (get_lines(code)).line2 > from tbl; > > I wish there was a way to run the query like this: > > select > id, > usr, > code, > CAST(get_lines(code) as lines) > from tbl; Note thatselect id, usr, code, get_lines(code) from tbl; should work in 8.0beta although you get the composite type as the last column, not two columns. sszabo=# select id, usr, code, get_lines(code) from tbl;id | usr | code | get_lines ----+-------+------+----------- 1 | one | 1 | (A,B) 2 | two | 2 | (Z,Z) 3 | three | 1 | (A,B) (3 rows) You can get individual columns with a bit of work and a subselect in from but you need to trick the system to not pull up the subselect to not get the function called twice per row.
В списке pgsql-sql по дате отправления: