Re: multiple function execute using (func()).*

From: Jeff <threshar(at)torgo(dot)978(dot)org>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: multiple function execute using (func()).*
Date: 2008-12-09 13:55:19
Message-ID: 3914E2A9-CA96-4447-8DB1-D91B0BB9BB2D@torgo.978.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Dec 8, 2008, at 5:15 PM, Merlin Moncure wrote:

> Hello,
>
> I've been bit by this about a million times:
>
> select (func()).* executes the function once per each field in the
> returned tuple. See the example below:
>

I ran into this exact problem a week or two ago.

I didn't dig too far into it but I figured (func()).* was being
expanded by the parser into func().a, func().b and friends. marking it
stable didn't help.

It can be quite surprising, especially if func() is expensive (as was
my case) or has side effects.

--
Jeff Trout <jeff(at)jefftrout(dot)com>
http://www.stuarthamm.net/
http://www.dellsmartexitin.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-12-09 13:59:51 Re: contrib/pg_stat_statements 1202
Previous Message Euler Taveira de Oliveira 2008-12-09 13:48:33 Re: operator does not exist: smallint <> smallint[]