pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #7583: Problem using INHERITS and LIKE
3+ messages / 3 participants
[nested] [flat]
* BUG #7583: Problem using INHERITS and LIKE
@ 2012-10-03 20:36 bryan.love@iovation.com
0 siblings, 1 reply; 3+ messages in thread
From: bryan.love@iovation.com @ 2012-10-03 20:36 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 7583
Logged by: Bryan Love
Email address: bryan.love@iovation.com
PostgreSQL version: 9.2.1
Operating system: Centos 6
Description:
After creating a table using LIKE and INHERITS, if you drop a column from
the parent table that existed prior to creation of the child table, the
column will not be dropped from the child table.
Test Case:
=# create table foo(col1 int, col2 int);
=# create table bar (like foo) inherits (foo);
NOTICE: merging column "col1" with inherited definition
NOTICE: merging column "col2" with inherited definition
CREATE TABLE
=# alter table foo drop col1;
ALTER TABLE
=# \d bar
Table "public.bar"
Column | Type | Modifiers
--------+---------+-----------
col1 | integer |
col2 | integer |
Inherits: foo
--- copy/paste block commands ----
drop table bar;
drop table foo;
create table foo(col1 int, col2 int);
create table bar (like foo) inherits (foo);
alter table foo drop col1;
\d bar
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #7583: Problem using INHERITS and LIKE
@ 2012-10-04 14:38 Tom Lane <tgl@sss.pgh.pa.us>
parent: bryan.love@iovation.com
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2012-10-04 14:38 UTC (permalink / raw)
To: bryan.love@iovation.com; +Cc: pgsql-bugs
bryan.love@iovation.com writes:
> After creating a table using LIKE and INHERITS, if you drop a column from
> the parent table that existed prior to creation of the child table, the
> column will not be dropped from the child table.
This is not a bug. LIKE says the column isn't inherited, so it exists
in the child independently of whether it exists in the parent.
Or, if you want to add it up: the child starts out with one local
definition of the column (from LIKE) and one inherited (from INHERITS).
Dropping the column from the parent removes the latter, but you still
have the former, so the column stays.
> =# create table bar (like foo) inherits (foo);
Just out of curiosity, is there any actual use-case for such a silly
thing?
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #7583: Problem using INHERITS and LIKE
@ 2012-10-04 17:24 Bryan Love <bryan.love@iovation.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Bryan Love @ 2012-10-04 17:24 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
Understood, thanks.
Our use case is that we want to copy the indexes from the parent table as
well, so we have to use (like ... including indexes).
On Thu, Oct 4, 2012 at 7:38 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> bryan.love@iovation.com writes:
> > After creating a table using LIKE and INHERITS, if you drop a column from
> > the parent table that existed prior to creation of the child table, the
> > column will not be dropped from the child table.
>
> This is not a bug. LIKE says the column isn't inherited, so it exists
> in the child independently of whether it exists in the parent.
>
> Or, if you want to add it up: the child starts out with one local
> definition of the column (from LIKE) and one inherited (from INHERITS).
> Dropping the column from the parent removes the latter, but you still
> have the former, so the column stays.
>
> > =# create table bar (like foo) inherits (foo);
>
> Just out of curiosity, is there any actual use-case for such a silly
> thing?
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2012-10-04 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03 20:36 BUG #7583: Problem using INHERITS and LIKE bryan.love@iovation.com
2012-10-04 14:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-10-04 17:24 ` Bryan Love <bryan.love@iovation.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox