hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y...@apache.org
Subject incubator-hawq git commit: HAWQ-792. Orca on causes different error message when insert null value to a not null col
Date Sun, 12 Jun 2016 04:55:52 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master c99884a3c -> b260e2d7e


HAWQ-792. Orca on causes different error message when insert null value to a not null col


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

Branch: refs/heads/master
Commit: b260e2d7e82dcc8405bbcb6a657c82d0cb9d883a
Parents: c99884a
Author: YI JIN <yjin@pivotal.io>
Authored: Sun Jun 12 14:55:23 2016 +1000
Committer: YI JIN <yjin@pivotal.io>
Committed: Sun Jun 12 14:55:23 2016 +1000

----------------------------------------------------------------------
 src/test/feature/lib/sql_util.cpp                  | 13 +++++++++++++
 src/test/feature/lib/sql_util.h                    |  5 +++++
 .../query/ans/sequence-serialcol-null-orca.ans     |  3 +++
 src/test/feature/query/test_sequence.cpp           | 17 +++++++++++++++--
 4 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b260e2d7/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 4f48664..8e9b615 100644
--- a/src/test/feature/lib/sql_util.cpp
+++ b/src/test/feature/lib/sql_util.cpp
@@ -164,6 +164,19 @@ string SQLUtility::getTestRootPath() const {
   return splitFilePath(result).path;
 }
 
+void SQLUtility::setGUCValue(const std::string &guc, const std::string &value) {
+  string sql = "set " + guc + " = " + value;
+  execute(sql, true);
+}
+
+std::string SQLUtility::getGUCValue(const std::string &guc) {
+  string sql = "show " + guc;
+  const hawq::test::PSQLQueryResult &result = executeQuery(sql);
+  EXPECT_EQ(result.rowCount(), 1);
+  std::vector<std::string> row = result.getRows()[0];
+  return row[0];
+}
+
 FilePath SQLUtility::splitFilePath(const string &filePath) const {
   FilePath fp;
   size_t found1 = filePath.find_last_of("/");

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b260e2d7/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 296108b..58df9cb 100644
--- a/src/test/feature/lib/sql_util.h
+++ b/src/test/feature/lib/sql_util.h
@@ -58,6 +58,11 @@ class SQLUtility {
   // @return path string
   std::string getTestRootPath() const;
 
+  // Set GUC value
+  void setGUCValue(const std::string &guc, const std::string &value);
+  // Get GUC value
+  std::string getGUCValue(const std::string &guc);
+
  private:
   std::unique_ptr<hawq::test::PSQL> getConnection();
   const std::string generateSQLFile(const std::string &sqlFile);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b260e2d7/src/test/feature/query/ans/sequence-serialcol-null-orca.ans
----------------------------------------------------------------------
diff --git a/src/test/feature/query/ans/sequence-serialcol-null-orca.ans b/src/test/feature/query/ans/sequence-serialcol-null-orca.ans
new file mode 100644
index 0000000..981d94f
--- /dev/null
+++ b/src/test/feature/query/ans/sequence-serialcol-null-orca.ans
@@ -0,0 +1,3 @@
+INSERT INTO serialtest VALUES('wrong',NULL);
+psql:/tmp/TestQuerySequence_TestSequenceCreateSerialColumn.sql:4: ERROR:  One or more assertions
failed  (seg0 localhost:40000 pid=11362)
+DETAIL:  Not null constraint for column f2 of table serialtest was violated

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b260e2d7/src/test/feature/query/test_sequence.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test_sequence.cpp b/src/test/feature/query/test_sequence.cpp
index 45027b9..36479c0 100644
--- a/src/test/feature/query/test_sequence.cpp
+++ b/src/test/feature/query/test_sequence.cpp
@@ -22,14 +22,27 @@ class TestQuerySequence : public ::testing::Test {
 
 TEST_F(TestQuerySequence, TestSequenceCreateSerialColumn) {
   hawq::test::SQLUtility util;
+  bool orcaon = false;
+  if (util.getGUCValue("optimizer") == "on") {
+	std::cout << "NOTE: TestQuerySequence.TestSequenceCreateSerialColumn "
+                 "uses answer file for optimizer on" << std::endl;
+    orcaon = true;
+  }
 
   util.execute("drop table if exists serialtest");
   util.execute("create table serialtest (f1 text, f2 serial)");
   util.execute("insert into serialtest values('foo')");
   util.execute("insert into serialtest values('force',100)");
   // expect failure due to null value in serial column
-  util.execSQLFile("query/sql/sequence-serialcol-null.sql",
-		  	  	   "query/ans/sequence-serialcol-null.ans");
+  if (orcaon) {
+    util.execSQLFile("query/sql/sequence-serialcol-null.sql",
+				     "query/ans/sequence-serialcol-null-orca.ans");
+  }
+  else {
+    util.execSQLFile("query/sql/sequence-serialcol-null.sql",
+				     "query/ans/sequence-serialcol-null.ans");
+
+  }
   // query table to check rows with generated and specified values in serial col
   util.execSQLFile("query/sql/sequence-serialcol-query.sql",
 		  	  	   "query/ans/sequence-serialcol-query.ans");


Mime
View raw message