@@ -671,25 +671,31 @@ func (s *session) Execute(
671671 return nil , nil , xerrors .WithStackTrace (err )
672672 }
673673
674- return s .executeQueryResult (result , txControl )
674+ return s .executeQueryResult (result , request . TxControl )
675675}
676676
677677// executeQueryResult returns Transaction and result built from received
678678// result.
679- func (s * session ) executeQueryResult (res * Ydb_Table.ExecuteQueryResult , txControl * table.TransactionControl ) (
679+ func (s * session ) executeQueryResult (
680+ res * Ydb_Table.ExecuteQueryResult , txControl * Ydb_Table.TransactionControl ,
681+ ) (
680682 table.Transaction , result.Result , error ,
681683) {
682- t := & transaction {
684+ tx := & transaction {
683685 id : res .GetTxMeta ().GetId (),
684686 s : s ,
685- c : txControl ,
686687 }
687- r := scanner .NewUnary (
688+ if txControl .CommitTx {
689+ tx .state = txStateCommitted
690+ } else {
691+ tx .state = txStateInitialized
692+ tx .control = table .TxControl (table .WithTxID (tx .id ))
693+ }
694+ return tx , scanner .NewUnary (
688695 res .GetResultSets (),
689696 res .GetQueryStats (),
690697 scanner .WithIgnoreTruncated (s .config .IgnoreTruncated ()),
691- )
692- return t , r , nil
698+ ), nil
693699}
694700
695701// executeDataQuery executes data query.
@@ -1084,8 +1090,9 @@ func (s *session) BeginTransaction(
10841090 return
10851091 }
10861092 return & transaction {
1087- id : result .GetTxMeta ().GetId (),
1088- s : s ,
1089- c : table .TxControl (table .WithTxID (result .GetTxMeta ().GetId ())),
1093+ id : result .GetTxMeta ().GetId (),
1094+ state : txStateInitialized ,
1095+ s : s ,
1096+ control : table .TxControl (table .WithTxID (result .GetTxMeta ().GetId ())),
10901097 }, nil
10911098}
0 commit comments