@@ -247,14 +247,18 @@ struct TKiExploreTxResults {
247247 }
248248 }
249249
250- void AddResult ( const TExprBase& result ) {
250+ void PrepareForResult ( ) {
251251 if (QueryBlocks.empty ()) {
252252 AddQueryBlock ();
253253 }
254254
255255 if (!ConcurrentResults && QueryBlocks.back ().Results .size () > 0 ) {
256256 AddQueryBlock ();
257257 }
258+ }
259+
260+ void AddResult (const TExprBase& result) {
261+ PrepareForResult ();
258262
259263 auto & curBlock = QueryBlocks.back ();
260264 curBlock.Results .push_back (result);
@@ -422,6 +426,10 @@ bool ExploreTx(TExprBase node, TExprContext& ctx, const TKiDataSink& dataSink, T
422426 const auto & tableData = tablesData->ExistingTable (cluster, table);
423427 YQL_ENSURE (tableData.Metadata );
424428
429+ if (!write.ReturningColumns ().Empty ()) {
430+ txRes.PrepareForResult ();
431+ }
432+
425433 if (tableOp == TYdbOperation::UpdateOn) {
426434 auto inputColumnsSetting = GetSetting (write.Settings ().Ref (), " input_columns" );
427435 YQL_ENSURE (inputColumnsSetting);
@@ -482,6 +490,11 @@ bool ExploreTx(TExprBase node, TExprContext& ctx, const TKiDataSink& dataSink, T
482490 for (const auto & item : updateStructType->GetItems ()) {
483491 updateColumns.emplace (item->GetName ());
484492 }
493+
494+ if (!update.ReturningColumns ().Empty ()) {
495+ txRes.PrepareForResult ();
496+ }
497+
485498 txRes.AddUpdateOpToQueryBlock (node, tableData.Metadata , updateColumns);
486499 if (!update.ReturningColumns ().Empty ()) {
487500 txRes.AddResult (
@@ -517,6 +530,10 @@ bool ExploreTx(TExprBase node, TExprContext& ctx, const TKiDataSink& dataSink, T
517530 YQL_ENSURE (tablesData);
518531 const auto & tableData = tablesData->ExistingTable (cluster, table);
519532 YQL_ENSURE (tableData.Metadata );
533+ if (!del.ReturningColumns ().Empty ()) {
534+ txRes.PrepareForResult ();
535+ }
536+
520537 txRes.AddWriteOpToQueryBlock (node, tableData.Metadata , tableOp & KikimrReadOps ());
521538 if (!del.ReturningColumns ().Empty ()) {
522539 txRes.AddResult (
0 commit comments