From 480200f0ea2fb908d08fc15f33f0e112e7d835b0 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 6 Jul 2015 10:07:20 +0300 Subject: [PATCH] cql3: Enable truncate statement grammar definition Truncate statement AST class is converted to C++ (although its functionality is unimplemented). Enable the CQL grammar definition so that users get an "not implemented" error instead of a syntax error. Signed-off-by: Pekka Enberg --- cql3/Cql.g | 9 +++++---- cql3/statements/truncate_statement.hh | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index a1166d2a0b..d85b92d41a 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -34,6 +34,7 @@ options { #include "cql3/statements/create_keyspace_statement.hh" #include "cql3/statements/create_table_statement.hh" #include "cql3/statements/property_definitions.hh" +#include "cql3/statements/truncate_statement.hh" #include "cql3/statements/select_statement.hh" #include "cql3/statements/update_statement.hh" #include "cql3/statements/delete_statement.hh" @@ -253,9 +254,7 @@ cqlStatement returns [shared_ptr stmt] | st4= batchStatement { $stmt = st4; } | st5= deleteStatement { $stmt = st5; } | st6= useStatement { $stmt = st6; } -#if 0 | st7= truncateStatement { $stmt = st7; } -#endif | st8= createKeyspaceStatement { $stmt = st8; } | st9= createTableStatement { $stmt = st9; } #if 0 @@ -839,14 +838,16 @@ dropIndexStatement returns [DropIndexStatement expr] : K_DROP K_INDEX (K_IF K_EXISTS { ifExists = true; } )? index=indexName { $expr = new DropIndexStatement(index, ifExists); } ; +#endif /** * TRUNCATE ; */ -truncateStatement returns [TruncateStatement stmt] - : K_TRUNCATE cf=columnFamilyName { $stmt = new TruncateStatement(cf); } +truncateStatement returns [::shared_ptr stmt] + : K_TRUNCATE cf=columnFamilyName { $stmt = ::make_shared(cf); } ; +#if 0 /** * GRANT ON TO */ diff --git a/cql3/statements/truncate_statement.hh b/cql3/statements/truncate_statement.hh index 49f1823e60..41eaedf67d 100644 --- a/cql3/statements/truncate_statement.hh +++ b/cql3/statements/truncate_statement.hh @@ -33,9 +33,9 @@ namespace cql3 { namespace statements { -class truncate_statement : public cf_statement, public virtual cql_statement, public ::enable_shared_from_this { +class truncate_statement : public cf_statement, public cql_statement, public ::enable_shared_from_this { public: - truncate_statement(::shared_ptr&& name) + truncate_statement(::shared_ptr name) : cf_statement{std::move(name)} { } @@ -47,6 +47,10 @@ public: return ::make_shared(this->shared_from_this()); } + virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override { + return parsed_statement::uses_function(ks_name, function_name); + } + virtual void check_access(const service::client_state& state) override { throw std::runtime_error("not implemented"); #if 0