Add to the schema object a member that points to the CDC schema object that is compatible with this schema, if any. The compatible CDC schema is created and altered with its base schema in the same group0 operation. When generating CDC log mutations for some base mutation we want them to be created using a compatible schema thas has a CDC column corresponding to each base column. This change will allow us to find the right CDC schema given a base mutation. We also update the relevant structures in the schema registry that are related to learning about schemas and transporting schemas across shards or nodes. When transporting a schema as frozen_schema, we need to transport the frozen cdc schema as well, and set it again when unfreezing and reconstructing the schema. When adding a schema to the registry, we need to ensure its CDC schema is added to the registry as well. Currently we always set the CDC schema to nullptr and maintain the previous behavior. We will change it in a later commit. Until then, we mark all places where CDC schema is passed clearly so we don't forget it.
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/*
|
|
* Copyright 2015-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "schema/schema_fwd.hh"
|
|
#include "mutation/frozen_mutation.hh"
|
|
#include "bytes_ostream.hh"
|
|
#include "db/view/base_info.hh"
|
|
|
|
namespace db {
|
|
class schema_ctxt;
|
|
}
|
|
|
|
// Transport for schema_ptr across shards/nodes.
|
|
// It's safe to access from another shard by const&.
|
|
class frozen_schema {
|
|
bytes_ostream _data;
|
|
public:
|
|
explicit frozen_schema(bytes_ostream);
|
|
frozen_schema(const schema_ptr&);
|
|
frozen_schema(frozen_schema&&) = default;
|
|
frozen_schema(const frozen_schema&) = default;
|
|
frozen_schema& operator=(const frozen_schema&) = default;
|
|
frozen_schema& operator=(frozen_schema&&) = default;
|
|
schema_ptr unfreeze(const db::schema_ctxt&, schema_ptr cdc_schema, std::optional<db::view::base_dependent_view_info> base_info = {}) const;
|
|
const bytes_ostream& representation() const;
|
|
};
|
|
|
|
// A frozen schema with additional information that is needed to be transported
|
|
// with it to be used for unfreezing it.
|
|
struct extended_frozen_schema {
|
|
extended_frozen_schema(const schema_ptr& c);
|
|
schema_ptr unfreeze(const db::schema_ctxt& ctxt) const;
|
|
|
|
frozen_schema fs;
|
|
std::optional<db::view::base_dependent_view_info> base_info; // Set only for views.
|
|
std::optional<frozen_schema> frozen_cdc_schema; // Set only for tables with CDC enabled.
|
|
};
|