hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject incubator-hawq git commit: HAWQ-811. Refactor execute interface in sql_util of feature test library to support returning error message.
Date Tue, 14 Jun 2016 03:00:48 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 62559633a -> 0d754a437


HAWQ-811. Refactor execute interface in sql_util of feature test library to support returning
error message.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/0d754a43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/0d754a43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/0d754a43

Branch: refs/heads/master
Commit: 0d754a43709160410f5d1d40d0f0f5535c2b1c84
Parents: 6255963
Author: xunzhang <xunzhangthu@gmail.com>
Authored: Mon Jun 13 23:26:25 2016 +0800
Committer: rlei <rlei@pivotal.io>
Committed: Tue Jun 14 10:58:00 2016 +0800

----------------------------------------------------------------------
 src/test/feature/lib/sql_util.cpp     | 8 ++++++--
 src/test/feature/lib/sql_util.h       | 6 +++---
 src/test/feature/testlib/test_lib.cpp | 7 +++++++
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0d754a43/src/test/feature/lib/sql_util.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/sql_util.cpp b/src/test/feature/lib/sql_util.cpp
index 8e9b615..8f2f208 100644
--- a/src/test/feature/lib/sql_util.cpp
+++ b/src/test/feature/lib/sql_util.cpp
@@ -51,10 +51,14 @@ void SQLUtility::exec(const string &sql) {
       << conn->getLastResult();
 }
 
-void SQLUtility::execute(const string &sql, bool check) {
+string SQLUtility::execute(const string &sql, bool check) {
   conn->runSQLCommand("SET SEARCH_PATH=" + schemaName + ";" + sql);
   EXPECT_NE(conn.get(), nullptr);
-  if (check) EXPECT_EQ(0, conn->getLastStatus()) << conn->getLastResult();
+  if (check) {
+    EXPECT_EQ(0, conn->getLastStatus()) << conn->getLastResult();
+    return "";
+  }
+  return conn.get()->getLastResult();
 }
 
 void SQLUtility::query(const string &sql, int expectNum) {

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0d754a43/src/test/feature/lib/sql_util.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/sql_util.h b/src/test/feature/lib/sql_util.h
index 58df9cb..48a4c2c 100644
--- a/src/test/feature/lib/sql_util.h
+++ b/src/test/feature/lib/sql_util.h
@@ -29,8 +29,8 @@ class SQLUtility {
 
   // Execute sql command
   // @param sql The given sql command
-  // @return void
-  void execute(const std::string &sql, bool check = true);
+  // @return error or notice message if check is false, else return empty
+  std::string execute(const std::string &sql, bool check = true);
 
   // Execute query command and check the rowCount
   // @param sql The given query command
@@ -50,7 +50,7 @@ class SQLUtility {
   // @return void
   void execSQLFile(const std::string &sqlFile, const std::string &ansFile);
 
-  // Get PSQL connection
+  // Get PSQL connection: do not suggest to use
   // @return PSQL raw pointer
   const hawq::test::PSQL *getPSQL() const;
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0d754a43/src/test/feature/testlib/test_lib.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/testlib/test_lib.cpp b/src/test/feature/testlib/test_lib.cpp
index 1c30284..99325f6 100644
--- a/src/test/feature/testlib/test_lib.cpp
+++ b/src/test/feature/testlib/test_lib.cpp
@@ -71,6 +71,13 @@ TEST_F(TestCommonLib, TestSqlUtil) {
   util.query("select * from test", 2);
   util.query("select * from test", "1|1.1|\n2|2.2|\n");
   util.execSQLFile("testlib/sql/sample.sql", "testlib/ans/sample.ans");
+  auto err_msg = util.execute("select * from non_exist_tbl;", false);
+  EXPECT_EQ(err_msg,
+            "ERROR:  relation \"non_exist_tbl\" does not exist\n"
+            "LINE 1: ...ARCH_PATH=TestCommonLib_TestSqlUtil;select * from non_exist_...\n"
+            "                                                             ^\n");
+  err_msg = util.execute("drop table non_exist_tbl;", false);
+  EXPECT_EQ(err_msg, "ERROR:  table \"non_exist_tbl\" does not exist\n");
 }
 
 TEST_F(TestCommonLib, TestDataGenerator) {


Mime
View raw message