New keyspace is added similarly as system_schema keyspace,
it's being registred via system_keyspace::make which calls
all_tables to build its schema.
Dummy table 'roles' is added as keyspaces are being currently
registered by walking through their tables. Full table schemas
will be added in subsequent commits.
Change can be observed via cqlsh:
cassandra@cqlsh> describe keyspaces;
system_auth_v2 system_schema system system_distributed_everywhere
system_auth system_distributed system_traces
cassandra@cqlsh> describe keyspace system_auth_v2;
CREATE KEYSPACE system_auth_v2 WITH replication = {'class': 'LocalStrategy'} AND durable_writes = true;
CREATE TABLE system_auth_v2.roles (
role text PRIMARY KEY
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
AND comment = 'comment'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.0
AND default_time_to_live = 0
AND gc_grace_seconds = 604800
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
67 lines
2.5 KiB
C++
67 lines
2.5 KiB
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <filesystem>
|
|
#include <seastar/core/future.hh>
|
|
|
|
#include "seastarx.hh"
|
|
#include "schema/schema.hh"
|
|
|
|
namespace db {
|
|
class config;
|
|
}
|
|
|
|
namespace tools {
|
|
|
|
/// Load the schema(s) from the specified string
|
|
///
|
|
/// The schema string is expected to contain everything that is needed to
|
|
/// create the table(s): keyspace, UDTs, etc. Definitions are expected to be
|
|
/// separated by `;`. A keyspace will be automatically generated if missing.
|
|
/// Tables whose name ends in "_scylla_cdc_log" are interpreted as CDC tables,
|
|
/// meaning they will be configured with the CDC partitioner.
|
|
/// Loading the schema(s) has no side-effect [1]. Nothing is written to disk,
|
|
/// it is all in memory, kept alive by the returned `schema_ptr`.
|
|
/// This is intended to be used by tools, which don't want to meddle with the
|
|
/// scylla home directory.
|
|
///
|
|
/// [1] Currently some global services has to be instantiated (snitch) to
|
|
/// be able to load the schema(s), these survive the call.
|
|
future<std::vector<schema_ptr>> load_schemas(const db::config& dbcfg, std::string_view schema_str);
|
|
|
|
/// Load exactly one schema from the specified path
|
|
///
|
|
/// If the file at the specified path contains more or less than one schema,
|
|
/// an exception will be thrown. See \ref load_schemas().
|
|
future<schema_ptr> load_one_schema_from_file(const db::config& dbcfg, std::filesystem::path path);
|
|
|
|
/// Load the system schema, with the given keyspace and table
|
|
///
|
|
/// Note that only schemas from builtin system tables are supported, i.e.,
|
|
/// from the following keyspaces:
|
|
/// * system
|
|
/// * system_auth_v2
|
|
/// * system_schema
|
|
/// * system_distributed
|
|
/// * system_distributed_everywhere
|
|
///
|
|
/// Any table from said keyspaces can be loaded. The keyspaces are created with
|
|
/// all schema and experimental features enabled.
|
|
schema_ptr load_system_schema(const db::config& dbcfg, std::string_view keyspace, std::string_view table);
|
|
|
|
/// Load the schema of the table with the designated keyspace and table name,
|
|
/// from the system schema table sstables.
|
|
///
|
|
/// The schema table sstables are accessed for read only. In general this method
|
|
/// tries very hard to have no side-effects.
|
|
/// The \p scylla_data_path parameter is expected to point to the scylla data
|
|
/// directory, which is usually /var/lib/scylla/data.
|
|
future<schema_ptr> load_schema_from_schema_tables(const db::config& dbcfg, std::filesystem::path scylla_data_path, std::string_view keyspace, std::string_view table);
|
|
|
|
} // namespace tools
|