cql3: return raw::parsed_statement as unique_ptr

Change CQL parsing routine to return std::unique_ptr
instead of seastar::shared_ptr.

This can help reduce redundant shared_ptr copies even further.

Make some supplementary changes necessary for this transition:
 * Remove enabled_shared_from_this base class from the following
   classes: truncate_statement, authorization_statement,
   authentication_statement: these were previously constructing
   prepared_statement instance in `prepare` method using
   `shared_from_this`.
   Make `prepare` methods implementation of inheriting classes
   mirror implementation from other statements (i.e.
   create a shallow copy of the object when prepairing into
   `prepared_statement`; this could be further refactored
   to avoid copies as much as possible).
 * Remove unused fields in create_role_statement which led to
   error while using compiler-generated copy ctor (copying
   uninitialied bool values via ctor).

Signed-off-by: Pavel Solodovnikov <pa.solodovnikov@scylladb.com>
This commit is contained in:
Pavel Solodovnikov
2020-03-22 21:54:50 +03:00
parent df1d687fc6
commit adc6a98b59
31 changed files with 216 additions and 162 deletions

View File

@@ -84,7 +84,7 @@ view_info::view_info(const schema& schema, const raw_view_info& raw_view_info)
cql3::statements::select_statement& view_info::select_statement() const {
if (!_select_statement) {
shared_ptr<cql3::statements::raw::select_statement> raw;
std::unique_ptr<cql3::statements::raw::select_statement> raw;
// FIXME(sarna): legacy code, should be removed after "computed_columns" feature is guaranteed
// to be available on every node. Then, we won't need to check if this view is backing a secondary index.
const column_definition* legacy_token_column = nullptr;