@@ -355,7 +355,7 @@ void TCommandExecuteQuery::Config(TConfig& config) {
355355 config.Opts ->AddLongOption (" flame-graph" , " Builds resource usage flame graph, based on statistics info" )
356356 .RequiredArgument (" PATH" ).StoreResult (&FlameGraphPath);
357357 config.Opts ->AddCharOption (' s' , " Collect statistics in basic mode" ).StoreTrue (&BasicStats);
358- config.Opts ->AddLongOption (" tx-mode" , " Transaction mode (for data queries only ) [serializable-rw, online-ro, stale-ro]" )
358+ config.Opts ->AddLongOption (" tx-mode" , " Transaction mode (for generic & data queries) [serializable-rw, online-ro, stale-ro, notx (generic queries only) ]" )
359359 .RequiredArgument (" [String]" ).DefaultValue (" serializable-rw" ).StoreResult (&TxMode);
360360 config.Opts ->AddLongOption (' q' , " query" , " Text of query to execute" ).RequiredArgument (" [String]" ).StoreResult (&Query);
361361 config.Opts ->AddLongOption (' f' , " file" , " Path to file with query text to execute" )
@@ -440,18 +440,15 @@ int TCommandExecuteQuery::ExecuteDataQuery(TConfig& config) {
440440 if (TxMode) {
441441 if (TxMode == " serializable-rw" ) {
442442 txSettings = NTable::TTxSettings::SerializableRW ();
443+ } else if (TxMode == " online-ro" ) {
444+ txSettings = NTable::TTxSettings::OnlineRO ();
445+ } else if (TxMode == " stale-ro" ) {
446+ txSettings = NTable::TTxSettings::StaleRO ();
443447 } else {
444- if (TxMode == " online-ro" ) {
445- txSettings = NTable::TTxSettings::OnlineRO ();
446- } else {
447- if (TxMode == " stale-ro" ) {
448- txSettings = NTable::TTxSettings::StaleRO ();
449- } else {
450- throw TMisuseException () << " Unknown transaction mode." ;
451- }
452- }
448+ throw TMisuseException () << " Unknown transaction mode." ;
453449 }
454450 }
451+
455452 NTable::TTableClient client (CreateDriver (config));
456453 NTable::TAsyncDataQueryResult asyncResult;
457454
@@ -519,7 +516,7 @@ void TCommandExecuteQuery::PrintDataQueryResponse(NTable::TDataQueryResult& resu
519516 Cout << Endl << " Statistics:" << Endl << stats->ToString ();
520517 PrintFlameGraph (stats->GetPlan ());
521518 }
522- if ( FlameGraphPath && !stats.Defined ())
519+ if ( FlameGraphPath && !stats.Defined ())
523520 {
524521 Cout << Endl << " Flame graph is available for full or profile stats only" << Endl;
525522 }
@@ -585,7 +582,22 @@ namespace {
585582 TClient client,
586583 const TString& query,
587584 const TSettings<TClient>& settings,
588- const std::optional<TParams>& params = std::nullopt ) {
585+ const TString& TxMode = " " ,
586+ const std::optional<TParams>& params = std::nullopt
587+ ) {
588+ NQuery::TTxSettings txSettings;
589+ if (TxMode) {
590+ if (TxMode == " serializable-rw" ) {
591+ txSettings = NQuery::TTxSettings::SerializableRW ();
592+ } else if (TxMode == " online-ro" ) {
593+ txSettings = NQuery::TTxSettings::OnlineRO ();
594+ } else if (TxMode == " stale-ro" ) {
595+ txSettings = NQuery::TTxSettings::StaleRO ();
596+ } else if (TxMode != " notx" ) {
597+ throw TMisuseException () << " Unknown transaction mode." ;
598+ }
599+ }
600+
589601 if constexpr (std::is_same_v<TClient, NTable::TTableClient>) {
590602 if (params) {
591603 return client.StreamExecuteScanQuery (
@@ -603,14 +615,14 @@ namespace {
603615 if (params) {
604616 return client.StreamExecuteQuery (
605617 query,
606- NQuery::TTxControl::BeginTx ().CommitTx (),
618+ (TxMode == " notx " ? NQuery::TTxControl::NoTx () : NQuery::TTxControl:: BeginTx (txSettings ).CommitTx () ),
607619 *params,
608620 settings
609621 );
610622 } else {
611623 return client.StreamExecuteQuery (
612624 query,
613- NQuery::TTxControl::BeginTx ().CommitTx (),
625+ (TxMode == " notx " ? NQuery::TTxControl::NoTx () : NQuery::TTxControl:: BeginTx (txSettings ).CommitTx () ),
614626 settings
615627 );
616628 }
@@ -681,6 +693,7 @@ int TCommandExecuteQuery::ExecuteQueryImpl(TConfig& config) {
681693 client,
682694 Query,
683695 settings,
696+ TxMode,
684697 paramBuilder->Build ()
685698 );
686699 return result.Apply ([promise](const auto & result) mutable {
@@ -702,7 +715,8 @@ int TCommandExecuteQuery::ExecuteQueryImpl(TConfig& config) {
702715 auto result = StreamExecuteQuery (
703716 client,
704717 Query,
705- settings
718+ settings,
719+ TxMode
706720 );
707721 return result.Apply ([promise](const auto & result) mutable {
708722 promise.SetValue (result.GetValue ());
0 commit comments