Some more function-default issues - Mailing list pgsql-hackers

From Tom Lane
Subject Some more function-default issues
Date
Msg-id 7958.1231248764@sss.pgh.pa.us
Whole thread Raw
Responses Re: Some more function-default issues  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-hackers
Some further reflection about Rushabh Lathia's bug report of yesterday
led me to the realization that there's a pretty big hole in the function
defaults patch.  Since we add default values during planning, it doesn't
work for any expression that's not fed through the planner.  For
instance, ALTER COLUMN USING:

regression=# create function add(int, int = 42) returns int
regression-# as 'select $1+$2' language sql;
CREATE FUNCTION
regression=# create table foo(f1 int);
CREATE TABLE
regression=# insert into foo values (1);
INSERT 0 1
regression=# alter table foo alter column f1 type bigint using add(f1)::bigint;
ERROR:  no value found for parameter 2
CONTEXT:  SQL function "add" statement 1

The minimum-code-change solution would be to run around and try to make
sure every such expression gets passed through eval_const_expressions()
before we try to execute it.  This is probably doable (looking for calls
to fix_opfuncids would be a good guide) but it seems like the potential
for errors of omission is large, particularly in third-party add-ons.

I wonder if anyone has an idea for a better way to attack this?
        regards, tom lane


pgsql-hackers by date:

Previous
From: KaiGai Kohei
Date:
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches (r1389)
Next
From: "Gurjeet Singh"
Date:
Subject: Re: [GENERAL] ERROR: failed to find conversion function from "unknown" to text