-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release note (sql change): add the SHOW TRANSACTIONS statement, similar to SHOW SESSIONS and variants. It shows the currently active transactions in the node or cluster, and some information about them.
- Loading branch information
1 parent
1bd878c
commit ebf2ec0
Showing
8 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package delegate | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree" | ||
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase" | ||
) | ||
|
||
const _ = ` | ||
id UUID, -- the unique ID of the transaction | ||
node_id INT, -- the ID of the node running the transaction | ||
session_id STRING, -- the ID of the session | ||
start TIMESTAMP, -- the start time of the transaction | ||
txn_string STRING, -- the string representation of the transcation | ||
application_name STRING, -- the name of the application as per SET application_name | ||
num_stmts INT, -- the number of statements executed so far | ||
num_retries INT, -- the number of times the transaction was restarted | ||
num_auto_retries INT -- the number of times the transaction was automatically restarted | ||
` | ||
|
||
func (d *delegator) delegateShowTransactions(n *tree.ShowTransactions) (tree.Statement, error) { | ||
const query = `SELECT node_id, id, application_name, num_stmts, num_retries, num_auto_retries FROM ` | ||
table := `crdb_internal.node_transactions` | ||
if n.Cluster { | ||
table = `crdb_internal.cluster_transactions` | ||
} | ||
var filter string | ||
if !n.All { | ||
filter = " WHERE application_name NOT LIKE '" + sqlbase.InternalAppNamePrefix + "%'" | ||
} | ||
return parse(query + table + filter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters