Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE? - Mailing list pgsql-hackers

From ash
Subject Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?
Date
Msg-id 874n0bk8nz.fsf@commandprompt.com
Whole thread Raw
In response to Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?  (David Fetter <david@fetter.org>)
List pgsql-hackers
David Fetter <david@fetter.org> writes:
>> >
>> > Also worth considering: functions which take any part of the view
>> > as a parameter.
>> 
>> Sorry, I don't get it: do you suggest we should re-create dependent
>> functions too?
>
> I'd throw an error in cases where such functions had an obvious and
> deterministic dependency on the views, ideally having gone through all
> such functions first and enumerated them in the error message.

Then it would also make sense to start with checking function dependency
on the tables themselves, not only the joining views:

psql=> CREATE TABLE t(id INT);
CREATE TABLE
psql=> CREATE FUNCTION func1() RETURNS SETOF INT AS $$ SELECT id FROM t; $$ LANGUAGE SQL;
CREATE FUNCTION
psql=> ALTER TABLE t ALTER COLUMN id TYPE BIGINT;
ALTER TABLE
-- Would complain on func1 right away

psql=> SELECT func1();
ERROR:  return type mismatch in function declared to return integer
DETAIL:  Actual return type is bigint.
CONTEXT:  SQL function "func1" during startup

psql=> CREATE FUNCTION func2() RETURNS SETOF INT AS $$ SELECT id FROM t; $$ LANGUAGE SQL;
ERROR:  return type mismatch in function declared to return integer
DETAIL:  Actual return type is bigint.
CONTEXT:  SQL function "func2"

--
Alex



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Spreading full-page writes
Next
From: Matteo Beccati
Date:
Subject: Re: [PATCH] Replacement for OSSP-UUID for Linux and BSD