kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject kudu git commit: KUDU-1852. KuduTableAlterer should not crash with nullptr arguments
Date Thu, 26 Jan 2017 03:34:39 GMT
Repository: kudu
Updated Branches:
  refs/heads/master dc8525358 -> 8a2ea8bdd


KUDU-1852. KuduTableAlterer should not crash with nullptr arguments

Change-Id: Ifa7c34b476111ecd33d4fd3ef5cc363a410ad76a
Reviewed-on: http://gerrit.cloudera.org:8080/5797
Reviewed-by: Dan Burkert <danburkert@apache.org>
Tested-by: Kudu Jenkins


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

Branch: refs/heads/master
Commit: 8a2ea8bddc88e8de60952b369f112b32710ee19b
Parents: dc85253
Author: Todd Lipcon <todd@apache.org>
Authored: Wed Jan 25 17:43:25 2017 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Thu Jan 26 02:59:55 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/8a2ea8bd/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/8a2ea8bd/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 8e0e13f..56c0e7b 100644
--- a/src/kudu/integration-tests/alter_table-test.cc
+++ b/src/kudu/integration-tests/alter_table-test.cc
@@ -1501,6 +1501,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


Mime
View raw message