mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-27 20:05:10 +00:00
Metadata id was introduced in CQLv5 to make metadata of prepared statement consistent between driver and database. This commit introduces a protocol extension that allows to use the same mechanism in CQLv4. This change: - Introduce SCYLLA_USE_METADATA_ID protocol extension for CQLv4 - Introduce METADATA_CHANGED flag in RESULT. The flag cames directly from CQLv5 binary protocol. In CQLv4, the bit was never used, so we assume it is safe to reuse it. - Implement handling of metadata_id and METADATA_CHANGED in RESULT rows - Implement returning metadata_id in RESULT prepared - Implement reading metadata_id from EXECUTE - Added description of SCYLLA_USE_METADATA_ID in documentation Metadata_id is wrapped in cql_metadata_id_wrapper because we need to distinguish the following situations: - Metadata_id is not supported by the protocol (e.g. CQLv4 without the extension is used) - Metadata_id is supported by the protocol but not set - e.g. PREPARE query is being handled: it doesn't contain metadata_id in the request but the reply (RESULT prepared) must contain metadata_id - Metadata_id is supported by the protocol and set, any number of bytes >= 0 is allowed, according to the CQLv5 protocol specification Fixes scylladb/scylladb#20860
58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
/*
|
|
* Copyright 2020-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
#pragma once
|
|
|
|
#include <seastar/core/sstring.hh>
|
|
#include "enum_set.hh"
|
|
|
|
namespace cql_transport {
|
|
|
|
/**
|
|
* CQL Protocol extensions. They can be viewed as an opportunity to provide
|
|
* some vendor-specific extensions to the CQL protocol without changing
|
|
* the version of the protocol itself (i.e. when the changes introduced by
|
|
* extensions are binary-compatible with the current version of the protocol).
|
|
*
|
|
* Extensions are meant to be passed between client and server in terms of
|
|
* SUPPORTED/STARTUP messages in order to negotiate compatible set of features
|
|
* to be used in a connection.
|
|
*
|
|
* The negotiation procedure and extensions themselves are documented in the
|
|
* `docs/dev/protocol-extensions.md`.
|
|
*/
|
|
enum class cql_protocol_extension {
|
|
LWT_ADD_METADATA_MARK,
|
|
RATE_LIMIT_ERROR,
|
|
TABLETS_ROUTING_V1,
|
|
USE_METADATA_ID
|
|
};
|
|
|
|
using cql_protocol_extension_enum = super_enum<cql_protocol_extension,
|
|
cql_protocol_extension::LWT_ADD_METADATA_MARK,
|
|
cql_protocol_extension::RATE_LIMIT_ERROR,
|
|
cql_protocol_extension::TABLETS_ROUTING_V1,
|
|
cql_protocol_extension::USE_METADATA_ID>;
|
|
|
|
using cql_protocol_extension_enum_set = enum_set<cql_protocol_extension_enum>;
|
|
|
|
cql_protocol_extension_enum_set supported_cql_protocol_extensions();
|
|
|
|
/**
|
|
* Returns the name of extension to be used in SUPPORTED/STARTUP feature negotiation.
|
|
*/
|
|
const seastar::sstring& protocol_extension_name(cql_protocol_extension ext);
|
|
|
|
/**
|
|
* Returns a list of additional key-value pairs (in the form of "ARG=VALUE" string)
|
|
* that belong to a particular extension and provide some additional capabilities
|
|
* to be used by the client driver in order to support this extension.
|
|
*/
|
|
std::vector<seastar::sstring> additional_options_for_proto_ext(cql_protocol_extension ext);
|
|
|
|
} // namespace cql_transport
|