Re: plpgsql: penalty due to double evaluation of parameters - Mailing list pgsql-hackers

From Tom Lane
Subject Re: plpgsql: penalty due to double evaluation of parameters
Date
Msg-id 4539.1211756820@sss.pgh.pa.us
Whole thread Raw
In response to Re: plpgsql: penalty due to double evaluation of parameters  ("Heikki Linnakangas" <heikki@enterprisedb.com>)
List pgsql-hackers
"Heikki Linnakangas" <heikki@enterprisedb.com> writes:
> I don't buy the performance argument unless I see some test results 
> demonstrating it; exec_prepare_plan is only called on the first 
> invocation of a statement. What kind of side-effects could 
> exec_eval_datum call have?

In principle, if you subscript TG_ARGV[] with an expression that has
visible side-effects, you could have unexpected behavior here.  I think
though that the right fix is to get rid of the special treatment of
TG_ARGV[] and make it a ordinary variable with type text[], instead
of being its very own class of datum.  The current implementation has
a lot of other misbehaviors for TG_ARGV[], like not being able to apply
array operations to it.

I agree that worrying about the performance is pointless, considering
the cost of the SPI_prepare_cursor() that we're about to do in the one
place where there could be a use for a get-the-type-only call.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: \df displaying volatility
Next
From: Simon Riggs
Date:
Subject: Read Uncommitted