Skip to content

Commit 8fcd22a

Browse files
committed
Revert "Forbid query execution on explicit session without attach (ydb-platform#1870)"
This reverts commit 57cf0e9.
1 parent 65c5bd7 commit 8fcd22a

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed

ydb/core/kqp/proxy_service/kqp_proxy_service.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
626626
const auto queryAction = ev->Get()->GetAction();
627627
TKqpRequestInfo requestInfo(traceId);
628628
ui64 requestId = PendingRequests.RegisterRequest(ev->Sender, ev->Cookie, traceId, TKqpEvents::EvQueryRequest);
629-
bool explicitSession = true;
630629
if (ev->Get()->GetSessionId().empty()) {
631630
TProcessResult<TKqpSessionInfo*> result;
632631
if (!CreateNewSessionWorker(requestInfo, TString(DefaultKikimrPublicClusterName), false,
@@ -635,7 +634,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
635634
ReplyProcessError(result.YdbStatus, result.Error, requestId);
636635
return;
637636
}
638-
explicitSession = false;
637+
639638
ev->Get()->SetSessionId(result.Value->SessionId);
640639
}
641640

@@ -651,16 +650,6 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
651650
dbCounters = Counters->GetDbCounters(database);
652651
}
653652

654-
if (queryType == NKikimrKqp::QUERY_TYPE_SQL_GENERIC_QUERY ||
655-
queryType == NKikimrKqp::QUERY_TYPE_SQL_GENERIC_CONCURRENT_QUERY) {
656-
657-
if (explicitSession && sessionInfo && !sessionInfo->AttachedRpcId) {
658-
TString error = "Attempt to execute query on explicit session without attach";
659-
ReplyProcessError(Ydb::StatusIds::BAD_REQUEST, error, requestId);
660-
return;
661-
}
662-
}
663-
664653
PendingRequests.SetSessionId(requestId, sessionId, dbCounters);
665654
Counters->ReportQueryRequest(dbCounters, ev->Get()->GetRequestSize(), ev->Get()->GetParametersSize(), ev->Get()->GetQuerySize());
666655
Counters->ReportQueryAction(dbCounters, queryAction);

ydb/services/ydb/ydb_query_ut.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,6 @@ Y_UNIT_TEST_SUITE(YdbQueryService) {
6868
UNIT_ASSERT(allDoneOk);
6969
}
7070

71-
Y_UNIT_TEST(TestForbidExecuteWithoutAttach) {
72-
TKikimrWithGrpcAndRootSchema server;
73-
74-
ui16 grpc = server.GetPort();
75-
TString location = TStringBuilder() << "localhost:" << grpc;
76-
77-
auto clientConfig = NGRpcProxy::TGRpcClientConfig(location);
78-
79-
TString sessionId = CreateQuerySession(clientConfig);
80-
81-
UNIT_ASSERT(sessionId);
82-
83-
NYdbGrpc::TGRpcClientLow clientLow;
84-
85-
std::shared_ptr<grpc::Channel> channel;
86-
channel = grpc::CreateChannel("localhost:" + ToString(grpc), grpc::InsecureChannelCredentials());
87-
88-
{
89-
std::unique_ptr<Ydb::Query::V1::QueryService::Stub> stub;
90-
stub = Ydb::Query::V1::QueryService::NewStub(channel);
91-
grpc::ClientContext context;
92-
Ydb::Query::ExecuteQueryRequest request;
93-
request.set_session_id(sessionId);
94-
request.set_exec_mode(Ydb::Query::EXEC_MODE_EXECUTE);
95-
request.mutable_tx_control()->mutable_begin_tx()->mutable_serializable_read_write();
96-
request.mutable_tx_control()->set_commit_tx(true);
97-
request.mutable_query_content()->set_text("SELECT 42");
98-
Ydb::Query::ExecuteQueryResponsePart response;
99-
auto reader = stub->ExecuteQuery(&context, request);
100-
bool res = true;
101-
while (res) {
102-
res = reader->Read(&response);
103-
if (res) {
104-
UNIT_ASSERT_VALUES_EQUAL(response.status(), Ydb::StatusIds::BAD_REQUEST);
105-
}
106-
}
107-
}
108-
}
109-
11071
Y_UNIT_TEST(TestCreateDropAttachSession) {
11172
TKikimrWithGrpcAndRootSchema server;
11273

0 commit comments

Comments
 (0)