From 1cac0c7b31a80dcd2687899d609347223e71e64b Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 5 Jun 2015 12:26:39 +0300 Subject: [PATCH 1/3] db/legacy_schema_tables: Fix read_schema_for_keyspaces() Fix the check in read_schema_for_keyspaces() to not insert empty result sets in the return value. There's no functional change as the merge algorithms already deal with the case. However, the code is now closer to what origin does. Spotted while reading the code. Signed-off-by: Pekka Enberg --- db/legacy_schema_tables.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 1cc65aaa2a..6531c30183 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -403,7 +403,7 @@ std::vector ALL { KEYSPACES, COLUMNFAMILIES, COLUMNS, TRIGGERS, USE auto schema = proxy.get_db().local().find_schema(system_keyspace::NAME, schema_table_name); auto map = [&proxy, schema_table_name] (sstring keyspace_name) { return read_schema_partition_for_keyspace(proxy, schema_table_name, keyspace_name); }; auto insert = [] (schema_result&& result, auto&& schema_entity) { - if (schema_entity.second) { + if (!schema_entity.second->empty()) { result.insert(std::move(schema_entity)); } return std::move(result); From 647d95d17063526661d3e11505c8db8daf022462 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 5 Jun 2015 12:44:23 +0300 Subject: [PATCH 2/3] types: Fix operator== for data_value We must compare types with ->equal(). Fixes keyspace merging issues where the merging code mistakenly thinks two keyspaces are different and calls the alter keyspace path which is not implemented. Signed-off-by: Pekka Enberg --- types.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types.hh b/types.hh index d990fa0584..e7b19710df 100644 --- a/types.hh +++ b/types.hh @@ -308,7 +308,7 @@ public: inline bool operator==(const data_value& x, const data_value& y) { - return x._type == y._type && x._type->equal(x._type->decompose(x._value), y._type->decompose(y._value)); + return x._type->equals(y._type) && x._type->equal(x._type->decompose(x._value), y._type->decompose(y._value)); } inline bool operator!=(const data_value& x, const data_value& y) From ee3dbcd294ba6bc5a571e9b874ac62b30ddea61d Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 28 May 2015 15:45:35 +0300 Subject: [PATCH 3/3] query-result-set: Add operator<< for result sets Add operator<< for result sets to make debugging schema merging code issues easier. Signed-off-by: Pekka Enberg --- query-result-set.cc | 16 ++++++++++++++++ query-result-set.hh | 2 ++ 2 files changed, 18 insertions(+) diff --git a/query-result-set.cc b/query-result-set.cc index 04d173bb22..0e62fb6ddc 100644 --- a/query-result-set.cc +++ b/query-result-set.cc @@ -6,6 +6,22 @@ namespace query { +std::ostream& operator<<(std::ostream& out, const result_set_row& row) { + for (auto&& cell : row._cells) { + auto&& type = cell.second.type(); + auto&& value = cell.second.value(); + out << cell.first << "=\"" << type->decompose(value) << "\" "; + } + return out; +} + +std::ostream& operator<<(std::ostream& out, const result_set& rs) { + for (auto&& row : rs._rows) { + out << row << std::endl; + } + return out; +} + result_set_builder::result_set_builder(schema_ptr schema) : _schema{schema} { } diff --git a/query-result-set.hh b/query-result-set.hh index b06dc9e328..8ba8835fb3 100644 --- a/query-result-set.hh +++ b/query-result-set.hh @@ -59,6 +59,7 @@ public: } friend inline bool operator==(const result_set_row& x, const result_set_row& y); friend inline bool operator!=(const result_set_row& x, const result_set_row& y); + friend std::ostream& operator<<(std::ostream& out, const result_set_row& row); }; inline bool operator==(const result_set_row& x, const result_set_row& y) { @@ -88,6 +89,7 @@ public: return _rows[idx]; } friend inline bool operator==(const result_set& x, const result_set& y); + friend std::ostream& operator<<(std::ostream& out, const result_set& rs); }; inline bool operator==(const result_set& x, const result_set& y) {