Skip to content

Commit

Permalink
sql/parser: rename some invisible non-terminals
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Jul 4, 2023
1 parent 2670c2d commit 753fc23
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 54 deletions.
3 changes: 0 additions & 3 deletions docs/generated/sql/bnf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ FILES = [
"opt_frame_clause",
"opt_locality",
"opt_persistence_temp_table",
"opt_show_tenant_options",
"opt_with_storage_parameter_list",
"pause_all_jobs_stmt",
"pause_job",
Expand Down Expand Up @@ -263,8 +262,6 @@ FILES = [
"table_clause",
"table_constraint",
"table_ref",
"tenant_capability",
"tenant_capability_list",
"transaction_stmt",
"truncate_stmt",
"unique_column_level",
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/sql/bnf/opt_show_tenant_options.bnf

This file was deleted.

3 changes: 0 additions & 3 deletions docs/generated/sql/bnf/tenant_capability.bnf

This file was deleted.

2 changes: 0 additions & 2 deletions docs/generated/sql/bnf/tenant_capability_list.bnf

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/gen/bnf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ BNF_SRCS = [
"//docs/generated/sql/bnf:opt_frame_clause.bnf",
"//docs/generated/sql/bnf:opt_locality.bnf",
"//docs/generated/sql/bnf:opt_persistence_temp_table.bnf",
"//docs/generated/sql/bnf:opt_show_tenant_options.bnf",
"//docs/generated/sql/bnf:opt_with_storage_parameter_list.bnf",
"//docs/generated/sql/bnf:pause_all_jobs_stmt.bnf",
"//docs/generated/sql/bnf:pause_job.bnf",
Expand Down Expand Up @@ -263,8 +262,6 @@ BNF_SRCS = [
"//docs/generated/sql/bnf:table_clause.bnf",
"//docs/generated/sql/bnf:table_constraint.bnf",
"//docs/generated/sql/bnf:table_ref.bnf",
"//docs/generated/sql/bnf:tenant_capability.bnf",
"//docs/generated/sql/bnf:tenant_capability_list.bnf",
"//docs/generated/sql/bnf:transaction_stmt.bnf",
"//docs/generated/sql/bnf:truncate_stmt.bnf",
"//docs/generated/sql/bnf:unique_column_level.bnf",
Expand Down
3 changes: 0 additions & 3 deletions pkg/gen/diagrams.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ DIAGRAMS_SRCS = [
"//docs/generated/sql/bnf:opt_frame_clause.html",
"//docs/generated/sql/bnf:opt_locality.html",
"//docs/generated/sql/bnf:opt_persistence_temp_table.html",
"//docs/generated/sql/bnf:opt_show_tenant_options.html",
"//docs/generated/sql/bnf:opt_with_storage_parameter_list.html",
"//docs/generated/sql/bnf:pause.html",
"//docs/generated/sql/bnf:pause_all_jobs.html",
Expand Down Expand Up @@ -261,8 +260,6 @@ DIAGRAMS_SRCS = [
"//docs/generated/sql/bnf:table_clause.html",
"//docs/generated/sql/bnf:table_constraint.html",
"//docs/generated/sql/bnf:table_ref.html",
"//docs/generated/sql/bnf:tenant_capability.html",
"//docs/generated/sql/bnf:tenant_capability_list.html",
"//docs/generated/sql/bnf:transaction.html",
"//docs/generated/sql/bnf:truncate.html",
"//docs/generated/sql/bnf:unique_column_level.html",
Expand Down
3 changes: 0 additions & 3 deletions pkg/gen/docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ DOCS_SRCS = [
"//docs/generated/sql/bnf:opt_frame_clause.bnf",
"//docs/generated/sql/bnf:opt_locality.bnf",
"//docs/generated/sql/bnf:opt_persistence_temp_table.bnf",
"//docs/generated/sql/bnf:opt_show_tenant_options.bnf",
"//docs/generated/sql/bnf:opt_with_storage_parameter_list.bnf",
"//docs/generated/sql/bnf:pause_all_jobs_stmt.bnf",
"//docs/generated/sql/bnf:pause_job.bnf",
Expand Down Expand Up @@ -275,8 +274,6 @@ DOCS_SRCS = [
"//docs/generated/sql/bnf:table_clause.bnf",
"//docs/generated/sql/bnf:table_constraint.bnf",
"//docs/generated/sql/bnf:table_ref.bnf",
"//docs/generated/sql/bnf:tenant_capability.bnf",
"//docs/generated/sql/bnf:tenant_capability_list.bnf",
"//docs/generated/sql/bnf:transaction_stmt.bnf",
"//docs/generated/sql/bnf:truncate_stmt.bnf",
"//docs/generated/sql/bnf:unique_column_level.bnf",
Expand Down
84 changes: 49 additions & 35 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ func (u *sqlSymUnion) showCreateFormatOption() tree.ShowCreateFormatOption {
%type <tree.Statement> alter_virtual_cluster_stmt

// ALTER VIRTUAL CLUSTER CAPABILITY
%type <tree.Statement> tenant_capability tenant_capability_list
%type <tree.Statement> virtual_cluster_capability virtual_cluster_capability_list

// ALTER VIRTUAL CLUSTER SET CLUSTER SETTING
%type <tree.Statement> alter_virtual_cluster_csetting_stmt
Expand Down Expand Up @@ -1193,7 +1193,7 @@ func (u *sqlSymUnion) showCreateFormatOption() tree.ShowCreateFormatOption {
%type <tree.Statement> create_sequence_stmt
%type <tree.Statement> create_func_stmt

%type <*tree.LikeTenantSpec> opt_like_tenant
%type <*tree.LikeTenantSpec> opt_like_virtual_cluster

%type <tree.Statement> create_stats_stmt
%type <*tree.CreateStatsOptions> opt_create_stats_options
Expand Down Expand Up @@ -1297,7 +1297,7 @@ func (u *sqlSymUnion) showCreateFormatOption() tree.ShowCreateFormatOption {
%type <tree.Statement> show_syntax_stmt
%type <tree.Statement> show_last_query_stats_stmt
%type <tree.Statement> show_tables_stmt
%type <tree.Statement> show_virtual_cluster_stmt opt_show_tenant_options show_tenant_options
%type <tree.Statement> show_virtual_cluster_stmt opt_show_virtual_cluster_options show_virtual_cluster_options
%type <tree.Statement> show_trace_stmt
%type <tree.Statement> show_transaction_stmt
%type <tree.Statement> show_transactions_stmt
Expand Down Expand Up @@ -1339,7 +1339,7 @@ func (u *sqlSymUnion) showCreateFormatOption() tree.ShowCreateFormatOption {
%type <[]tree.KVOption> kv_option_list opt_with_options var_set_list opt_with_schedule_options
%type <*tree.BackupOptions> opt_with_backup_options backup_options backup_options_list
%type <*tree.RestoreOptions> opt_with_restore_options restore_options restore_options_list
%type <*tree.TenantReplicationOptions> opt_with_tenant_replication_options tenant_replication_options tenant_replication_options_list
%type <*tree.TenantReplicationOptions> opt_with_replication_options replication_options replication_options_list
%type <tree.ShowBackupDetails> show_backup_details
%type <*tree.ShowJobOptions> show_job_options show_job_options_list
%type <*tree.ShowBackupOptions> opt_with_show_backup_options show_backup_options show_backup_options_list show_backup_connection_options show_backup_connection_options_list
Expand Down Expand Up @@ -4424,15 +4424,15 @@ create_stmt:
// Replication option:
// FROM REPLICATION OF <virtual_cluster_spec> ON <location> [ WITH OPTIONS ... ]
create_virtual_cluster_stmt:
CREATE virtual_cluster d_expr opt_like_tenant
CREATE virtual_cluster d_expr opt_like_virtual_cluster
{
/* SKIP DOC */
$$.val = &tree.CreateTenant{
TenantSpec: &tree.TenantSpec{IsName: true, Expr: $3.expr()},
Like: $4.likeTenantSpec(),
}
}
| CREATE virtual_cluster IF NOT EXISTS d_expr opt_like_tenant
| CREATE virtual_cluster IF NOT EXISTS d_expr opt_like_virtual_cluster
{
/* SKIP DOC */
$$.val = &tree.CreateTenant{
Expand All @@ -4441,7 +4441,7 @@ create_virtual_cluster_stmt:
Like: $7.likeTenantSpec(),
}
}
| CREATE virtual_cluster d_expr opt_like_tenant FROM REPLICATION OF d_expr ON d_expr opt_with_tenant_replication_options
| CREATE virtual_cluster d_expr opt_like_virtual_cluster FROM REPLICATION OF d_expr ON d_expr opt_with_replication_options
{
/* SKIP DOC */
$$.val = &tree.CreateTenantFromReplication{
Expand All @@ -4452,7 +4452,7 @@ create_virtual_cluster_stmt:
Like: $4.likeTenantSpec(),
}
}
| CREATE virtual_cluster IF NOT EXISTS d_expr opt_like_tenant FROM REPLICATION OF d_expr ON d_expr opt_with_tenant_replication_options
| CREATE virtual_cluster IF NOT EXISTS d_expr opt_like_virtual_cluster FROM REPLICATION OF d_expr ON d_expr opt_with_replication_options
{
/* SKIP DOC */
$$.val = &tree.CreateTenantFromReplication{
Expand All @@ -4470,10 +4470,10 @@ virtual_cluster:
TENANT { /* SKIP DOC */ }
| VIRTUAL CLUSTER

// opt_like_tenant defines a LIKE clause for CREATE VIRTUAL CLUSTER.
// opt_like_virtual_cluster defines a LIKE clause for CREATE VIRTUAL CLUSTER.
// Eventually this can grow to support INCLUDING/EXCLUDING options
// like in CREATE TABLE.
opt_like_tenant:
opt_like_virtual_cluster:
/* EMPTY */
{
$$.val = &tree.LikeTenantSpec{}
Expand All @@ -4484,12 +4484,12 @@ opt_like_tenant:
}

// Optional tenant replication options.
opt_with_tenant_replication_options:
WITH tenant_replication_options_list
opt_with_replication_options:
WITH replication_options_list
{
$$.val = $2.tenantReplicationOptions()
}
| WITH OPTIONS '(' tenant_replication_options_list ')'
| WITH OPTIONS '(' replication_options_list ')'
{
$$.val = $4.tenantReplicationOptions()
}
Expand All @@ -4498,21 +4498,21 @@ opt_with_tenant_replication_options:
$$.val = &tree.TenantReplicationOptions{}
}

tenant_replication_options_list:
replication_options_list:
// Require at least one option
tenant_replication_options
replication_options
{
$$.val = $1.tenantReplicationOptions()
}
| tenant_replication_options_list ',' tenant_replication_options
| replication_options_list ',' replication_options
{
if err := $1.tenantReplicationOptions().CombineWith($3.tenantReplicationOptions()); err != nil {
return setErr(sqllex, err)
}
}

// List of valid tenant replication options.
tenant_replication_options:
replication_options:
RETENTION '=' d_expr
{
$$.val = &tree.TenantReplicationOptions{Retention: $3.expr()}
Expand Down Expand Up @@ -5933,7 +5933,7 @@ backup_kms:
// REPLICATION STATUS
// CAPABILITIES
show_virtual_cluster_stmt:
SHOW virtual_cluster_spec_opt_all opt_show_tenant_options
SHOW virtual_cluster_spec_opt_all opt_show_virtual_cluster_options
{
/* SKIP DOC */
$$.val = &tree.ShowTenant{
Expand Down Expand Up @@ -5972,29 +5972,39 @@ virtual_cluster_spec_opt_all:
$$.val = $3.tenantSpec()
}

opt_show_tenant_options:
opt_show_virtual_cluster_options:
/* EMPTY */
{ $$.val = tree.ShowTenantOptions{} }
| WITH show_tenant_options
{ $$.val = $2.showTenantOpts() }
{
/* SKIP DOC */
$$.val = tree.ShowTenantOptions{}
}
| WITH show_virtual_cluster_options
{
/* SKIP DOC */
$$.val = $2.showTenantOpts()
}

show_tenant_options:
show_virtual_cluster_options:
REPLICATION STATUS
{
/* SKIP DOC */
$$.val = tree.ShowTenantOptions{WithReplication: true}
}
| CAPABILITIES
{
/* SKIP DOC */
$$.val = tree.ShowTenantOptions{WithCapabilities: true}
}
| show_tenant_options ',' REPLICATION STATUS
| show_virtual_cluster_options ',' REPLICATION STATUS
{
/* SKIP DOC */
o := $1.showTenantOpts()
o.WithReplication = true
$$.val = o
}
| show_tenant_options ',' CAPABILITIES
| show_virtual_cluster_options ',' CAPABILITIES
{
/* SKIP DOC */
o := $1.showTenantOpts()
o.WithCapabilities = true
$$.val = o
Expand Down Expand Up @@ -6670,7 +6680,7 @@ alter_virtual_cluster_replication_stmt:
},
}
}
| ALTER virtual_cluster virtual_cluster_spec SET REPLICATION tenant_replication_options_list
| ALTER virtual_cluster virtual_cluster_spec SET REPLICATION replication_options_list
{
/* SKIP DOC */
$$.val = &tree.AlterTenantReplication{
Expand Down Expand Up @@ -6731,7 +6741,7 @@ to_or_eq:
// ALTER VIRTUAL CLUSTER <tenant_id> GRANT CAPABILITY <var> { TO | = } <value>
// ALTER VIRTUAL CLUSTER <tenant_id> REVOKE CAPABILITY <var>
alter_virtual_cluster_capability_stmt:
ALTER virtual_cluster virtual_cluster_spec GRANT CAPABILITY tenant_capability_list
ALTER virtual_cluster virtual_cluster_spec GRANT CAPABILITY virtual_cluster_capability_list
{
/* SKIP DOC */
$$.val = &tree.AlterTenantCapability{
Expand All @@ -6747,7 +6757,7 @@ alter_virtual_cluster_capability_stmt:
AllCapabilities: true,
}
}
| ALTER virtual_cluster virtual_cluster_spec REVOKE CAPABILITY tenant_capability_list
| ALTER virtual_cluster virtual_cluster_spec REVOKE CAPABILITY virtual_cluster_capability_list
{
/* SKIP DOC */
$$.val = &tree.AlterTenantCapability{
Expand All @@ -6768,28 +6778,32 @@ alter_virtual_cluster_capability_stmt:
| ALTER virtual_cluster virtual_cluster_spec GRANT error // SHOW HELP: ALTER VIRTUAL CLUSTER CAPABILITY
| ALTER virtual_cluster virtual_cluster_spec REVOKE error // SHOW HELP: ALTER VIRTUAL CLUSTER CAPABILITY

tenant_capability:
virtual_cluster_capability:
var_name
{
$$.val = tree.TenantCapability{
Name: strings.Join($1.strs(), "."),
}
/* SKIP DOC */
$$.val = tree.TenantCapability{
Name: strings.Join($1.strs(), "."),
}
}
| var_name to_or_eq var_value
{
/* SKIP DOC */
$$.val = tree.TenantCapability{
Name: strings.Join($1.strs(), "."),
Value: $3.expr(),
}
}

tenant_capability_list:
tenant_capability
virtual_cluster_capability_list:
virtual_cluster_capability
{
/* SKIP DOC */
$$.val = []tree.TenantCapability{$1.tenantCapability()}
}
| tenant_capability_list ',' tenant_capability
| virtual_cluster_capability_list ',' virtual_cluster_capability
{
/* SKIP DOC */
$$.val = append($1.tenantCapabilities(), $3.tenantCapability())
}

Expand Down

0 comments on commit 753fc23

Please sign in to comment.