Skip to content

Commit

Permalink
filter pg const params in response (#5711)
Browse files Browse the repository at this point in the history
  • Loading branch information
VPolka authored Jun 24, 2024
1 parent e58b6f6 commit 3d06832
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ydb/core/kqp/session_actor/kqp_query_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ bool TKqpQueryState::SaveAndCheckCompileResult(TEvKqp::TEvCompileResponse* ev) {
if (!CommandTagName) {
CommandTagName = CompileResult->CommandTagName;
}
for (const auto& param : PreparedQuery->GetParameters()) {
const auto& ast = CompileResult->Ast;
if (!ast || !ast->PgAutoParamValues || !ast->PgAutoParamValues->contains(param.GetName())) {
ResultParams.push_back(param);
}
}
return true;
}

Expand Down
5 changes: 5 additions & 0 deletions ydb/core/kqp/session_actor/kqp_query_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class TKqpQueryState : public TNonCopyable {
ui64 ParametersSize = 0;
TPreparedQueryHolder::TConstPtr PreparedQuery;
TKqpCompileResult::TConstPtr CompileResult;
TVector<NKikimrKqp::TParameterDescription> ResultParams;
TKqpStatsCompile CompileStats;
TIntrusivePtr<TKqpTransactionContext> TxCtx;
TQueryData::TPtr QueryData;
Expand Down Expand Up @@ -188,6 +189,10 @@ class TKqpQueryState : public TNonCopyable {
return QueryParameterTypes;
}

TVector<NKikimrKqp::TParameterDescription> GetResultParams() const {
return ResultParams;
}

void EnsureAction() {
YQL_ENSURE(RequestEv->HasAction());
}
Expand Down
9 changes: 6 additions & 3 deletions ydb/core/kqp/session_actor/kqp_session_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,8 +1697,9 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {

if (replyQueryParameters) {
YQL_ENSURE(QueryState->PreparedQuery);
response->MutableQueryParameters()->CopyFrom(
QueryState->PreparedQuery->GetParameters());
for (auto& param : QueryState->GetResultParams()) {
*response->AddQueryParameters() = param;
}
}

if (replyQueryId) {
Expand Down Expand Up @@ -1902,7 +1903,9 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
response.SetPreparedQuery(compileResult->Uid);

auto& preparedQuery = compileResult->PreparedQuery;
response.MutableQueryParameters()->CopyFrom(preparedQuery->GetParameters());
for (auto& param : QueryState->GetResultParams()) {
*response.AddQueryParameters() = param;
}

response.SetQueryPlan(preparedQuery->GetPhysicalQuery().GetQueryPlan());
response.SetQueryAst(preparedQuery->GetPhysicalQuery().GetQueryAst());
Expand Down

0 comments on commit 3d06832

Please sign in to comment.