Re: Typed-tables patch broke pg_upgrade

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Typed-tables patch broke pg_upgrade
Date: 2011-02-09 23:43:33
Message-ID: 11842.1297295013@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I find that pg_upgrade fails in HEAD when asked to do a 9.1-to-9.1
upgrade of the regression database. It gets to this bit of the
restore script:

CREATE TABLE test_tbl2 OF public.test_type2;

-- For binary upgrade, recreate dropped column.
UPDATE pg_catalog.pg_attribute
SET attlen = -1, attalign = 'i', attbyval = false
WHERE attname = '........pg.dropped.2........'
AND attrelid = 'test_tbl2'::pg_catalog.regclass;
ALTER TABLE ONLY test_tbl2 DROP COLUMN "........pg.dropped.2........";

and fails with

ERROR: cannot drop column from typed table

which probably is because test_type2 has a dropped column.

Somebody has failed to think through something, because if this state of
affairs was allowed to be created during the regression tests, why
should we not be able to restore it?

(pg_upgrade's ENUM support is broken too, but at least that one is a
one-line fix.)

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-02-10 04:16:25
Message-ID: 201102100416.p1A4GQg28988@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> I find that pg_upgrade fails in HEAD when asked to do a 9.1-to-9.1
> upgrade of the regression database. It gets to this bit of the
> restore script:
>
> CREATE TABLE test_tbl2 OF public.test_type2;
>
> -- For binary upgrade, recreate dropped column.
> UPDATE pg_catalog.pg_attribute
> SET attlen = -1, attalign = 'i', attbyval = false
> WHERE attname = '........pg.dropped.2........'
> AND attrelid = 'test_tbl2'::pg_catalog.regclass;
> ALTER TABLE ONLY test_tbl2 DROP COLUMN "........pg.dropped.2........";
>
> and fails with
>
> ERROR: cannot drop column from typed table
>
> which probably is because test_type2 has a dropped column.
>
> Somebody has failed to think through something, because if this state of
> affairs was allowed to be created during the regression tests, why
> should we not be able to restore it?

I am not aware of this code changing in 9.1. Was this test in 9.0?
Does this problem happen for 9.0?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-02-10 04:31:38
Message-ID: 1297312298.25615.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2011-02-09 at 18:43 -0500, Tom Lane wrote:
> I find that pg_upgrade fails in HEAD when asked to do a 9.1-to-9.1
> upgrade of the regression database. It gets to this bit of the
> restore script:
>
> CREATE TABLE test_tbl2 OF public.test_type2;
>
> -- For binary upgrade, recreate dropped column.
> UPDATE pg_catalog.pg_attribute
> SET attlen = -1, attalign = 'i', attbyval = false
> WHERE attname = '........pg.dropped.2........'
> AND attrelid = 'test_tbl2'::pg_catalog.regclass;
> ALTER TABLE ONLY test_tbl2 DROP COLUMN "........pg.dropped.2........";
>
> and fails with
>
> ERROR: cannot drop column from typed table
>
> which probably is because test_type2 has a dropped column.

It should call

ALTER TYPE test_type2 DROP ATTRIBUTE xyz CASCADE;

instead. That will propagate to the table.

I'm not sure though, whether a composite type preserves the dropped
attribute for re-dropping in this case.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-02-10 04:32:06
Message-ID: 1297312326.25615.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2011-02-09 at 23:16 -0500, Bruce Momjian wrote:
> I am not aware of this code changing in 9.1. Was this test in 9.0?
> Does this problem happen for 9.0?

No, because you can't drop anything from a typed table in 9.0.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-03-11 13:28:15
Message-ID: 201103111328.p2BDSFd10499@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Is this still an open bug?

---------------------------------------------------------------------------

Tom Lane wrote:
> I find that pg_upgrade fails in HEAD when asked to do a 9.1-to-9.1
> upgrade of the regression database. It gets to this bit of the
> restore script:
>
> CREATE TABLE test_tbl2 OF public.test_type2;
>
> -- For binary upgrade, recreate dropped column.
> UPDATE pg_catalog.pg_attribute
> SET attlen = -1, attalign = 'i', attbyval = false
> WHERE attname = '........pg.dropped.2........'
> AND attrelid = 'test_tbl2'::pg_catalog.regclass;
> ALTER TABLE ONLY test_tbl2 DROP COLUMN "........pg.dropped.2........";
>
> and fails with
>
> ERROR: cannot drop column from typed table
>
> which probably is because test_type2 has a dropped column.
>
> Somebody has failed to think through something, because if this state of
> affairs was allowed to be created during the regression tests, why
> should we not be able to restore it?
>
> (pg_upgrade's ENUM support is broken too, but at least that one is a
> one-line fix.)
>
> regards, tom lane

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-03-27 02:19:20
Message-ID: AANLkTinBK2-58Q4v=PJJ1kh_xVJSonu2mOiMk74aDChS@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Mar 11, 2011 at 8:28 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Is this still an open bug?

Is anyone working on fixing this?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-03-30 16:50:12
Message-ID: 1301503812.31317.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tor, 2011-02-10 at 06:31 +0200, Peter Eisentraut wrote:
> > ERROR: cannot drop column from typed table
> >
> > which probably is because test_type2 has a dropped column.
>
> It should call
>
> ALTER TYPE test_type2 DROP ATTRIBUTE xyz CASCADE;
>
> instead. That will propagate to the table.

Here is a patch that addresses this problem.

It looks like Noah Misch might have found another problem in this area.
We'll have to investigate that.

Attachment Content-Type Size
type-table-pgupgrade.patch text/x-patch 3.0 KB

From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-03-31 01:32:08
Message-ID: 20110331013208.GB18119@tornado.gateway.2wire.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 30, 2011 at 07:50:12PM +0300, Peter Eisentraut wrote:
> On tor, 2011-02-10 at 06:31 +0200, Peter Eisentraut wrote:
> > > ERROR: cannot drop column from typed table
> > >
> > > which probably is because test_type2 has a dropped column.
> >
> > It should call
> >
> > ALTER TYPE test_type2 DROP ATTRIBUTE xyz CASCADE;
> >
> > instead. That will propagate to the table.
>
> Here is a patch that addresses this problem.

This only works when exactly one typed table uses each composite type having
dropped columns. With zero users, the placeholder column never gets dropped.
Actually, it happens to work for >1 user, but only because 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. Incidentally, this led me to notice that you can hang a typed
table off a table row type. ALTER TABLE never propagates to such typed tables,
allowing them to get out of sync:

create table t (x int, y int);
create table is_a of t;
create table is_a2 of t;
alter table t drop y, add z int;
\d is_a
Table "public.is_a"
Column | Type | Modifiers
--------+---------+-----------
x | integer |
y | integer |
Typed table of type: t

Perhaps we should disallow the use of table row types in CREATE TABLE ... OF?

> It looks like Noah Misch might have found another problem in this area.
> We'll have to investigate that.

Your bits in dumpCompositeType() are most of what's needed to fix that, I think.

Thanks,
nm


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-05 13:44:44
Message-ID: BANLkTikzBzb1BwQAeAsC87F0k6iJqZHK=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 30, 2011 at 9:32 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> On Wed, Mar 30, 2011 at 07:50:12PM +0300, Peter Eisentraut wrote:
>> On tor, 2011-02-10 at 06:31 +0200, Peter Eisentraut wrote:
>> > > ERROR:  cannot drop column from typed table
>> > >
>> > > which probably is because test_type2 has a dropped column.
>> >
>> > It should call
>> >
>> > ALTER TYPE test_type2 DROP ATTRIBUTE xyz CASCADE;
>> >
>> > instead.  That will propagate to the table.
>>
>> Here is a patch that addresses this problem.
>
> This only works when exactly one typed table uses each composite type having
> dropped columns.  With zero users, the placeholder column never gets dropped.
> Actually, it happens to work for >1 user, but only because 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.  Incidentally, this led me to notice that you can hang a typed
> table off a table row type.  ALTER TABLE never propagates to such typed tables,
> allowing them to get out of sync:
>
> create table t (x int, y int);
> create table is_a of t;
> create table is_a2 of t;
> alter table t drop y, add z int;
> \d is_a
>     Table "public.is_a"
>  Column |  Type   | Modifiers
> --------+---------+-----------
>  x      | integer |
>  y      | integer |
> Typed table of type: t
>
> Perhaps we should disallow the use of table row types in CREATE TABLE ... OF?
>
>> It looks like Noah Misch might have found another problem in this area.
>> We'll have to investigate that.
>
> Your bits in dumpCompositeType() are most of what's needed to fix that, I think.

Where are we on this?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-06 15:49:18
Message-ID: 20110406154918.GA17021@tornado.gateway.2wire.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Apr 05, 2011 at 09:44:44AM -0400, Robert Haas wrote:
> On Wed, Mar 30, 2011 at 9:32 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> > On Wed, Mar 30, 2011 at 07:50:12PM +0300, Peter Eisentraut wrote:
> >> Here is a patch that addresses this problem.
> >
> > This only works when exactly one typed table uses each composite type having
> > dropped columns. ?With zero users, the placeholder column never gets dropped.
> > Actually, it happens to work for >1 user, but only because 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. ?Incidentally, this led me to notice that you can hang a typed
> > table off a table row type. ?ALTER TABLE never propagates to such typed tables,
> > allowing them to get out of sync:
> >
> > create table t (x int, y int);
> > create table is_a of t;
> > create table is_a2 of t;
> > alter table t drop y, add z int;
> > \d is_a
> > ? ? Table "public.is_a"
> > ?Column | ?Type ? | Modifiers
> > --------+---------+-----------
> > ?x ? ? ?| integer |
> > ?y ? ? ?| integer |
> > Typed table of type: t
> >
> > Perhaps we should disallow the use of table row types in CREATE TABLE ... OF?
> >
> >> It looks like Noah Misch might have found another problem in this area.
> >> We'll have to investigate that.
> >
> > Your bits in dumpCompositeType() are most of what's needed to fix that, I think.
>
> Where are we on this?

Peter, were you planning to complete this? I can take a swing at it, if it
would be helpful.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-07 21:23:10
Message-ID: 1302211390.21369.32.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2011-04-06 at 11:49 -0400, Noah Misch wrote:
> Peter, were you planning to complete this? I can take a swing at it, if it
> would be helpful.

Help is always welcome.


From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-08 11:46:48
Message-ID: 20110408114648.GB27915@tornado.gateway.2wire.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

Attachment Content-Type Size
tt0v1-alter-multiple.patch text/plain 715 bytes

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-08 19:43:39
Message-ID: BANLkTim3qh23fS=nXn9BrUn7OEVvbhwuiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 30, 2011 at 9:32 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> Incidentally, this led me to notice that you can hang a typed
> table off a table row type.  ALTER TABLE never propagates to such typed tables,
> allowing them to get out of sync:
>
> create table t (x int, y int);
> create table is_a of t;
> create table is_a2 of t;
> alter table t drop y, add z int;
> \d is_a
>     Table "public.is_a"
>  Column |  Type   | Modifiers
> --------+---------+-----------
>  x      | integer |
>  y      | integer |
> Typed table of type: t
>
> Perhaps we should disallow the use of table row types in CREATE TABLE ... OF?

Yes, I think we need to do that.

>> It looks like Noah Misch might have found another problem in this area.
>> We'll have to investigate that.
>
> Your bits in dumpCompositeType() are most of what's needed to fix that, I think.

Most?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-08 20:05:49
Message-ID: BANLkTi=y8RggRLcfqOj7cGuo94O4V4ekFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 30, 2011 at 12:50 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On tor, 2011-02-10 at 06:31 +0200, Peter Eisentraut wrote:
>> > ERROR:  cannot drop column from typed table
>> >
>> > which probably is because test_type2 has a dropped column.
>>
>> It should call
>>
>> ALTER TYPE test_type2 DROP ATTRIBUTE xyz CASCADE;
>>
>> instead.  That will propagate to the table.
>
> Here is a patch that addresses this problem.
>
> It looks like Noah Misch might have found another problem in this area.
> We'll have to investigate that.

There's something wrong with this patch - it never arranges to
actually drop the phony column. Consider:

create type foo as (a int, b int);
alter table foo drop attribute b;
create table x (a int, b int);
alter table x drop column b;

Then pg_dump --binary-upgrade emits, in relevant part, the following for x:

CREATE TABLE x (
a integer,
"........pg.dropped.2........" INTEGER /* dummy */
);

-- For binary upgrade, recreate dropped column.
UPDATE pg_catalog.pg_attribute
SET attlen = 4, attalign = 'i', attbyval = false
WHERE attname = '........pg.dropped.2........'
AND attrelid IN ('x'::pg_catalog.regclass);
ALTER TABLE ONLY x DROP COLUMN "........pg.dropped.2........";

But for t we get only:

CREATE TYPE foo AS (
a integer,
"........pg.dropped.2........" INTEGER /* dummy */
);

...which is no good.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Noah Misch <noah(at)leadboat(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-08 20:32:54
Message-ID: 20110408203254.GB18152@tornado.gateway.2wire.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 08, 2011 at 03:43:39PM -0400, Robert Haas wrote:
> On Wed, Mar 30, 2011 at 9:32 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> > Incidentally, this led me to notice that you can hang a typed
> > table off a table row type. ?ALTER TABLE never propagates to such typed tables,
> > allowing them to get out of sync:
> >
> > create table t (x int, y int);
> > create table is_a of t;
> > create table is_a2 of t;
> > alter table t drop y, add z int;
> > \d is_a
> > ? ? Table "public.is_a"
> > ?Column | ?Type ? | Modifiers
> > --------+---------+-----------
> > ?x ? ? ?| integer |
> > ?y ? ? ?| integer |
> > Typed table of type: t
> >
> > Perhaps we should disallow the use of table row types in CREATE TABLE ... OF?
>
> Yes, I think we need to do that.

Having thought about it some more, that would be unfortunate. We rarely
distinguish between table row types and CREATE TYPE AS types. Actually, I'm not
aware of any place we distinguish other than in ALTER TABLE/ALTER TYPE, to
instruct you to use the other.

But depending on how hard it is to fix, that might be a good stopgap.

> >> It looks like Noah Misch might have found another problem in this area.
> >> We'll have to investigate that.
> >
> > Your bits in dumpCompositeType() are most of what's needed to fix that, I think.
>
> Most?

I think it will just fall out of the completed fix for the original reported
problem. Will keep you posted.

nm


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-27 18:30:41
Message-ID: 1303929041.2950.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here is the patch to fix that, as discussed.

Attachment Content-Type Size
typed-table-pgupgrade.patch text/x-patch 2.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-27 18:42:39
Message-ID: 8589.1303929759@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Here is the patch to fix that, as discussed.

Looks sane --- I assume you tested it against the originally
complained-of scenario?
http://archives.postgresql.org/message-id/201103111328.p2BDSFd10499@momjian.us

If so, please apply soon --- we need to wrap beta1 this evening.

regards, tom lane


From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed-tables patch broke pg_upgrade
Date: 2011-04-27 19:18:39
Message-ID: 20110427191839.GA7341@tornado.gateway.2wire.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Apr 27, 2011 at 09:30:41PM +0300, Peter Eisentraut wrote:
> Here is the patch to fix that, as discussed.

Looks correct. Thanks.