You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2017/03/01 19:12:23 UTC

[2/2] kudu git commit: KUDU-1852. KuduTableAlterer should not crash with nullptr arguments

KUDU-1852. KuduTableAlterer should not crash with nullptr arguments

Change-Id: Ifa7c34b476111ecd33d4fd3ef5cc363a410ad76a
Reviewed-on: http://gerrit.cloudera.org:8080/5797
Reviewed-by: Dan Burkert <da...@apache.org>
Tested-by: Kudu Jenkins
(cherry picked from commit 8a2ea8bddc88e8de60952b369f112b32710ee19b)
Reviewed-on: http://gerrit.cloudera.org:8080/6204
Reviewed-by: Jean-Daniel Cryans <jd...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/1af814b0
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/1af814b0
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/1af814b0

Branch: refs/heads/branch-1.2.x
Commit: 1af814b0908b191e8c41a027670b99a8c2bc78f3
Parents: 3b05eee
Author: Todd Lipcon <to...@apache.org>
Authored: Wed Jan 25 17:43:25 2017 -0800
Committer: Jean-Daniel Cryans <jd...@apache.org>
Committed: Wed Mar 1 19:10:13 2017 +0000

----------------------------------------------------------------------
 src/kudu/client/client.cc                      | 6 ++++++
 src/kudu/integration-tests/alter_table-test.cc | 7 +++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/1af814b0/src/kudu/client/client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index 3ca0aba..c6ef71f 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -920,14 +920,17 @@ KuduTableAlterer* KuduTableAlterer::AddRangePartition(
 
   if (lower_bound == nullptr || upper_bound == nullptr) {
     data_->status_ = Status::InvalidArgument("range partition bounds may not be null");
+    return this;
   }
   if (!lower_bound->schema()->Equals(*upper_bound->schema())) {
     data_->status_ = Status::InvalidArgument("range partition bounds must have matching schemas");
+    return this;
   }
   if (data_->schema_ == nullptr) {
     data_->schema_ = lower_bound->schema();
   } else if (!lower_bound->schema()->Equals(*data_->schema_)) {
     data_->status_ = Status::InvalidArgument("range partition bounds must have matching schemas");
+    return this;
   }
 
   Data::Step s { AlterTableRequestPB::ADD_RANGE_PARTITION,
@@ -948,14 +951,17 @@ KuduTableAlterer* KuduTableAlterer::DropRangePartition(
     KuduTableCreator::RangePartitionBound upper_bound_type) {
   if (lower_bound == nullptr || upper_bound == nullptr) {
     data_->status_ = Status::InvalidArgument("range partition bounds may not be null");
+    return this;
   }
   if (!lower_bound->schema()->Equals(*upper_bound->schema())) {
     data_->status_ = Status::InvalidArgument("range partition bounds must have matching schemas");
+    return this;
   }
   if (data_->schema_ == nullptr) {
     data_->schema_ = lower_bound->schema();
   } else if (!lower_bound->schema()->Equals(*data_->schema_)) {
     data_->status_ = Status::InvalidArgument("range partition bounds must have matching schemas");
+    return this;
   }
 
   Data::Step s { AlterTableRequestPB::DROP_RANGE_PARTITION,

http://git-wip-us.apache.org/repos/asf/kudu/blob/1af814b0/src/kudu/integration-tests/alter_table-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/alter_table-test.cc b/src/kudu/integration-tests/alter_table-test.cc
index 2d0b8eb..45eba3b 100644
--- a/src/kudu/integration-tests/alter_table-test.cc
+++ b/src/kudu/integration-tests/alter_table-test.cc
@@ -1502,6 +1502,13 @@ TEST_F(AlterTableTest, TestAlterRangePartitioningInvalid) {
   ASSERT_FALSE(s.ok());
   ASSERT_STR_CONTAINS(s.ToString(), "No range partition found for drop range partition step");
   ASSERT_EQ(100, CountTableRows(table.get()));
+
+  // Bad arguments (null ranges)
+  table_alterer.reset(client_->NewTableAlterer(table_name));
+  table_alterer->DropRangePartition(nullptr, nullptr);
+  s = table_alterer->Alter();
+  ASSERT_FALSE(s.ok());
+  ASSERT_STR_CONTAINS(s.ToString(), "range partition bounds may not be null");
 }
 
 // Attempts to exhaustively check all cases of single-column range partition