Skip site navigation (1) Skip section navigation (2)

Re: [7.4.2] Still "variable not found in subplan target lists"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: "veramente(at)libero(dot)it" <veramente(at)libero(dot)it>,pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [7.4.2] Still "variable not found in subplan target lists"
Date: 2004-04-16 14:09:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Andreas Pflug <pgadmin(at)pse-consulting(dot)de> writes:
> Tom Lane wrote:
>> This is an unsupported operation.  You should perhaps complain to the
>> pgadmin guys that they are not correctly updating the system catalogs.

> UPDATE pg_attribute
>    SET atttypmod=2504
>  WHERE attrelid=25574::oid AND attnum=2;

> This is what pgAdmin3 will generate to change a varchar to 2500 bytes. 
> Please let me know what's wrong with that.

It doesn't fix views that contain references to the column.  The new
typmod would need to be propagated into the view's rule parsetree, and
perhaps to the type of the view's result column if the view directly
exposes the changed column (whereupon you need to recursively look at
the views that depend on this one, etc).

What you could probably do is find the referencing views via pg_depend.
For each one, try to do CREATE OR REPLACE VIEW using the view definition
string from pg_get_viewdef.  If it succeeds you're done (the variable
must not be propagated to any output column).  If it fails, adjust the
indicated output column's typmod.  Lather, rinse, repeat in case there
is more than one dependent output column.  Recurse once you've
successfully altered the view.

It'd probably also be a smart idea to error out if pg_depend shows any
dependencies on the column from objects that you don't know what to do
with (aren't views).

I recall there was some discussion of this stuff on pgsql-hackers the
last time it was proposed to support "ALTER COLUMN type".  We may have
thought of some additional considerations besides views.  I'd suggest
trawling the list archives to see...

			regards, tom lane

In response to


pgsql-bugs by date

Next:From: PostgreSQL Bugs ListDate: 2004-04-18 09:52:04
Subject: BUG #1134: ALTER USER ... RENAME breaks md5 passwords
Previous:From: Andreas PflugDate: 2004-04-16 09:08:28
Subject: Re: [7.4.2] Still "variable not found in subplan target lists"

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group