Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: make SPLIT AT output be consistent with SHOW_RANGES #55543

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/split_at
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# LogicTest: !3node-tenant

# Test formatting of keys in output of SPLIT AT

statement ok
CREATE TABLE t (a INT PRIMARY KEY)

query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key end_key replicas lease_holder
NULL NULL {1} 1

query TTT colnames
ALTER TABLE t SPLIT AT VALUES (1), (10)
----
key pretty split_enforced_until
[189 137 137] /1 2262-04-11 23:47:16.854776 +0000 +0000
[189 137 146] /10 2262-04-11 23:47:16.854776 +0000 +0000

query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key end_key replicas lease_holder
NULL /1 {1} 1
/1 /10 {1} 1
/10 NULL {1} 1

statement ok
DROP TABLE t
3 changes: 2 additions & 1 deletion pkg/sql/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
Expand Down Expand Up @@ -74,7 +75,7 @@ func (n *splitNode) Values() tree.Datums {
}
return tree.Datums{
tree.NewDBytes(tree.DBytes(n.run.lastSplitKey)),
tree.NewDString(keys.PrettyPrint(nil /* valDirs */, n.run.lastSplitKey)),
tree.NewDString(catalogkeys.PrettyKey(nil /* valDirs */, n.run.lastSplitKey, 2)),
splitEnforcedUntil,
}
}
Expand Down