Skip to content
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
718 changes: 718 additions & 0 deletions ast/admin.go

Large diffs are not rendered by default.

43 changes: 40 additions & 3 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2475,9 +2475,18 @@ func (n *PlacementOption) Restore(ctx *format.RestoreCtx) error {

// ResourceGroupOption is used for parsing resource group option.
type ResourceGroupOption struct {
Tp ResourceUnitType
StrValue string
UintValue uint64
Tp ResourceUnitType
StrValue string
UintValue uint64
// IntValue holds the ResourceGroupThreadPriority value, which may be
// negative (MySQL allows -20..19).
IntValue int64
// BoolValue distinguishes ResourceGroupEnable's ENABLE (true) from
// DISABLE (false).
BoolValue bool
// Force is the optional FORCE modifier of DISABLE (MySQL syntax
// ALTER RESOURCE GROUP ... DISABLE FORCE).
Force bool
Burstable BurstableType
RunawayOptionList []*ResourceGroupRunawayOption
BackgroundOptions []*ResourceGroupBackgroundOption
Expand All @@ -2500,6 +2509,13 @@ const (
ResourceUnlimitedOption
ResourceGroupRunaway
ResourceGroupBackground

// MySQL-syntax resource group options (CREATE/ALTER RESOURCE GROUP
// per the MySQL reference manual rather than the TiDB dialect).
ResourceGroupType
ResourceGroupVCPU
ResourceGroupThreadPriority
ResourceGroupEnable
)

type BurstableType int
Expand Down Expand Up @@ -2564,6 +2580,27 @@ func (n *ResourceGroupOption) Restore(ctx *format.RestoreCtx) error {
} else {
ctx.WritePlain("NULL")
}
case ResourceGroupType:
ctx.WriteKeyWord("TYPE ")
ctx.WritePlain("= ")
ctx.WriteKeyWord(n.StrValue)
case ResourceGroupVCPU:
ctx.WriteKeyWord("VCPU ")
ctx.WritePlain("= ")
ctx.WritePlain(n.StrValue)
case ResourceGroupThreadPriority:
ctx.WriteKeyWord("THREAD_PRIORITY ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.IntValue)
case ResourceGroupEnable:
if n.BoolValue {
ctx.WriteKeyWord("ENABLE")
} else {
ctx.WriteKeyWord("DISABLE")
if n.Force {
ctx.WriteKeyWord(" FORCE")
}
}
case ResourceGroupBackground:
ctx.WritePlain("BACKGROUND ")
ctx.WritePlain("= ")
Expand Down
84 changes: 84 additions & 0 deletions ast/sem.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,30 @@ const (
ResignalCommand = "RESIGNAL"
// GetDiagnosticsCommand represents GET DIAGNOSTICS statement
GetDiagnosticsCommand = "GET DIAGNOSTICS"
// CheckTableCommand represents CHECK TABLE statement
CheckTableCommand = "CHECK TABLE"
// ChecksumTableCommand represents CHECKSUM TABLE statement
ChecksumTableCommand = "CHECKSUM TABLE"
// RepairTablesCommand represents REPAIR TABLE statement
RepairTablesCommand = "REPAIR TABLE"
// CreateLoadableFunctionCommand represents CREATE FUNCTION statement for loadable functions
CreateLoadableFunctionCommand = "CREATE FUNCTION"
// InstallComponentCommand represents INSTALL COMPONENT statement
InstallComponentCommand = "INSTALL COMPONENT"
// UninstallComponentCommand represents UNINSTALL COMPONENT statement
UninstallComponentCommand = "UNINSTALL COMPONENT"
// InstallPluginCommand represents INSTALL PLUGIN statement
InstallPluginCommand = "INSTALL PLUGIN"
// UninstallPluginCommand represents UNINSTALL PLUGIN statement
UninstallPluginCommand = "UNINSTALL PLUGIN"
// CloneCommand represents CLONE statement
CloneCommand = "CLONE"
// CacheIndexCommand represents CACHE INDEX statement
CacheIndexCommand = "CACHE INDEX"
// LoadIndexCommand represents LOAD INDEX INTO CACHE statement
LoadIndexCommand = "LOAD INDEX INTO CACHE"
// ResetPersistCommand represents RESET PERSIST statement
ResetPersistCommand = "RESET PERSIST"
// UnknownCommand represents unknown statements
UnknownCommand = "UNKNOWN"
// SetOprCommand represents UNION/INTERSECT/EXCEPT statement
Expand Down Expand Up @@ -1362,3 +1386,63 @@ func (n *ResignalStmt) SEMCommand() string {
func (n *GetDiagnosticsStmt) SEMCommand() string {
return GetDiagnosticsCommand
}

// SEMCommand returns the command string for the statement.
func (n *CheckTableStmt) SEMCommand() string {
return CheckTableCommand
}

// SEMCommand returns the command string for the statement.
func (n *ChecksumTableStmt) SEMCommand() string {
return ChecksumTableCommand
}

// SEMCommand returns the command string for the statement.
func (n *RepairTablesStmt) SEMCommand() string {
return RepairTablesCommand
}

// SEMCommand returns the command string for the statement.
func (n *CreateLoadableFunctionStmt) SEMCommand() string {
return CreateLoadableFunctionCommand
}

// SEMCommand returns the command string for the statement.
func (n *InstallComponentStmt) SEMCommand() string {
return InstallComponentCommand
}

// SEMCommand returns the command string for the statement.
func (n *UninstallComponentStmt) SEMCommand() string {
return UninstallComponentCommand
}

// SEMCommand returns the command string for the statement.
func (n *InstallPluginStmt) SEMCommand() string {
return InstallPluginCommand
}

// SEMCommand returns the command string for the statement.
func (n *UninstallPluginStmt) SEMCommand() string {
return UninstallPluginCommand
}

// SEMCommand returns the command string for the statement.
func (n *CloneStmt) SEMCommand() string {
return CloneCommand
}

// SEMCommand returns the command string for the statement.
func (n *CacheIndexStmt) SEMCommand() string {
return CacheIndexCommand
}

// SEMCommand returns the command string for the statement.
func (n *LoadIndexStmt) SEMCommand() string {
return LoadIndexCommand
}

// SEMCommand returns the command string for the statement.
func (n *ResetPersistStmt) SEMCommand() string {
return ResetPersistCommand
}
17 changes: 17 additions & 0 deletions parser/keyword_classes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions parser/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ var Keywords = []KeywordsType{
{"AFFINITY", false, "unreserved"},
{"AFTER", false, "unreserved"},
{"AGAINST", false, "unreserved"},
{"AGGREGATE", false, "unreserved"},
{"AGO", false, "unreserved"},
{"ALGORITHM", false, "unreserved"},
{"ALWAYS", false, "unreserved"},
Expand Down Expand Up @@ -309,6 +310,7 @@ var Keywords = []KeywordsType{
{"CASCADED", false, "unreserved"},
{"CAUSAL", false, "unreserved"},
{"CHAIN", false, "unreserved"},
{"CHANGED", false, "unreserved"},
{"CHANNEL", false, "unreserved"},
{"CHARSET", false, "unreserved"},
{"CHECKPOINT", false, "unreserved"},
Expand All @@ -318,6 +320,7 @@ var Keywords = []KeywordsType{
{"CLEANUP", false, "unreserved"},
{"CLIENT", false, "unreserved"},
{"CLIENT_ERRORS_SUMMARY", false, "unreserved"},
{"CLONE", false, "unreserved"},
{"CLOSE", false, "unreserved"},
{"CLUSTER", false, "unreserved"},
{"CLUSTERED", false, "unreserved"},
Expand All @@ -330,6 +333,7 @@ var Keywords = []KeywordsType{
{"COMMIT", false, "unreserved"},
{"COMMITTED", false, "unreserved"},
{"COMPACT", false, "unreserved"},
{"COMPONENT", false, "unreserved"},
{"COMPRESSED", false, "unreserved"},
{"COMPRESSION", false, "unreserved"},
{"COMPRESSION_LEVEL", false, "unreserved"},
Expand Down Expand Up @@ -393,6 +397,7 @@ var Keywords = []KeywordsType{
{"EXPLORE", false, "unreserved"},
{"EXTENDED", false, "unreserved"},
{"FAILED_LOGIN_ATTEMPTS", false, "unreserved"},
{"FAST", false, "unreserved"},
{"FAULTS", false, "unreserved"},
{"FIELDS", false, "unreserved"},
{"FILE", false, "unreserved"},
Expand Down Expand Up @@ -424,6 +429,7 @@ var Keywords = []KeywordsType{
{"INCREMENTAL", false, "unreserved"},
{"INDEXES", false, "unreserved"},
{"INSERT_METHOD", false, "unreserved"},
{"INSTALL", false, "unreserved"},
{"INSTANCE", false, "unreserved"},
{"INVISIBLE", false, "unreserved"},
{"INVOKER", false, "unreserved"},
Expand All @@ -438,6 +444,7 @@ var Keywords = []KeywordsType{
{"LAST", false, "unreserved"},
{"LASTVAL", false, "unreserved"},
{"LAST_BACKUP", false, "unreserved"},
{"LEAVES", false, "unreserved"},
{"LESS", false, "unreserved"},
{"LEVEL", false, "unreserved"},
{"LIST", false, "unreserved"},
Expand Down Expand Up @@ -508,8 +515,10 @@ var Keywords = []KeywordsType{
{"PASSWORD_LOCK_TIME", false, "unreserved"},
{"PAUSE", false, "unreserved"},
{"PERCENT", false, "unreserved"},
{"PERSIST", false, "unreserved"},
{"PER_DB", false, "unreserved"},
{"PER_TABLE", false, "unreserved"},
{"PLUGIN", false, "unreserved"},
{"PLUGINS", false, "unreserved"},
{"POINT", false, "unreserved"},
{"POLICY", false, "unreserved"},
Expand Down Expand Up @@ -549,6 +558,7 @@ var Keywords = []KeywordsType{
{"RESTORE", false, "unreserved"},
{"RESTORES", false, "unreserved"},
{"RESUME", false, "unreserved"},
{"RETURNS", false, "unreserved"},
{"REUSE", false, "unreserved"},
{"REVERSE", false, "unreserved"},
{"ROLE", false, "unreserved"},
Expand Down Expand Up @@ -587,6 +597,7 @@ var Keywords = []KeywordsType{
{"SLOW", false, "unreserved"},
{"SNAPSHOT", false, "unreserved"},
{"SOME", false, "unreserved"},
{"SONAME", false, "unreserved"},
{"SOURCE", false, "unreserved"},
{"SQL_BUFFER_RESULT", false, "unreserved"},
{"SQL_CACHE", false, "unreserved"},
Expand All @@ -611,6 +622,7 @@ var Keywords = []KeywordsType{
{"STATUS", false, "unreserved"},
{"STORAGE", false, "unreserved"},
{"STRICT_FORMAT", false, "unreserved"},
{"STRING", false, "unreserved"},
{"SUBJECT", false, "unreserved"},
{"SUBPARTITION", false, "unreserved"},
{"SUBPARTITIONS", false, "unreserved"},
Expand All @@ -626,6 +638,7 @@ var Keywords = []KeywordsType{
{"TEMPTABLE", false, "unreserved"},
{"TEXT", false, "unreserved"},
{"THAN", false, "unreserved"},
{"THREAD_PRIORITY", false, "unreserved"},
{"TIKV_IMPORTER", false, "unreserved"},
{"TIME", false, "unreserved"},
{"TIMEOUT", false, "unreserved"},
Expand All @@ -648,12 +661,16 @@ var Keywords = []KeywordsType{
{"UNCOMMITTED", false, "unreserved"},
{"UNDEFINED", false, "unreserved"},
{"UNICODE", false, "unreserved"},
{"UNINSTALL", false, "unreserved"},
{"UNKNOWN", false, "unreserved"},
{"UNSET", false, "unreserved"},
{"UPGRADE", false, "unreserved"},
{"USER", false, "unreserved"},
{"USE_FRM", false, "unreserved"},
{"VALIDATION", false, "unreserved"},
{"VALUE", false, "unreserved"},
{"VARIABLES", false, "unreserved"},
{"VCPU", false, "unreserved"},
{"VECTOR", false, "unreserved"},
{"VIEW", false, "unreserved"},
{"VISIBLE", false, "unreserved"},
Expand Down
4 changes: 2 additions & 2 deletions parser/keywords_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func TestKeywords(t *testing.T) {
}

func TestKeywordsLength(t *testing.T) {
if !reflect.DeepEqual(690, len(parser.Keywords)) {
t.Fatalf("got %v, want %v", len(parser.Keywords), 690)
if !reflect.DeepEqual(707, len(parser.Keywords)) {
t.Fatalf("got %v, want %v", len(parser.Keywords), 707)
}

reservedNr := 0
Expand Down
Loading
Loading