Skip to content

Commit

Permalink
schema::describe: print 'synchronous_updates' only if it was specified
Browse files Browse the repository at this point in the history
While describing materialized view, print `synchronous_updates` option
only if the tag is present in schema's extensions map. Previously if the
key wasn't present, the default (false) value was printed.

Fixes: scylladb#14924
  • Loading branch information
Jadw1 committed Aug 2, 2023
1 parent 6c66030 commit 3a7db87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 6 additions & 8 deletions schema/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,8 @@ static bool is_index(replica::database& db, const table_id& id, const schema& s)
return db.find_column_family(id).get_index_manager().is_index(s);
}

static bool is_update_synchronously_view(const schema& s) {
auto tag_opt = db::find_tag(s, db::SYNCHRONOUS_VIEW_UPDATES_TAG_KEY);
if (!tag_opt.has_value()) {
return false;
}

return *tag_opt == "true";
static std::optional<std::string> is_update_synchronously_view(const schema& s) {
return db::find_tag(s, db::SYNCHRONOUS_VIEW_UPDATES_TAG_KEY);
}

sstring schema::element_type(replica::database& db) const {
Expand Down Expand Up @@ -949,7 +944,10 @@ std::ostream& schema::describe(replica::database& db, std::ostream& os, bool wit
os << "\n AND cdc = " << cdc_options().to_sstring();
}
if (is_view() && !is_index(db, view_info()->base_id(), *this)) {
os << "\n AND synchronous_updates = " << std::boolalpha << is_update_synchronously_view(*this);
auto is_sync_update = is_update_synchronously_view(*this);
if (is_sync_update.has_value()) {
os << "\n AND synchronous_updates = " << *is_sync_update;
}
}
os << ";\n";

Expand Down
3 changes: 1 addition & 2 deletions test/boost/cql_query_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4335,8 +4335,7 @@ SEASTAR_TEST_CASE(test_describe_view_schema) {
" AND read_repair_chance = 0\n"
" AND speculative_retry = '99.0PERCENTILE'\n"
" AND paxos_grace_seconds = 43200\n"
" AND tombstone_gc = {'mode':'timeout','propagation_delay_in_seconds':'3600'}\n"
" AND synchronous_updates = false;\n"},
" AND tombstone_gc = {'mode':'timeout','propagation_delay_in_seconds':'3600'};\n"},
{"cf_index_index", "CREATE INDEX cf_index ON \"KS\".\"cF\"(col2);"},
{"cf_index1_index", "CREATE INDEX cf_index1 ON \"KS\".\"cF\"(pk);"},
{"cf_index2_index", "CREATE INDEX cf_index2 ON \"KS\".\"cF\"(pk1);"},
Expand Down

0 comments on commit 3a7db87

Please sign in to comment.