Skip to content

Commit

Permalink
Merge #40704
Browse files Browse the repository at this point in the history
40704: sql: support wildcard in SHOW PARTITIONS FROM INDEX r=solongordon a=solongordon

The SHOW PARTITIONS FROM INDEX command now supports the same `tbl@*`
syntax which `ALTER PARTITION OF INDEX` does. It behaves identically to
SHOW PARTITIONS FROM TABLE.

Fixes #40382

Release note: None

Co-authored-by: Solon Gordon <[email protected]>
  • Loading branch information
craig[bot] and solongordon committed Sep 12, 2019
2 parents 5169da9 + 5b7a96e commit 29cb9a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ show_partitions_stmt ::=
'SHOW' 'PARTITIONS' 'FROM' 'TABLE' table_name
| 'SHOW' 'PARTITIONS' 'FROM' 'DATABASE' database_name
| 'SHOW' 'PARTITIONS' 'FROM' 'INDEX' table_index_name
| 'SHOW' 'PARTITIONS' 'FROM' 'INDEX' table_name '@' '*'

show_jobs_stmt ::=
'SHOW' 'AUTOMATIC' 'JOBS'
Expand Down
8 changes: 8 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/distsql_partitioning
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ test t3 p2 NULL x t3@primary (2) constraints = '[+dc=dc2]'
test t3 p3 NULL y t3@sec (3) constraints = '[+dc=dc3]'
test t3 p4 NULL y t3@sec (4) constraints = '[+dc=dc4]'

query TTTTTTTT
SHOW PARTITIONS FROM INDEX t3@*
----
test t3 p1 NULL x t3@primary (1) constraints = '[+dc=dc1]'
test t3 p2 NULL x t3@primary (2) constraints = '[+dc=dc2]'
test t3 p3 NULL y t3@sec (3) constraints = '[+dc=dc3]'
test t3 p4 NULL y t3@sec (4) constraints = '[+dc=dc4]'

query TTTTTTTT
SHOW PARTITIONS FROM INDEX t3@sec
----
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,10 @@ show_partitions_stmt:
{
$$.val = &tree.ShowPartitions{IsIndex: true, Index: $5.tableIndexName()}
}
| SHOW PARTITIONS FROM INDEX table_name '@' '*'
{
$$.val = &tree.ShowPartitions{IsTable: true, Table: $5.unresolvedObjectName()}
}
| SHOW PARTITIONS error // SHOW HELP: SHOW PARTITIONS

// %Help: SHOW DATABASES - list databases
Expand Down

0 comments on commit 29cb9a6

Please sign in to comment.