mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
lwt: introduce cql_statment_opt_metadata
cql_statement_opt_metadata is an interim node in cql (prepared) statement hierarchy parenting modification_statement and batch_statement. If there is IF condition in such statements, they return a result set, and thus have a result set metadata. The metadata itself is filled in a subsequent patch.
This commit is contained in:
@@ -115,4 +115,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Conditional modification statements and batches
|
||||
// return a result set and have metadata, while same
|
||||
// statements without conditions do not.
|
||||
class cql_statement_opt_metadata : public cql_statement {
|
||||
protected:
|
||||
// Result set metadata, may be empty for simple updates and batches
|
||||
shared_ptr<metadata> _metadata;
|
||||
public:
|
||||
using cql_statement::cql_statement;
|
||||
virtual shared_ptr<const metadata> get_result_metadata() const override {
|
||||
if (_metadata) {
|
||||
return _metadata;
|
||||
}
|
||||
return make_empty_metadata();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ batch_statement::batch_statement(int bound_terms, type type_,
|
||||
std::vector<single_statement> statements,
|
||||
std::unique_ptr<attributes> attrs,
|
||||
cql_stats& stats)
|
||||
: cql_statement_no_metadata(timeout_for_type(type_))
|
||||
: cql_statement_opt_metadata(timeout_for_type(type_))
|
||||
, _bound_terms(bound_terms), _type(type_), _statements(std::move(statements))
|
||||
, _attrs(std::move(attrs))
|
||||
, _has_conditions(boost::algorithm::any_of(_statements, [] (auto&& s) { return s.statement->has_conditions(); }))
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace statements {
|
||||
* A <code>BATCH</code> statement parsed from a CQL query.
|
||||
*
|
||||
*/
|
||||
class batch_statement : public cql_statement_no_metadata {
|
||||
class batch_statement : public cql_statement_opt_metadata {
|
||||
static logging::logger _logger;
|
||||
public:
|
||||
using type = raw::batch_statement::type;
|
||||
|
||||
@@ -74,7 +74,7 @@ modification_statement_timeout(const schema& s) {
|
||||
}
|
||||
|
||||
modification_statement::modification_statement(statement_type type_, uint32_t bound_terms, schema_ptr schema_, std::unique_ptr<attributes> attrs_, cql_stats& stats)
|
||||
: cql_statement_no_metadata(modification_statement_timeout(*schema_))
|
||||
: cql_statement_opt_metadata(modification_statement_timeout(*schema_))
|
||||
, type{type_}
|
||||
, _bound_terms{bound_terms}
|
||||
, s{schema_}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace raw { class modification_statement; }
|
||||
/*
|
||||
* Abstract parent class of individual modifications, i.e. INSERT, UPDATE and DELETE.
|
||||
*/
|
||||
class modification_statement : public cql_statement_no_metadata {
|
||||
class modification_statement : public cql_statement_opt_metadata {
|
||||
private:
|
||||
static thread_local const ::shared_ptr<column_identifier> CAS_RESULT_COLUMN;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user