On Wed, Mar 30, 2011 at 09:32:08PM -0400, Noah Misch wrote:
> ... ALTER TYPE mistakenly
> only touches the first table-of-type:
>
> create type t as (x int, y int);
> create table is_a of t;
> create table is_a2 of t;
> alter type t drop attribute y cascade, add attribute z int cascade;
> \d is_a
> Table "public.is_a"
> Column | Type | Modifiers
> --------+---------+-----------
> x | integer |
> z | integer |
> Typed table of type: t
> \d is_a2
> Table "public.is_a2"
> Column | Type | Modifiers
> --------+---------+-----------
> x | integer |
> y | integer |
> Typed table of type: t
>
> Might be a simple fix; looks like find_typed_table_dependencies() only grabs
> the
> first match.
This is a fairly independent one-liner, so here's that patch. I didn't
incorporate the test case, because it seems distinctly unlikely to recur.
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 4a97819..bd18db3 100644
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 4014,4020 **** find_typed_table_dependencies(Oid typeOid, const char
*typeName, DropBehavior be
scan = heap_beginscan(classRel, SnapshotNow, 1, key);
! if (HeapTupleIsValid(tuple = heap_getnext(scan, ForwardScanDirection)))
{
if (behavior == DROP_RESTRICT)
ereport(ERROR,
--- 4014,4020 ----
scan = heap_beginscan(classRel, SnapshotNow, 1, key);
! while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
if (behavior == DROP_RESTRICT)
ereport(ERROR,
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers