More bogosity in alter_table test: sometimes causes prepare test to fail
by means of arbitrarily renaming tables the other test depends on.
This commit is contained in:
parent
e8a4515626
commit
2fb67fa469
|
@ -94,183 +94,36 @@ SELECT * FROM tmp;
|
||||||
|
|
||||||
DROP TABLE tmp;
|
DROP TABLE tmp;
|
||||||
--
|
--
|
||||||
-- rename -
|
-- rename - check on both non-temp and temp tables
|
||||||
-- 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.
|
|
||||||
--
|
--
|
||||||
VACUUM ANALYZE tenk1;
|
CREATE TABLE tmp (regtable int);
|
||||||
ALTER TABLE tenk1 RENAME TO ten_k;
|
CREATE TEMP TABLE tmp (tmptable int);
|
||||||
-- 20 values, sorted
|
ALTER TABLE tmp RENAME TO tmp_new;
|
||||||
SELECT unique1 FROM ten_k WHERE unique1 < 20;
|
SELECT * FROM tmp;
|
||||||
unique1
|
regtable
|
||||||
---------
|
----------
|
||||||
0
|
(0 rows)
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
7
|
|
||||||
8
|
|
||||||
9
|
|
||||||
10
|
|
||||||
11
|
|
||||||
12
|
|
||||||
13
|
|
||||||
14
|
|
||||||
15
|
|
||||||
16
|
|
||||||
17
|
|
||||||
18
|
|
||||||
19
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
-- 20 values, sorted
|
SELECT * FROM tmp_new;
|
||||||
SELECT unique2 FROM ten_k WHERE unique2 < 20;
|
tmptable
|
||||||
unique2
|
----------
|
||||||
---------
|
(0 rows)
|
||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
7
|
|
||||||
8
|
|
||||||
9
|
|
||||||
10
|
|
||||||
11
|
|
||||||
12
|
|
||||||
13
|
|
||||||
14
|
|
||||||
15
|
|
||||||
16
|
|
||||||
17
|
|
||||||
18
|
|
||||||
19
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
-- 100 values, sorted
|
ALTER TABLE tmp RENAME TO tmp_new2;
|
||||||
SELECT hundred FROM ten_k WHERE hundred = 50;
|
SELECT * FROM tmp; -- should fail
|
||||||
hundred
|
ERROR: relation "tmp" does not exist
|
||||||
---------
|
SELECT * FROM tmp_new;
|
||||||
50
|
tmptable
|
||||||
50
|
----------
|
||||||
50
|
(0 rows)
|
||||||
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 ten_k RENAME TO tenk1;
|
SELECT * FROM tmp_new2;
|
||||||
-- 5 values, sorted
|
regtable
|
||||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
----------
|
||||||
unique1
|
(0 rows)
|
||||||
---------
|
|
||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
|
DROP TABLE tmp_new;
|
||||||
|
DROP TABLE tmp_new2;
|
||||||
-- ALTER TABLE ... RENAME on non-table relations
|
-- ALTER TABLE ... RENAME on non-table relations
|
||||||
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
||||||
ALTER TABLE onek_unique1 RENAME TO tmp_onek_unique1;
|
ALTER TABLE onek_unique1 RENAME TO tmp_onek_unique1;
|
||||||
|
@ -278,6 +131,8 @@ ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
|
||||||
-- renaming views
|
-- renaming views
|
||||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||||
|
-- analyze to ensure we get an indexscan here
|
||||||
|
ANALYZE tenk1;
|
||||||
-- 5 values, sorted
|
-- 5 values, sorted
|
||||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||||
unique1
|
unique1
|
||||||
|
|
|
@ -144,28 +144,25 @@ DROP TABLE tmp;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- rename -
|
-- rename - check on both non-temp and temp tables
|
||||||
-- 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.
|
|
||||||
--
|
--
|
||||||
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 * FROM tmp;
|
||||||
SELECT unique1 FROM ten_k WHERE unique1 < 20;
|
SELECT * FROM tmp_new;
|
||||||
|
|
||||||
-- 20 values, sorted
|
ALTER TABLE tmp RENAME TO tmp_new2;
|
||||||
SELECT unique2 FROM ten_k WHERE unique2 < 20;
|
|
||||||
|
|
||||||
-- 100 values, sorted
|
SELECT * FROM tmp; -- should fail
|
||||||
SELECT hundred FROM ten_k WHERE hundred = 50;
|
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
|
-- ALTER TABLE ... RENAME on non-table relations
|
||||||
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
||||||
|
@ -174,6 +171,8 @@ ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
|
||||||
-- renaming views
|
-- renaming views
|
||||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||||
|
-- analyze to ensure we get an indexscan here
|
||||||
|
ANALYZE tenk1;
|
||||||
-- 5 values, sorted
|
-- 5 values, sorted
|
||||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||||
DROP VIEW tmp_view_new;
|
DROP VIEW tmp_view_new;
|
||||||
|
|
Loading…
Reference in New Issue