diff options
author | ilnaz <ilnaz@ydb.tech> | 2023-05-15 19:16:36 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2023-05-15 19:16:36 +0300 |
commit | 0ac676ac096493cfaf247dac20414e08560ab5c4 (patch) | |
tree | 8d48d88829c686aa7953dbdd6c6aaf1c10bc787d | |
parent | 629d082bd9c44a67a8efd93fd89b95142f49ea2c (diff) | |
download | ydb-0ac676ac096493cfaf247dac20414e08560ab5c4.tar.gz |
Check RequestType of DDL requests
31 files changed, 212 insertions, 36 deletions
diff --git a/ydb/core/CMakeLists.txt b/ydb/core/CMakeLists.txt index 38f1966ea59..6f3ca338f1b 100644 --- a/ydb/core/CMakeLists.txt +++ b/ydb/core/CMakeLists.txt @@ -18,6 +18,7 @@ add_subdirectory(control) add_subdirectory(debug) add_subdirectory(debug_tools) add_subdirectory(discovery) +add_subdirectory(docapi) add_subdirectory(driver_lib) add_subdirectory(engine) add_subdirectory(erasure) diff --git a/ydb/core/docapi/CMakeLists.darwin-x86_64.txt b/ydb/core/docapi/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..b145759320c --- /dev/null +++ b/ydb/core/docapi/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(ydb-core-docapi) +target_compile_options(ydb-core-docapi PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(ydb-core-docapi PUBLIC + contrib-libs-cxxsupp + yutil +) +target_sources(ydb-core-docapi PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/docapi/traits.cpp +) diff --git a/ydb/core/docapi/CMakeLists.linux-aarch64.txt b/ydb/core/docapi/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..47a78dfe5eb --- /dev/null +++ b/ydb/core/docapi/CMakeLists.linux-aarch64.txt @@ -0,0 +1,21 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(ydb-core-docapi) +target_compile_options(ydb-core-docapi PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(ydb-core-docapi PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil +) +target_sources(ydb-core-docapi PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/docapi/traits.cpp +) diff --git a/ydb/core/docapi/CMakeLists.linux-x86_64.txt b/ydb/core/docapi/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..47a78dfe5eb --- /dev/null +++ b/ydb/core/docapi/CMakeLists.linux-x86_64.txt @@ -0,0 +1,21 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(ydb-core-docapi) +target_compile_options(ydb-core-docapi PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(ydb-core-docapi PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil +) +target_sources(ydb-core-docapi PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/docapi/traits.cpp +) diff --git a/ydb/core/docapi/CMakeLists.txt b/ydb/core/docapi/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/ydb/core/docapi/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/ydb/core/docapi/CMakeLists.windows-x86_64.txt b/ydb/core/docapi/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..b145759320c --- /dev/null +++ b/ydb/core/docapi/CMakeLists.windows-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(ydb-core-docapi) +target_compile_options(ydb-core-docapi PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(ydb-core-docapi PUBLIC + contrib-libs-cxxsupp + yutil +) +target_sources(ydb-core-docapi PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/docapi/traits.cpp +) diff --git a/ydb/core/docapi/traits.cpp b/ydb/core/docapi/traits.cpp new file mode 100644 index 00000000000..38a6e8cebf4 --- /dev/null +++ b/ydb/core/docapi/traits.cpp @@ -0,0 +1,8 @@ +#include "traits.h" + +namespace NKikimr::NDocApi { + +const TStringBuf RequestType = "_document_api_request"; +const TStringBuf VersionAttribute = "__document_api_version"; + +} diff --git a/ydb/core/docapi/traits.h b/ydb/core/docapi/traits.h new file mode 100644 index 00000000000..843b7b86e77 --- /dev/null +++ b/ydb/core/docapi/traits.h @@ -0,0 +1,10 @@ +#pragma once + +#include <util/generic/strbuf.h> + +namespace NKikimr::NDocApi { + +extern const TStringBuf RequestType; +extern const TStringBuf VersionAttribute; + +} diff --git a/ydb/core/grpc_services/local_rpc/local_rpc.h b/ydb/core/grpc_services/local_rpc/local_rpc.h index 9f1be767a81..fd90c59ed06 100644 --- a/ydb/core/grpc_services/local_rpc/local_rpc.h +++ b/ydb/core/grpc_services/local_rpc/local_rpc.h @@ -30,10 +30,15 @@ class TLocalRpcCtx : public NGRpcService::IRequestOpCtx { public: using TResp = typename TRpc::TResponse; template<typename TProto, typename TCb> - TLocalRpcCtx(TProto&& req, TCb&& cb, const TString& databaseName, const TMaybe<TString>& token, bool internalCall) + TLocalRpcCtx(TProto&& req, TCb&& cb, + const TString& databaseName, + const TMaybe<TString>& token, + const TMaybe<TString>& requestType, + bool internalCall) : Request(std::forward<TProto>(req)) , CbWrapper(std::forward<TCb>(cb)) , DatabaseName(databaseName) + , RequestType(requestType) , InternalCall(internalCall) { if (token) { @@ -191,7 +196,7 @@ public: } const TMaybe<TString> GetRequestType() const override { - return Nothing(); + return RequestType; } void SetCostInfo(float consumed_units) override { @@ -229,6 +234,7 @@ private: typename TRpc::TRequest Request; TCbWrapper CbWrapper; const TString DatabaseName; + const TMaybe<TString> RequestType; const bool InternalCall; TIntrusiveConstPtr<NACLib::TUserToken> InternalToken; const TString EmptySerializedTokenMessage_; @@ -240,13 +246,16 @@ private: }; template<typename TRpc> -NThreading::TFuture<typename TRpc::TResponse> DoLocalRpc(typename TRpc::TRequest&& proto, const TString& database, const TMaybe<TString>& token, TActorSystem* actorSystem, bool internalCall = false) { +NThreading::TFuture<typename TRpc::TResponse> DoLocalRpc(typename TRpc::TRequest&& proto, const TString& database, + const TMaybe<TString>& token, const TMaybe<TString>& requestType, + TActorSystem* actorSystem, bool internalCall = false) +{ auto promise = NThreading::NewPromise<typename TRpc::TResponse>(); proto.mutable_operation_params()->set_operation_mode(Ydb::Operations::OperationParams::SYNC); using TCbWrapper = TPromiseWrapper<typename TRpc::TResponse>; - auto req = new TLocalRpcCtx<TRpc, TCbWrapper>(std::move(proto), TCbWrapper(promise), database, token, internalCall); + auto req = new TLocalRpcCtx<TRpc, TCbWrapper>(std::move(proto), TCbWrapper(promise), database, token, requestType, internalCall); auto actor = TRpc::CreateRpcActor(req); actorSystem->Register(actor, TMailboxType::HTSwap, actorSystem->AppData<TAppData>()->UserPoolId); @@ -254,13 +263,26 @@ NThreading::TFuture<typename TRpc::TResponse> DoLocalRpc(typename TRpc::TRequest } template<typename TRpc> -TActorId DoLocalRpcSameMailbox(typename TRpc::TRequest&& proto, std::function<void(typename TRpc::TResponse)>&& cb, const TString& database, const TMaybe<TString>& token, const TActorContext& ctx, bool internalCall = false) { +NThreading::TFuture<typename TRpc::TResponse> DoLocalRpc(typename TRpc::TRequest&& proto, const TString& database, const TMaybe<TString>& token, TActorSystem* actorSystem, bool internalCall = false) { + return DoLocalRpc<TRpc>(std::move(proto), database, token, Nothing(), actorSystem, internalCall); +} + +template<typename TRpc> +TActorId DoLocalRpcSameMailbox(typename TRpc::TRequest&& proto, std::function<void(typename TRpc::TResponse)>&& cb, + const TString& database, const TMaybe<TString>& token, const TMaybe<TString>& requestType, + const TActorContext& ctx, bool internalCall = false) +{ proto.mutable_operation_params()->set_operation_mode(Ydb::Operations::OperationParams::SYNC); - auto req = new TLocalRpcCtx<TRpc, std::function<void(typename TRpc::TResponse)>>(std::move(proto), std::move(cb), database, token, internalCall); + auto req = new TLocalRpcCtx<TRpc, std::function<void(typename TRpc::TResponse)>>(std::move(proto), std::move(cb), database, token, requestType, internalCall); auto actor = TRpc::CreateRpcActor(req); return ctx.RegisterWithSameMailbox(actor); } +template<typename TRpc> +TActorId DoLocalRpcSameMailbox(typename TRpc::TRequest&& proto, std::function<void(typename TRpc::TResponse)>&& cb, const TString& database, const TMaybe<TString>& token, const TActorContext& ctx, bool internalCall = false) { + return DoLocalRpcSameMailbox<TRpc>(std::move(proto), std::move(cb), database, token, Nothing(), ctx, internalCall); +} + } // namespace NRpcService } // namespace NKikimr diff --git a/ydb/core/kqp/gateway/kqp_ic_gateway.cpp b/ydb/core/kqp/gateway/kqp_ic_gateway.cpp index 2116f56f1b8..b51fbe1f61d 100644 --- a/ydb/core/kqp/gateway/kqp_ic_gateway.cpp +++ b/ydb/core/kqp/gateway/kqp_ic_gateway.cpp @@ -1006,7 +1006,7 @@ public: } } - TFuture<TGenericResult> AlterTable(Ydb::Table::AlterTableRequest&& req, const TString& cluster) override { + TFuture<TGenericResult> AlterTable(const TString& cluster, Ydb::Table::AlterTableRequest&& req, const TMaybe<TString>& requestType) override { try { if (!CheckCluster(cluster)) { return InvalidCluster<TGenericResult>(cluster); @@ -1017,7 +1017,7 @@ public: using TEvAlterTableRequest = TGrpcRequestOperationCall<Ydb::Table::AlterTableRequest, Ydb::Table::AlterTableResponse>; - return SendLocalRpcRequestNoResult<TEvAlterTableRequest>(std::move(req), Database, GetTokenCompat()); + return SendLocalRpcRequestNoResult<TEvAlterTableRequest>(std::move(req), Database, GetTokenCompat(), requestType); } catch (yexception& e) { return MakeFuture(ResultFromException<TGenericResult>(e)); @@ -2170,8 +2170,8 @@ private: } template<typename TRpc> - TFuture<TGenericResult> SendLocalRpcRequestNoResult(typename TRpc::TRequest&& proto, const TString& databse, const TString& token) { - return NRpcService::DoLocalRpc<TRpc>(std::move(proto), databse, token, ActorSystem).Apply([](NThreading::TFuture<typename TRpc::TResponse> future) { + TFuture<TGenericResult> SendLocalRpcRequestNoResult(typename TRpc::TRequest&& proto, const TString& databse, const TString& token, const TMaybe<TString>& requestType = {}) { + return NRpcService::DoLocalRpc<TRpc>(std::move(proto), databse, token, requestType, ActorSystem).Apply([](NThreading::TFuture<typename TRpc::TResponse> future) { auto r = future.ExtractValue(); NYql::TIssues issues; NYql::IssuesFromMessage(r.operation().issues(), issues); diff --git a/ydb/core/kqp/host/kqp_host.cpp b/ydb/core/kqp/host/kqp_host.cpp index d1ffbe79c96..5c1caadea31 100644 --- a/ydb/core/kqp/host/kqp_host.cpp +++ b/ydb/core/kqp/host/kqp_host.cpp @@ -911,17 +911,17 @@ public: SessionCtx->SetDatabase(database); } - IAsyncQueryResultPtr ExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql) override { + IAsyncQueryResultPtr ExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql, const TExecSettings& settings) override { return CheckedProcessQuery(*ExprCtx, - [this, &query, isSql] (TExprContext& ctx) { - return ExecuteSchemeQueryInternal(query, isSql, ctx); + [this, &query, isSql, settings] (TExprContext& ctx) { + return ExecuteSchemeQueryInternal(query, isSql, settings, ctx); }); } - TQueryResult SyncExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql) override { + TQueryResult SyncExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql, const TExecSettings& settings) override { return CheckedSyncProcessQuery( - [this, &query, isSql] () { - return ExecuteSchemeQuery(query, isSql); + [this, &query, isSql, settings] () { + return ExecuteSchemeQuery(query, isSql, settings); }); } @@ -1217,9 +1217,13 @@ private: return true; } - IAsyncQueryResultPtr ExecuteSchemeQueryInternal(const TKqpQueryRef& query, bool isSql, TExprContext& ctx) { + IAsyncQueryResultPtr ExecuteSchemeQueryInternal(const TKqpQueryRef& query, bool isSql, const TExecSettings& settings, TExprContext& ctx) { SetupYqlTransformer(EKikimrQueryType::Ddl); + if (settings.DocumentApiRestricted) { + SessionCtx->Query().DocumentApiRestricted = *settings.DocumentApiRestricted; + } + TMaybe<TSqlVersion> sqlVersion; auto queryExpr = CompileYqlQuery(query, isSql, false, ctx, sqlVersion); if (!queryExpr) { diff --git a/ydb/core/kqp/host/kqp_host.h b/ydb/core/kqp/host/kqp_host.h index 6c1b2344e1e..5c1cf64438c 100644 --- a/ydb/core/kqp/host/kqp_host.h +++ b/ydb/core/kqp/host/kqp_host.h @@ -19,8 +19,15 @@ public: using IAsyncGenericResult = NYql::IKikimrAsyncResult<TGenericResult>; using IAsyncGenericResultPtr = TIntrusivePtr<IAsyncGenericResult>; - struct TPrepareSettings { + struct TExecSettings { TMaybe<bool> DocumentApiRestricted; + + TString ToString() const { + return TStringBuilder() << "TExecSettings{ DocumentApiRestricted: " << DocumentApiRestricted << " }"; + } + }; + + struct TPrepareSettings: public TExecSettings { TMaybe<bool> IsInternalCall; TString ToString() const { @@ -45,8 +52,8 @@ public: virtual TQueryResult SyncPrepareDataQuery(const TKqpQueryRef& query, const TPrepareSettings& settings) = 0; /* Scheme queries */ - virtual IAsyncQueryResultPtr ExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql) = 0; - virtual TQueryResult SyncExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql) = 0; + virtual IAsyncQueryResultPtr ExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql, const TExecSettings& settings) = 0; + virtual TQueryResult SyncExecuteSchemeQuery(const TKqpQueryRef& query, bool isSql, const TExecSettings& settings) = 0; /* Scan queries */ virtual IAsyncQueryResultPtr PrepareScanQuery(const TKqpQueryRef& query, bool isSql, const TPrepareSettings& settings) = 0; diff --git a/ydb/core/kqp/provider/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/provider/CMakeLists.darwin-x86_64.txt index d9ee58782fc..d78b2eaf38f 100644 --- a/ydb/core/kqp/provider/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/kqp/provider/CMakeLists.darwin-x86_64.txt @@ -24,6 +24,7 @@ target_link_libraries(core-kqp-provider PUBLIC yutil ydb-core-base ydb-core-protos + ydb-core-docapi core-kqp-query_data ydb-library-aclib library-aclib-protos diff --git a/ydb/core/kqp/provider/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/provider/CMakeLists.linux-aarch64.txt index bd624ef617c..d8cfb2499f9 100644 --- a/ydb/core/kqp/provider/CMakeLists.linux-aarch64.txt +++ b/ydb/core/kqp/provider/CMakeLists.linux-aarch64.txt @@ -25,6 +25,7 @@ target_link_libraries(core-kqp-provider PUBLIC yutil ydb-core-base ydb-core-protos + ydb-core-docapi core-kqp-query_data ydb-library-aclib library-aclib-protos diff --git a/ydb/core/kqp/provider/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/provider/CMakeLists.linux-x86_64.txt index bd624ef617c..d8cfb2499f9 100644 --- a/ydb/core/kqp/provider/CMakeLists.linux-x86_64.txt +++ b/ydb/core/kqp/provider/CMakeLists.linux-x86_64.txt @@ -25,6 +25,7 @@ target_link_libraries(core-kqp-provider PUBLIC yutil ydb-core-base ydb-core-protos + ydb-core-docapi core-kqp-query_data ydb-library-aclib library-aclib-protos diff --git a/ydb/core/kqp/provider/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/provider/CMakeLists.windows-x86_64.txt index d9ee58782fc..d78b2eaf38f 100644 --- a/ydb/core/kqp/provider/CMakeLists.windows-x86_64.txt +++ b/ydb/core/kqp/provider/CMakeLists.windows-x86_64.txt @@ -24,6 +24,7 @@ target_link_libraries(core-kqp-provider PUBLIC yutil ydb-core-base ydb-core-protos + ydb-core-docapi core-kqp-query_data ydb-library-aclib library-aclib-protos diff --git a/ydb/core/kqp/provider/yql_kikimr_exec.cpp b/ydb/core/kqp/provider/yql_kikimr_exec.cpp index 8d600788400..cf375c146c4 100644 --- a/ydb/core/kqp/provider/yql_kikimr_exec.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_exec.cpp @@ -1,5 +1,7 @@ #include "yql_kikimr_provider_impl.h" +#include <ydb/core/docapi/traits.h> + #include <ydb/library/yql/utils/log/log.h> #include <ydb/library/yql/core/yql_execution.h> #include <ydb/library/yql/core/yql_graph_transformer.h> @@ -1383,7 +1385,11 @@ public: } else if (isColumn) { future = Gateway->AlterColumnTable(cluster, ParseAlterColumnTableSettings(maybeAlter.Cast())); } else { - future = Gateway->AlterTable(std::move(alterTableRequest), cluster); + TMaybe<TString> requestType; + if (!SessionCtx->Query().DocumentApiRestricted) { + requestType = NKikimr::NDocApi::RequestType; + } + future = Gateway->AlterTable(cluster, std::move(alterTableRequest), requestType); } } diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.h b/ydb/core/kqp/provider/yql_kikimr_gateway.h index 11109ee9f45..99004025067 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.h +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.h @@ -687,7 +687,7 @@ public: virtual NThreading::TFuture<TGenericResult> CreateTable(TKikimrTableMetadataPtr metadata, bool createDir) = 0; - virtual NThreading::TFuture<TGenericResult> AlterTable(Ydb::Table::AlterTableRequest&& req, const TString& cluster) = 0; + virtual NThreading::TFuture<TGenericResult> AlterTable(const TString& cluster, Ydb::Table::AlterTableRequest&& req, const TMaybe<TString>& requestType) = 0; virtual NThreading::TFuture<TGenericResult> RenameTable(const TString& src, const TString& dst, const TString& cluster) = 0; diff --git a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp index 52a028da307..879607286e9 100644 --- a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp @@ -1,5 +1,7 @@ #include "yql_kikimr_provider_impl.h" +#include <ydb/core/docapi/traits.h> + #include <ydb/library/yql/core/type_ann/type_ann_impl.h> #include <ydb/library/yql/core/type_ann/type_ann_list.h> #include <ydb/library/yql/core/yql_expr_optimize.h> @@ -17,8 +19,6 @@ namespace { using namespace NCommon; using namespace NNodes; -const TString DocApiTableVersionAttribute = "__document_api_version"; - const TTypeAnnotationNode* GetExpectedRowType(const TKikimrTableDescription& tableDesc, const TVector<TString>& columns, const TPosition& pos, TExprContext& ctx) { @@ -1533,7 +1533,7 @@ virtual TStatus HandleCreateTable(TKiCreateTable create, TExprContext& ctx) over return true; } - if (!meta.Attributes.FindPtr(DocApiTableVersionAttribute)) { + if (!meta.Attributes.FindPtr(NKikimr::NDocApi::VersionAttribute)) { return true; } diff --git a/ydb/core/kqp/session_actor/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/session_actor/CMakeLists.darwin-x86_64.txt index 3b2e287ad0f..e84e1c47462 100644 --- a/ydb/core/kqp/session_actor/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/kqp/session_actor/CMakeLists.darwin-x86_64.txt @@ -14,6 +14,7 @@ target_compile_options(core-kqp-session_actor PRIVATE target_link_libraries(core-kqp-session_actor PUBLIC contrib-libs-cxxsupp yutil + ydb-core-docapi core-kqp-common providers-common-http_gateway ) diff --git a/ydb/core/kqp/session_actor/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/session_actor/CMakeLists.linux-aarch64.txt index 88931dbd4f6..9f9420485ef 100644 --- a/ydb/core/kqp/session_actor/CMakeLists.linux-aarch64.txt +++ b/ydb/core/kqp/session_actor/CMakeLists.linux-aarch64.txt @@ -15,6 +15,7 @@ target_link_libraries(core-kqp-session_actor PUBLIC contrib-libs-linux-headers contrib-libs-cxxsupp yutil + ydb-core-docapi core-kqp-common providers-common-http_gateway ) diff --git a/ydb/core/kqp/session_actor/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/session_actor/CMakeLists.linux-x86_64.txt index 88931dbd4f6..9f9420485ef 100644 --- a/ydb/core/kqp/session_actor/CMakeLists.linux-x86_64.txt +++ b/ydb/core/kqp/session_actor/CMakeLists.linux-x86_64.txt @@ -15,6 +15,7 @@ target_link_libraries(core-kqp-session_actor PUBLIC contrib-libs-linux-headers contrib-libs-cxxsupp yutil + ydb-core-docapi core-kqp-common providers-common-http_gateway ) diff --git a/ydb/core/kqp/session_actor/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/session_actor/CMakeLists.windows-x86_64.txt index 3b2e287ad0f..e84e1c47462 100644 --- a/ydb/core/kqp/session_actor/CMakeLists.windows-x86_64.txt +++ b/ydb/core/kqp/session_actor/CMakeLists.windows-x86_64.txt @@ -14,6 +14,7 @@ target_compile_options(core-kqp-session_actor PRIVATE target_link_libraries(core-kqp-session_actor PUBLIC contrib-libs-cxxsupp yutil + ydb-core-docapi core-kqp-common providers-common-http_gateway ) diff --git a/ydb/core/kqp/session_actor/kqp_worker_actor.cpp b/ydb/core/kqp/session_actor/kqp_worker_actor.cpp index 40a3c0d2b4b..8f20984b4e0 100644 --- a/ydb/core/kqp/session_actor/kqp_worker_actor.cpp +++ b/ydb/core/kqp/session_actor/kqp_worker_actor.cpp @@ -572,7 +572,9 @@ private: switch (type) { case NKikimrKqp::QUERY_TYPE_SQL_DDL: { - QueryState->AsyncQueryResult = KqpHost->ExecuteSchemeQuery(query, true); + IKqpHost::TExecSettings execSettings; + execSettings.DocumentApiRestricted = IsDocumentApiRestricted(QueryState->RequestEv->GetRequestType()); + QueryState->AsyncQueryResult = KqpHost->ExecuteSchemeQuery(query, true, execSettings); break; } diff --git a/ydb/core/kqp/session_actor/kqp_worker_common.h b/ydb/core/kqp/session_actor/kqp_worker_common.h index 481fa2ce896..545a082583a 100644 --- a/ydb/core/kqp/session_actor/kqp_worker_common.h +++ b/ydb/core/kqp/session_actor/kqp_worker_common.h @@ -2,6 +2,7 @@ #include "kqp_session_actor.h" +#include <ydb/core/docapi/traits.h> #include <ydb/core/kqp/common/kqp.h> #include <ydb/core/kqp/provider/yql_kikimr_gateway.h> #include <ydb/core/kqp/provider/yql_kikimr_provider.h> @@ -132,7 +133,7 @@ void SlowLogQuery(const TActorContext &ctx, const NYql::TKikimrConfiguration* co NYql::TKikimrQueryLimits GetQueryLimits(const TKqpWorkerSettings& settings); inline bool IsDocumentApiRestricted(const TString& requestType) { - return requestType != "_document_api_request"sv; + return requestType != NDocApi::RequestType; } TMaybe<Ydb::StatusIds::StatusCode> GetYdbStatus(const NYql::TIssue& issue); diff --git a/ydb/core/kqp/ut/service/kqp_document_api_ut.cpp b/ydb/core/kqp/ut/service/kqp_document_api_ut.cpp index b08192a1a64..db5bfaa6f33 100644 --- a/ydb/core/kqp/ut/service/kqp_document_api_ut.cpp +++ b/ydb/core/kqp/ut/service/kqp_document_api_ut.cpp @@ -115,10 +115,16 @@ Y_UNIT_TEST_SUITE(KqpDocumentApi) { ALTER TABLE `/Root/DocumentApiTest` DROP COLUMN Value; )"; - auto result = session.ExecuteSchemeQuery(query).ExtractValueSync(); - result.GetIssues().PrintTo(Cerr); - UNIT_ASSERT(!result.IsSuccess()); - UNIT_ASSERT(HasIssue(result.GetIssues(), NYql::TIssuesIds::KIKIMR_BAD_OPERATION)); + const auto tests = TVector<std::pair<TExecSchemeQuerySettings, bool>>{ + {TExecSchemeQuerySettings(), false}, + {TExecSchemeQuerySettings().RequestType("_document_api_request"), true}, + }; + + for (const auto& [settings, success] : tests) { + auto result = session.ExecuteSchemeQuery(query, settings).ExtractValueSync(); + result.GetIssues().PrintTo(Cerr); + UNIT_ASSERT_VALUES_EQUAL(result.IsSuccess(), success); + } } Y_UNIT_TEST(RestrictDrop) { diff --git a/ydb/core/tx/tx_proxy/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/tx_proxy/CMakeLists.darwin-x86_64.txt index bf765f4fca7..de796fd00ab 100644 --- a/ydb/core/tx/tx_proxy/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/tx/tx_proxy/CMakeLists.darwin-x86_64.txt @@ -32,6 +32,7 @@ target_link_libraries(core-tx-tx_proxy PUBLIC ydb-core-actorlib_impl ydb-core-base core-blobstorage-base + ydb-core-docapi ydb-core-engine ydb-core-formats ydb-core-grpc_services diff --git a/ydb/core/tx/tx_proxy/CMakeLists.linux-aarch64.txt b/ydb/core/tx/tx_proxy/CMakeLists.linux-aarch64.txt index 786900b59f2..b2c78d13102 100644 --- a/ydb/core/tx/tx_proxy/CMakeLists.linux-aarch64.txt +++ b/ydb/core/tx/tx_proxy/CMakeLists.linux-aarch64.txt @@ -33,6 +33,7 @@ target_link_libraries(core-tx-tx_proxy PUBLIC ydb-core-actorlib_impl ydb-core-base core-blobstorage-base + ydb-core-docapi ydb-core-engine ydb-core-formats ydb-core-grpc_services diff --git a/ydb/core/tx/tx_proxy/CMakeLists.linux-x86_64.txt b/ydb/core/tx/tx_proxy/CMakeLists.linux-x86_64.txt index 786900b59f2..b2c78d13102 100644 --- a/ydb/core/tx/tx_proxy/CMakeLists.linux-x86_64.txt +++ b/ydb/core/tx/tx_proxy/CMakeLists.linux-x86_64.txt @@ -33,6 +33,7 @@ target_link_libraries(core-tx-tx_proxy PUBLIC ydb-core-actorlib_impl ydb-core-base core-blobstorage-base + ydb-core-docapi ydb-core-engine ydb-core-formats ydb-core-grpc_services diff --git a/ydb/core/tx/tx_proxy/CMakeLists.windows-x86_64.txt b/ydb/core/tx/tx_proxy/CMakeLists.windows-x86_64.txt index bf765f4fca7..de796fd00ab 100644 --- a/ydb/core/tx/tx_proxy/CMakeLists.windows-x86_64.txt +++ b/ydb/core/tx/tx_proxy/CMakeLists.windows-x86_64.txt @@ -32,6 +32,7 @@ target_link_libraries(core-tx-tx_proxy PUBLIC ydb-core-actorlib_impl ydb-core-base core-blobstorage-base + ydb-core-docapi ydb-core-engine ydb-core-formats ydb-core-grpc_services diff --git a/ydb/core/tx/tx_proxy/schemereq.cpp b/ydb/core/tx/tx_proxy/schemereq.cpp index ab0a8f162a7..47779a8382b 100644 --- a/ydb/core/tx/tx_proxy/schemereq.cpp +++ b/ydb/core/tx/tx_proxy/schemereq.cpp @@ -1,5 +1,6 @@ #include "proxy.h" +#include <ydb/core/docapi/traits.h> #include <ydb/core/tx/schemeshard/schemeshard.h> #include <ydb/core/protos/flat_scheme_op.pb.h> #include <ydb/core/base/tablet_pipe.h> @@ -16,9 +17,6 @@ namespace NKikimr { namespace NTxProxy { -static constexpr TStringBuf DocApiRequestType = "_document_api_request"; -static constexpr TStringBuf DocApiTableVersionAttribute = "__document_api_version"; - template<typename TDerived> struct TBaseSchemeReq: public TActorBootstrapped<TDerived> { using TBase = TActorBootstrapped<TDerived>; @@ -967,7 +965,7 @@ struct TBaseSchemeReq: public TActorBootstrapped<TDerived> { } static bool IsDocApiRestricted(const NKikimrTxUserProxy::TEvProposeTransaction& tx) { - if (tx.GetRequestType() == DocApiRequestType) { + if (tx.GetRequestType() == NDocApi::RequestType) { return false; } @@ -983,7 +981,7 @@ struct TBaseSchemeReq: public TActorBootstrapped<TDerived> { bool CheckDocApi(const NSchemeCache::TSchemeCacheNavigate::TResultSet& resolveSet, const TActorContext &ctx) { for (const auto& entry: resolveSet) { - if (entry.Attributes.contains(DocApiTableVersionAttribute)) { + if (entry.Attributes.contains(NDocApi::VersionAttribute)) { auto issue = MakeIssue(NKikimrIssues::TIssuesIds::DEFAULT_ERROR, TStringBuilder() << "Document API table cannot be modified" << ": "<< CanonizePath(entry.Path)); |