Skip to content

Commit

Permalink
Merge #56883
Browse files Browse the repository at this point in the history
56883: sql: allow PRIMARY REGION syntax for CREATE / ALTER DATABASE r=ajstorm a=otan

Release note (sql change): Introduced stubs for ALTER DATABASE ...
PRIMARY REGION and CREATE TABLE ... PRIMARY REGION

Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
craig[bot] and otan committed Nov 20, 2020
2 parents 39015a0 + be7dc05 commit 81ac191
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 41 deletions.
36 changes: 18 additions & 18 deletions docs/generated/sql/bnf/create_database_stmt.bnf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
create_database_stmt ::=
'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause opt_regions_list opt_survive_clause
'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' '=' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause 'ENCODING' non_reserved_word_or_sconst opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' '=' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause 'CONNECTION' 'LIMIT' signed_iconst opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_lc_collate_clause opt_lc_ctype_clause opt_primary_region_clause opt_regions_list opt_survival_goal_clause
27 changes: 19 additions & 8 deletions docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,8 @@ alter_database_stmt ::=
| alter_database_to_schema_stmt
| alter_database_add_region_stmt
| alter_database_drop_region_stmt
| alter_database_survive_stmt
| alter_database_survival_goal_stmt
| alter_database_primary_region_stmt

alter_range_stmt ::=
alter_zone_range_stmt
Expand Down Expand Up @@ -1286,8 +1287,8 @@ create_changefeed_stmt ::=
'CREATE' 'CHANGEFEED' 'FOR' changefeed_targets opt_changefeed_sink opt_with_options

create_database_stmt ::=
'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_regions_list opt_survive_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_regions_list opt_survive_clause
'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause
| 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause

create_index_stmt ::=
'CREATE' opt_unique 'INDEX' opt_concurrently opt_index_name 'ON' table_name opt_index_access_method '(' index_params ')' opt_hash_sharded opt_storing opt_interleave opt_partition_by opt_with_storage_parameter_list opt_where_clause
Expand Down Expand Up @@ -1673,8 +1674,11 @@ alter_database_add_region_stmt ::=
alter_database_drop_region_stmt ::=
'ALTER' 'DATABASE' database_name 'DROP' 'REGION' region_name

alter_database_survive_stmt ::=
'ALTER' 'DATABASE' database_name survive_clause
alter_database_survival_goal_stmt ::=
'ALTER' 'DATABASE' database_name survival_goal_clause

alter_database_primary_region_stmt ::=
'ALTER' 'DATABASE' database_name primary_region_clause

alter_zone_range_stmt ::=
'ALTER' 'RANGE' zone_name set_zone_config
Expand Down Expand Up @@ -1763,12 +1767,16 @@ opt_connection_limit ::=
'CONNECTION' 'LIMIT' opt_equal signed_iconst
|

opt_primary_region_clause ::=
primary_region_clause
|

opt_regions_list ::=
region_or_regions opt_equal region_name_list
|

opt_survive_clause ::=
survive_clause
opt_survival_goal_clause ::=
survival_goal_clause
|

opt_unique ::=
Expand Down Expand Up @@ -2140,10 +2148,13 @@ sequence_option_list ::=
region_name ::=
name

survive_clause ::=
survival_goal_clause ::=
'SURVIVE' opt_equal 'REGION' 'FAILURE'
| 'SURVIVE' opt_equal 'ZONE' 'FAILURE'

primary_region_clause ::=
'PRIMARY' 'REGION' opt_equal region_name

role_option ::=
'CREATEROLE'
| 'NOCREATEROLE'
Expand Down
7 changes: 7 additions & 0 deletions pkg/sql/alter_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ func (p *planner) AlterDatabaseDropRegion(
return nil, unimplemented.New("alter database drop region", "implementation pending")
}

// AlterDatabasePrimaryRegion transforms a tree.AlterDatabasePrimaryRegion into a plan node.
func (p *planner) AlterDatabasePrimaryRegion(
ctx context.Context, n *tree.AlterDatabasePrimaryRegion,
) (planNode, error) {
return nil, unimplemented.New("alter database primary region", "implementation pending")
}

// AlterDatabaseSurvivalGoal transforms a tree.AlterDatabaseSurvivalGoal into a plan node.
func (p *planner) AlterDatabaseSurvivalGoal(
ctx context.Context, n *tree.AlterDatabaseSurvivalGoal,
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/create_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (p *planner) CreateDatabase(ctx context.Context, n *tree.CreateDatabase) (p
}
}

if n.PrimaryRegion != "" {
return nil, unimplemented.New("create database primary region", "implementation pending")
}

if n.ConnectionLimit != -1 {
return nil, unimplemented.NewWithIssueDetailf(
54241,
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/multiregion
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ CREATE DATABASE invalid_region_db REGION "region_no_exists"
statement error region "test1" defined multiple times
CREATE DATABASE duplicate_region_name_db REGIONS "test1", "test1"

statement error implementation pending
CREATE DATABASE primary_region_db PRIMARY REGION "test"

statement error implementation pending
CREATE DATABASE new_db SURVIVE ZONE FAILURE

Expand All @@ -34,3 +37,6 @@ ALTER DATABASE new_db DROP REGION "us-west-1"

statement error implementation pending
ALTER TABLE a SET REGIONAL AFFINITY TO NONE

statement error implementation pending
ALTER DATABASE primary_region_db PRIMARY REGION "test"
3 changes: 3 additions & 0 deletions pkg/sql/opaque.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func buildOpaque(
plan, err = p.AlterDatabaseAddRegion(ctx, n)
case *tree.AlterDatabaseDropRegion:
plan, err = p.AlterDatabaseDropRegion(ctx, n)
case *tree.AlterDatabasePrimaryRegion:
plan, err = p.AlterDatabasePrimaryRegion(ctx, n)
case *tree.AlterDatabaseSurvivalGoal:
plan, err = p.AlterDatabaseSurvivalGoal(ctx, n)
case *tree.AlterIndex:
Expand Down Expand Up @@ -198,6 +200,7 @@ func init() {
&tree.AlterDatabaseAddRegion{},
&tree.AlterDatabaseDropRegion{},
&tree.AlterDatabaseOwner{},
&tree.AlterDatabasePrimaryRegion{},
&tree.AlterDatabaseSurvivalGoal{},
&tree.AlterIndex{},
&tree.AlterSchema{},
Expand Down
7 changes: 7 additions & 0 deletions pkg/sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestParse(t *testing.T) {
{`CREATE DATABASE a REGIONS = "us-west-1", "us-west-2"`},
{`CREATE DATABASE a SURVIVE REGION FAILURE`},
{`CREATE DATABASE a SURVIVE ZONE FAILURE`},
{`CREATE DATABASE a PRIMARY REGION "us-west-1"`},
{`CREATE DATABASE IF NOT EXISTS a`},
{`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0'`},
{`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid'`},
Expand All @@ -87,6 +88,7 @@ func TestParse(t *testing.T) {
{`CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2"`},
{`CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE`},
{`CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE`},
{`CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1"`},

{`CREATE SCHEMA IF NOT EXISTS foo`},
{`CREATE SCHEMA foo`},
Expand Down Expand Up @@ -1363,6 +1365,7 @@ func TestParse(t *testing.T) {
{`ALTER DATABASE a ADD REGION "us-west-1"`},
{`ALTER DATABASE a DROP REGION "us-west-1"`},
{`ALTER DATABASE a SURVIVE REGION FAILURE`},
{`ALTER DATABASE a PRIMARY REGION "us-west-3"`},
{`EXPLAIN ALTER DATABASE a RENAME TO b`},

{`ALTER DATABASE a OWNER TO foo`},
Expand Down Expand Up @@ -1783,6 +1786,10 @@ func TestParse2(t *testing.T) {
`CREATE DATABASE a REGION "us-west-1"`,
`CREATE DATABASE a REGIONS = "us-west-1"`,
},
{
`CREATE DATABASE a PRIMARY REGION = "us-west-1"`,
`CREATE DATABASE a PRIMARY REGION "us-west-1"`,
},
{`CREATE TABLE a (b INT) WITH (fillfactor=100)`,
`CREATE TABLE a (b INT8)`},
{`CREATE TABLE a (b INT, UNIQUE INDEX foo (b))`,
Expand Down
56 changes: 41 additions & 15 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ func (u *sqlSymUnion) objectNamePrefixList() tree.ObjectNamePrefixList {
%type <tree.Statement> alter_database_to_schema_stmt
%type <tree.Statement> alter_database_add_region_stmt
%type <tree.Statement> alter_database_drop_region_stmt
%type <tree.Statement> alter_database_survive_stmt
%type <tree.Statement> alter_database_survival_goal_stmt
%type <tree.Statement> alter_database_primary_region_stmt
%type <tree.Statement> alter_zone_database_stmt
%type <tree.Statement> alter_database_owner

Expand Down Expand Up @@ -955,9 +956,9 @@ func (u *sqlSymUnion) objectNamePrefixList() tree.ObjectNamePrefixList {

%type <str> opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause
%type <tree.NameList> opt_regions_list
%type <str> region_name
%type <str> region_name primary_region_clause opt_primary_region_clause
%type <tree.NameList> region_name_list
%type <tree.SurvivalGoal> survive_clause opt_survive_clause
%type <tree.SurvivalGoal> survival_goal_clause opt_survival_goal_clause
%type <tree.RegionalAffinity> regional_affinity
%type <int32> opt_connection_limit

Expand Down Expand Up @@ -1458,6 +1459,7 @@ alter_sequence_options_stmt:
// ALTER DATABASE <name> CONVERT TO SCHEMA WITH PARENT <name>
// ALTER DATABASE <name> ADD REGIONS <regions>
// ALTER DATABASE <name> DROP REGIONS <regions>
// ALTER DATABASE <name> SET PRIMARY REGION <region>
// ALTER DATABASE <name> SURVIVE <failure type>
// %SeeAlso: WEBDOCS/alter-database.html
alter_database_stmt:
Expand All @@ -1467,7 +1469,8 @@ alter_database_stmt:
| alter_database_to_schema_stmt
| alter_database_add_region_stmt
| alter_database_drop_region_stmt
| alter_database_survive_stmt
| alter_database_survival_goal_stmt
| alter_database_primary_region_stmt
// ALTER DATABASE has its error help token here because the ALTER DATABASE
// prefix is spread over multiple non-terminals.
| ALTER DATABASE error // SHOW HELP: ALTER DATABASE
Expand Down Expand Up @@ -1496,15 +1499,24 @@ alter_database_drop_region_stmt:
}
}

alter_database_survive_stmt:
ALTER DATABASE database_name survive_clause
alter_database_survival_goal_stmt:
ALTER DATABASE database_name survival_goal_clause
{
$$.val = &tree.AlterDatabaseSurvivalGoal{
Name: tree.Name($3),
SurvivalGoal: $4.survivalGoal(),
}
}

alter_database_primary_region_stmt:
ALTER DATABASE database_name primary_region_clause
{
$$.val = &tree.AlterDatabasePrimaryRegion{
Name: tree.Name($3),
PrimaryRegion: tree.Name($4),
}
}

// %Help: ALTER RANGE - change the parameters of a range
// %Category: DDL
// %Text:
Expand Down Expand Up @@ -7544,7 +7556,7 @@ transaction_deferrable_mode:
// %Text: CREATE DATABASE [IF NOT EXISTS] <name>
// %SeeAlso: WEBDOCS/create-database.html
create_database_stmt:
CREATE DATABASE database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_regions_list opt_survive_clause
CREATE DATABASE database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause
{
$$.val = &tree.CreateDatabase{
Name: tree.Name($3),
Expand All @@ -7553,11 +7565,12 @@ create_database_stmt:
Collate: $7,
CType: $8,
ConnectionLimit: $9.int32(),
Regions: $10.nameList(),
SurvivalGoal: $11.survivalGoal(),
PrimaryRegion: tree.Name($10),
Regions: $11.nameList(),
SurvivalGoal: $12.survivalGoal(),
}
}
| CREATE DATABASE IF NOT EXISTS database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_regions_list opt_survive_clause
| CREATE DATABASE IF NOT EXISTS database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause
{
$$.val = &tree.CreateDatabase{
IfNotExists: true,
Expand All @@ -7567,12 +7580,25 @@ create_database_stmt:
Collate: $10,
CType: $11,
ConnectionLimit: $12.int32(),
Regions: $13.nameList(),
SurvivalGoal: $14.survivalGoal(),
PrimaryRegion: tree.Name($13),
Regions: $14.nameList(),
SurvivalGoal: $15.survivalGoal(),
}
}
| CREATE DATABASE error // SHOW HELP: CREATE DATABASE

opt_primary_region_clause:
primary_region_clause
| /* EMPTY */
{
$$ = ""
}

primary_region_clause:
PRIMARY REGION opt_equal region_name {
$$ = $4
}

opt_regions_list:
region_or_regions opt_equal region_name_list
{
Expand All @@ -7587,7 +7613,7 @@ region_or_regions:
REGION
| REGIONS

survive_clause:
survival_goal_clause:
SURVIVE opt_equal REGION FAILURE
{
$$.val = tree.SurvivalGoalRegionFailure
Expand All @@ -7597,8 +7623,8 @@ survive_clause:
$$.val = tree.SurvivalGoalZoneFailure
}

opt_survive_clause:
survive_clause
opt_survival_goal_clause:
survival_goal_clause
| /* EMPTY */
{
$$.val = tree.SurvivalGoalDefault
Expand Down
Loading

0 comments on commit 81ac191

Please sign in to comment.