From 1c9fc0d70a66ff3a167a6e2ab0f8a3b48d1d969d Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Thu, 19 Jan 2017 13:35:18 +0900
Subject: [PATCH 8/8] Avoid DROP TABLE ... CASCADE in more partitioning tests

The output produced by specifying CASCADE is unreliable and causes
test failures occasionally.  This time, fix create_table.sql and
alter_table.sql to do that.

Patch by: Amit Langote
---
 src/test/regress/expected/alter_table.out  | 18 ++++++----------
 src/test/regress/expected/create_table.out | 34 ++++++------------------------
 src/test/regress/sql/alter_table.sql       | 10 +++++----
 src/test/regress/sql/create_table.sql      | 14 ++++++------
 4 files changed, 26 insertions(+), 50 deletions(-)

diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index c510761c68..76b9c2d372 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -3330,15 +3330,10 @@ ALTER TABLE list_parted2 DROP COLUMN b;
 ERROR:  cannot drop column named in partition key
 ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
 ERROR:  cannot alter type of column named in partition key
--- cleanup
-DROP TABLE list_parted, list_parted2, range_parted CASCADE;
-NOTICE:  drop cascades to 6 other objects
-DETAIL:  drop cascades to table part1
-drop cascades to table part2
-drop cascades to table part_2
-drop cascades to table part_5
-drop cascades to table part_5_a
-drop cascades to table part_1
+-- cleanup: avoid using CASCADE
+DROP TABLE list_parted, part_1;
+DROP TABLE list_parted2, part_2, part_5, part_5_a;
+DROP TABLE range_parted, part1, part2;
 -- more tests for certain multi-level partitioning scenarios
 create table p (a int, b int) partition by range (a, b);
 create table p1 (b int, a int not null) partition by range (b);
@@ -3367,6 +3362,5 @@ insert into p1 (a, b) values (2, 3);
 -- check that partition validation scan correctly detects violating rows
 alter table p attach partition p1 for values from (1, 2) to (1, 10);
 ERROR:  partition constraint is violated by some row
--- cleanup
-drop table p, p1 cascade;
-NOTICE:  drop cascades to table p11
+-- cleanup: avoid using CASCADE
+drop table p, p1, p11;
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 37edd6cde8..6caa9c2407 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -651,30 +651,10 @@ Check constraints:
     "check_a" CHECK (length(a) > 0)
 Number of partitions: 3 (Use \d+ to list them.)
 
--- partitions cannot be dropped directly
-DROP TABLE part_a;
--- need to specify CASCADE to drop partitions along with the parent
-DROP TABLE parted;
-ERROR:  cannot drop table parted because other objects depend on it
-DETAIL:  table part_b depends on table parted
-table part_c depends on table parted
-table part_c_1_10 depends on table part_c
-HINT:  Use DROP ... CASCADE to drop the dependent objects too.
-DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3 CASCADE;
-NOTICE:  drop cascades to 16 other objects
-DETAIL:  drop cascades to table part00
-drop cascades to table part10
-drop cascades to table part11
-drop cascades to table part12
-drop cascades to table part0
-drop cascades to table part1
-drop cascades to table part2
-drop cascades to table part3
-drop cascades to table part_null_z
-drop cascades to table part_ab
-drop cascades to table part_1
-drop cascades to table part_2
-drop cascades to table part_null
-drop cascades to table part_b
-drop cascades to table part_c
-drop cascades to table part_c_1_10
+-- cleanup: avoid using CASCADE
+DROP TABLE parted, part_a, part_b, part_c, part_c_1_10;
+DROP TABLE list_parted, part_1, part_2, part_null;
+DROP TABLE range_parted;
+DROP TABLE list_parted2, part_ab, part_null_z;
+DROP TABLE range_parted2, part0, part1, part2, part3;
+DROP TABLE range_parted3, part00, part10, part11, part12;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 86d27ac35c..4611cbb731 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -2189,8 +2189,10 @@ ALTER TABLE part_2 INHERIT inh_test;
 ALTER TABLE list_parted2 DROP COLUMN b;
 ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
 
--- cleanup
-DROP TABLE list_parted, list_parted2, range_parted CASCADE;
+-- cleanup: avoid using CASCADE
+DROP TABLE list_parted, part_1;
+DROP TABLE list_parted2, part_2, part_5, part_5_a;
+DROP TABLE range_parted, part1, part2;
 
 -- more tests for certain multi-level partitioning scenarios
 create table p (a int, b int) partition by range (a, b);
@@ -2215,5 +2217,5 @@ insert into p1 (a, b) values (2, 3);
 -- check that partition validation scan correctly detects violating rows
 alter table p attach partition p1 for values from (1, 2) to (1, 10);
 
--- cleanup
-drop table p, p1 cascade;
+-- cleanup: avoid using CASCADE
+drop table p, p1, p11;
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index f960d36fd0..8242e7328d 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -585,10 +585,10 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10);
 -- returned.
 \d parted
 
--- partitions cannot be dropped directly
-DROP TABLE part_a;
-
--- need to specify CASCADE to drop partitions along with the parent
-DROP TABLE parted;
-
-DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3 CASCADE;
+-- cleanup: avoid using CASCADE
+DROP TABLE parted, part_a, part_b, part_c, part_c_1_10;
+DROP TABLE list_parted, part_1, part_2, part_null;
+DROP TABLE range_parted;
+DROP TABLE list_parted2, part_ab, part_null_z;
+DROP TABLE range_parted2, part0, part1, part2, part3;
+DROP TABLE range_parted3, part00, part10, part11, part12;
-- 
2.11.0

