This is an automated email from the ASF dual-hosted git repository. chiyang10000 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hawq.git
commit 117bbfe7741d52f81fc3c408f8cae6c611628713 Author: Chiyang Wan <[email protected]> AuthorDate: Tue Feb 23 10:04:07 2021 +0800 HAWQ-1784. Fix TestCreateTable depends on GUC setting It collects saved GUC values into each SQLUtility instance. --- src/test/feature/catalog/test_create_table.cpp | 4 ++++ src/test/feature/lib/sql_util.cpp | 6 +++--- src/test/feature/lib/sql_util.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/feature/catalog/test_create_table.cpp b/src/test/feature/catalog/test_create_table.cpp index 9219748..240f39c 100644 --- a/src/test/feature/catalog/test_create_table.cpp +++ b/src/test/feature/catalog/test_create_table.cpp @@ -188,6 +188,7 @@ TEST_F(TestCreateTable, TestCreateTable1) { TEST_F(TestCreateTable, TestCreateTableInherits) { hawq::test::SQLUtility util; // prepare + util.setGUCValue("default_hash_table_bucket_number", "6"); util.execute("DROP TABLE IF EXISTS t1_1_6, t1_1_5, t1_1_4, t1_1_3, " "t1_1_2, t1_1_1, t1_1_w, t1_1, t1 CASCADE"); @@ -238,6 +239,7 @@ TEST_F(TestCreateTable, TestCreateTableInherits) { TEST_F(TestCreateTable, TestCreateTableDistribution1) { hawq::test::SQLUtility util; // prepare + util.setGUCValue("default_hash_table_bucket_number", "6"); util.execute("DROP TABLE IF EXISTS t1_3_4, t1_3_3, t1_3_2, t1_3_1, t1_3_w, t1_3 CASCADE"); util.execute("DROP TABLE IF EXISTS t1_2_4, t1_2_3, t1_2_2, t1_2_1, t1_2_w, t1_2 CASCADE"); util.execute("DROP TABLE IF EXISTS t1 CASCADE"); @@ -307,6 +309,7 @@ TEST_F(TestCreateTable, TestCreateTableDistribution1) { TEST_F(TestCreateTable, TestCreateTableDistribution2) { hawq::test::SQLUtility util; // prepare + util.setGUCValue("default_hash_table_bucket_number", "6"); util.execute("DROP TABLE IF EXISTS t2_2, t2_2_w, t2_2_1, t2_2_2, t2_2_3, t2_2_4 CASCADE"); util.execute("DROP TABLE IF EXISTS t2_3, t2_3_w, t2_3_1, t2_3_2, t2_3_3, t2_3_4 CASCADE"); util.execute("DROP TABLE IF EXISTS t2_1_1, t2_1, t2 CASCADE"); @@ -428,6 +431,7 @@ TEST_F(TestCreateTable, TestCreateTableDistribution3) { TEST_F(TestCreateTable, TestCreateTableDistribution4) { hawq::test::SQLUtility util; // prepare + util.setGUCValue("default_hash_table_bucket_number", "6"); util.execute("DROP TABLE IF EXISTS t4"); // test diff --git a/src/test/feature/lib/sql_util.cpp b/src/test/feature/lib/sql_util.cpp index 1dbef13..3ad027c 100644 --- a/src/test/feature/lib/sql_util.cpp +++ b/src/test/feature/lib/sql_util.cpp @@ -176,7 +176,7 @@ void SQLUtility::exec(const string &sql) { void SQLUtility::execIgnore(const string &sql) { conn->runSQLCommand(sql); } string SQLUtility::execute(const string &sql, bool check) { - conn->runSQLCommand("SET SEARCH_PATH=" + schemaName + ";" + sql); + conn->runSQLCommand("SET SEARCH_PATH=" + schemaName + ";" + savedGUCValue + sql); EXPECT_NE(conn.get(), nullptr); if (check) { EXPECT_EQ(0, conn->getLastStatus()) << sql << " " << conn->getLastResult(); @@ -186,7 +186,7 @@ string SQLUtility::execute(const string &sql, bool check) { } bool SQLUtility::executeSql(const std::string &sql) { - conn->runSQLCommand("SET SEARCH_PATH=" + schemaName + ";" + sql); + conn->runSQLCommand("SET SEARCH_PATH=" + schemaName + ";" + savedGUCValue + sql); EXPECT_NE(conn.get(), nullptr); return !conn->getLastStatus(); } @@ -767,7 +767,7 @@ string SQLUtility::getTestRootPath() { void SQLUtility::setGUCValue(const std::string &guc, const std::string &value) { string sql = "set " + guc + " = " + value; - execute(sql, true); + savedGUCValue += sql + ';'; } std::string SQLUtility::getGUCValue(const std::string &guc) { diff --git a/src/test/feature/lib/sql_util.h b/src/test/feature/lib/sql_util.h index 748ad31..3ca67a9 100644 --- a/src/test/feature/lib/sql_util.h +++ b/src/test/feature/lib/sql_util.h @@ -397,6 +397,7 @@ class SQLUtility { std::unique_ptr<hawq::test::PSQL> conn; std::string databaseName; std::string schemaName; + std::string savedGUCValue; }; // class SQLUtility
