mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Change ALTER TABLE SET WITHOUT OIDS to rewrite the whole table to physically
get rid of the OID column. This eliminates the problem discovered by Heikki back in November that 8.4's suppression of "unnecessary" junk filtering in INSERT/SELECT could lead to an Assert failure, or storing of oids into a table that shouldn't have them if Asserts are off. While that particular problem could have been solved in other ways, it seems likely to be just a forerunner of things to come if we continue to allow tables to contain rows that disagree with the pg_class.relhasoids setting. It's better to make this operation slow than to sacrifice performance or risk bugs in more common code paths. Also, add ALTER TABLE SET WITH OIDS to rewrite the table to add oids. This was a bit more controversial, but in view of the very small amount of extra code needed given the current ALTER TABLE infrastructure, it seems best to eliminate the asymmetry in features.
This commit is contained in:
@@ -921,7 +921,7 @@ order by relname, attnum;
|
||||
drop table p1, p2 cascade;
|
||||
|
||||
--
|
||||
-- Test the ALTER TABLE WITHOUT OIDS command
|
||||
-- Test the ALTER TABLE SET WITH/WITHOUT OIDS command
|
||||
--
|
||||
create table altstartwith (col integer) with oids;
|
||||
|
||||
@@ -934,10 +934,16 @@ alter table altstartwith set without oids;
|
||||
select oid > 0, * from altstartwith; -- fails
|
||||
select * from altstartwith;
|
||||
|
||||
-- Run inheritance tests
|
||||
alter table altstartwith set with oids;
|
||||
|
||||
select oid > 0, * from altstartwith;
|
||||
|
||||
drop table altstartwith;
|
||||
|
||||
-- Check inheritance cases
|
||||
create table altwithoid (col integer) with oids;
|
||||
|
||||
-- Inherits parents oid column
|
||||
-- Inherits parents oid column anyway
|
||||
create table altinhoid () inherits (altwithoid) without oids;
|
||||
|
||||
insert into altinhoid values (1);
|
||||
@@ -946,13 +952,42 @@ select oid > 0, * from altwithoid;
|
||||
select oid > 0, * from altinhoid;
|
||||
|
||||
alter table altwithoid set without oids;
|
||||
alter table altinhoid set without oids;
|
||||
|
||||
select oid > 0, * from altwithoid; -- fails
|
||||
select oid > 0, * from altinhoid; -- fails
|
||||
select * from altwithoid;
|
||||
select * from altinhoid;
|
||||
|
||||
alter table altwithoid set with oids;
|
||||
|
||||
select oid > 0, * from altwithoid;
|
||||
select oid > 0, * from altinhoid;
|
||||
|
||||
drop table altwithoid cascade;
|
||||
|
||||
create table altwithoid (col integer) without oids;
|
||||
|
||||
-- child can have local oid column
|
||||
create table altinhoid () inherits (altwithoid) with oids;
|
||||
|
||||
insert into altinhoid values (1);
|
||||
|
||||
select oid > 0, * from altwithoid; -- fails
|
||||
select oid > 0, * from altinhoid;
|
||||
|
||||
alter table altwithoid set with oids;
|
||||
|
||||
select oid > 0, * from altwithoid;
|
||||
select oid > 0, * from altinhoid;
|
||||
|
||||
-- the child's local definition should remain
|
||||
alter table altwithoid set without oids;
|
||||
|
||||
select oid > 0, * from altwithoid; -- fails
|
||||
select oid > 0, * from altinhoid;
|
||||
|
||||
drop table altwithoid cascade;
|
||||
|
||||
-- test renumbering of child-table columns in inherited operations
|
||||
|
||||
create table p1 (f1 int);
|
||||
|
||||
Reference in New Issue
Block a user