Skip to content

Commit

Permalink
json_query transaction mode
Browse files Browse the repository at this point in the history
  • Loading branch information
StekPerepolnen committed Jun 23, 2024
1 parent 43d5e45 commit 6227fcc
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions ydb/core/viewer/json_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
TString Stats;
TString Syntax;
TString QueryId;
TString TransactionMode;
bool Direct = false;
bool IsBase64Encode = true;

Expand Down Expand Up @@ -82,6 +83,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
Schema = StringToSchemaType(schemaStr);
Syntax = params.Get("syntax");
QueryId = params.Get("query_id");
TransactionMode = params.Get("transaction_mode");
Direct = FromStringWithDefault<bool>(params.Get("direct"), Direct);
IsBase64Encode = FromStringWithDefault<bool>(params.Get("base64"), true);
}
Expand All @@ -97,6 +99,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
Action = Action.empty() ? requestData["action"].GetStringSafe({}) : Action;
Syntax = Syntax.empty() ? requestData["syntax"].GetStringSafe({}) : Syntax;
QueryId = QueryId.empty() ? requestData["query_id"].GetStringSafe({}) : QueryId;
TransactionMode = TransactionMode.empty() ? requestData["transaction_mode"].GetStringSafe({}) : TransactionMode;
}
return success;
}
Expand Down Expand Up @@ -243,9 +246,17 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
} else if (Action == "execute-data") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXECUTE);
request.SetType(NKikimrKqp::QUERY_TYPE_SQL_DML);
request.mutable_txcontrol()->mutable_begin_tx()->mutable_serializable_read_write();
request.mutable_txcontrol()->set_commit_tx(true);
request.SetKeepSession(false);
if (TransactionMode == "online-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_online_read_only();
} else if (TransactionMode == "stale-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_stale_read_only();
} else if (TransactionMode == "snapshot-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_snapshot_read_only();
} else {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_serializable_read_write();
}
request.mutable_txcontrol()->set_commit_tx(true);
} else if (Action == "explain" || Action == "explain-ast" || Action == "explain-data") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXPLAIN);
request.SetType(NKikimrKqp::QUERY_TYPE_SQL_DML);
Expand Down Expand Up @@ -662,6 +673,17 @@ YAML::Node TJsonRequestSwagger<TJsonQuery>::GetSwagger() {
type: string
enum: [profile, full]
required: false
- name: transaction_mode
in: query
description: >
transaction mode:
* `serializable-read-write`
* `online-read-only`
* `stale-read-only`
* `snapshot-read-only`
type: string
enum: [serializable-read-write, online-read-only, stale-read-only, snapshot-read-only]
required: false
- name: direct
in: query
description: force processing query on current node
Expand Down

0 comments on commit 6227fcc

Please sign in to comment.