From 5b7a96efc8d6214585e271306adfc19f171a66e7 Mon Sep 17 00:00:00 2001 From: Solon Gordon Date: Thu, 12 Sep 2019 10:55:01 -0400 Subject: [PATCH] sql: support wildcard in SHOW PARTITIONS FROM INDEX 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 --- docs/generated/sql/bnf/stmt_block.bnf | 1 + .../logictestccl/testdata/logic_test/distsql_partitioning | 8 ++++++++ pkg/sql/parser/sql.y | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index 0d96945e815d..8c879dac25c5 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -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' diff --git a/pkg/ccl/logictestccl/testdata/logic_test/distsql_partitioning b/pkg/ccl/logictestccl/testdata/logic_test/distsql_partitioning index 6775aeaee9dd..2170a8820d6d 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/distsql_partitioning +++ b/pkg/ccl/logictestccl/testdata/logic_test/distsql_partitioning @@ -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 ---- diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index c39597dbc2d2..1da1e0a61a77 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -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