Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?

From: ash <ash(at)commandprompt(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?
Date: 2014-05-27 07:00:48
Message-ID: 874n0bk8nz.fsf@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


David Fetter <david(at)fetter(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matteo Beccati 2014-05-27 07:34:14 Re: [PATCH] Replacement for OSSP-UUID for Linux and BSD
Previous Message Simon Riggs 2014-05-27 06:57:36 Re: Spreading full-page writes