mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +03:00
Adjust alter_table regression test to avoid conflicts with rangefuncs
and prepare tests, which cause intermittent failures in parallel test mode. Back-port of fix originally applied to 8.0 and 7.4 branches; the problems do not appear to exist in 7.2 branch but they do occur in 7.3. Per buildfarm results.
This commit is contained in:
@@ -90,183 +90,36 @@ SELECT * FROM tmp;
|
||||
|
||||
DROP TABLE tmp;
|
||||
--
|
||||
-- rename -
|
||||
-- should preserve indices, which we can check by seeing if a SELECT
|
||||
-- chooses an indexscan; however, in the absence of vacuum statistics
|
||||
-- it might not. Therefore, vacuum first.
|
||||
-- rename - check on both non-temp and temp tables
|
||||
--
|
||||
VACUUM ANALYZE tenk1;
|
||||
ALTER TABLE tenk1 RENAME TO ten_k;
|
||||
-- 20 values, sorted
|
||||
SELECT unique1 FROM ten_k WHERE unique1 < 20;
|
||||
unique1
|
||||
---------
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
(20 rows)
|
||||
CREATE TABLE tmp (regtable int);
|
||||
CREATE TEMP TABLE tmp (tmptable int);
|
||||
ALTER TABLE tmp RENAME TO tmp_new;
|
||||
SELECT * FROM tmp;
|
||||
regtable
|
||||
----------
|
||||
(0 rows)
|
||||
|
||||
-- 20 values, sorted
|
||||
SELECT unique2 FROM ten_k WHERE unique2 < 20;
|
||||
unique2
|
||||
---------
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
(20 rows)
|
||||
SELECT * FROM tmp_new;
|
||||
tmptable
|
||||
----------
|
||||
(0 rows)
|
||||
|
||||
-- 100 values, sorted
|
||||
SELECT hundred FROM ten_k WHERE hundred = 50;
|
||||
hundred
|
||||
---------
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
50
|
||||
(100 rows)
|
||||
ALTER TABLE tmp RENAME TO tmp_new2;
|
||||
SELECT * FROM tmp; -- should fail
|
||||
ERROR: Relation "tmp" does not exist
|
||||
SELECT * FROM tmp_new;
|
||||
tmptable
|
||||
----------
|
||||
(0 rows)
|
||||
|
||||
ALTER TABLE ten_k RENAME TO tenk1;
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
unique1
|
||||
---------
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
(5 rows)
|
||||
SELECT * FROM tmp_new2;
|
||||
regtable
|
||||
----------
|
||||
(0 rows)
|
||||
|
||||
DROP TABLE tmp_new;
|
||||
DROP TABLE tmp_new2;
|
||||
-- ALTER TABLE ... RENAME on non-table relations
|
||||
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
||||
ALTER TABLE onek_unique1 RENAME TO tmp_onek_unique1;
|
||||
@@ -274,6 +127,8 @@ ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
|
||||
-- renaming views
|
||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||
-- analyze to ensure we get an indexscan here
|
||||
ANALYZE tenk1;
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
unique1
|
||||
@@ -740,8 +595,8 @@ drop table def_test;
|
||||
alter table pg_class drop column relname;
|
||||
ERROR: ALTER TABLE: relation "pg_class" is a system catalog
|
||||
-- try altering non-existent table, should fail
|
||||
alter table foo drop column bar;
|
||||
ERROR: Relation "foo" does not exist
|
||||
alter table nosuchtable drop column bar;
|
||||
ERROR: Relation "nosuchtable" does not exist
|
||||
-- test dropping columns
|
||||
create table atacc1 (a int4 not null, b int4, c int4 not null, d int4);
|
||||
insert into atacc1 values (1, 2, 3, 4);
|
||||
|
@@ -140,28 +140,25 @@ DROP TABLE tmp;
|
||||
|
||||
|
||||
--
|
||||
-- rename -
|
||||
-- should preserve indices, which we can check by seeing if a SELECT
|
||||
-- chooses an indexscan; however, in the absence of vacuum statistics
|
||||
-- it might not. Therefore, vacuum first.
|
||||
-- rename - check on both non-temp and temp tables
|
||||
--
|
||||
VACUUM ANALYZE tenk1;
|
||||
CREATE TABLE tmp (regtable int);
|
||||
CREATE TEMP TABLE tmp (tmptable int);
|
||||
|
||||
ALTER TABLE tenk1 RENAME TO ten_k;
|
||||
ALTER TABLE tmp RENAME TO tmp_new;
|
||||
|
||||
-- 20 values, sorted
|
||||
SELECT unique1 FROM ten_k WHERE unique1 < 20;
|
||||
SELECT * FROM tmp;
|
||||
SELECT * FROM tmp_new;
|
||||
|
||||
-- 20 values, sorted
|
||||
SELECT unique2 FROM ten_k WHERE unique2 < 20;
|
||||
ALTER TABLE tmp RENAME TO tmp_new2;
|
||||
|
||||
-- 100 values, sorted
|
||||
SELECT hundred FROM ten_k WHERE hundred = 50;
|
||||
SELECT * FROM tmp; -- should fail
|
||||
SELECT * FROM tmp_new;
|
||||
SELECT * FROM tmp_new2;
|
||||
|
||||
ALTER TABLE ten_k RENAME TO tenk1;
|
||||
DROP TABLE tmp_new;
|
||||
DROP TABLE tmp_new2;
|
||||
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
|
||||
-- ALTER TABLE ... RENAME on non-table relations
|
||||
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
||||
@@ -170,6 +167,8 @@ ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
|
||||
-- renaming views
|
||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||
-- analyze to ensure we get an indexscan here
|
||||
ANALYZE tenk1;
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
DROP VIEW tmp_view_new;
|
||||
@@ -577,7 +576,7 @@ drop table def_test;
|
||||
alter table pg_class drop column relname;
|
||||
|
||||
-- try altering non-existent table, should fail
|
||||
alter table foo drop column bar;
|
||||
alter table nosuchtable drop column bar;
|
||||
|
||||
-- test dropping columns
|
||||
create table atacc1 (a int4 not null, b int4, c int4 not null, d int4);
|
||||
|
Reference in New Issue
Block a user