Skip to content

Commit

Permalink
parser: fix STATS_AUTO_RECALC syntax (pingcap#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauhg authored and leoppro committed Aug 20, 2019
1 parent 310a6da commit c7b203b
Show file tree
Hide file tree
Showing 5 changed files with 6,927 additions and 6,854 deletions.
12 changes: 11 additions & 1 deletion ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ const (
TableOptionDelayKeyWrite
TableOptionRowFormat
TableOptionStatsPersistent
TableOptionStatsAutoRecalc
TableOptionShardRowID
TableOptionPreSplitRegion
TableOptionPackKeys
Expand Down Expand Up @@ -1591,6 +1592,7 @@ const (
// TableOption is used for parsing table option from SQL.
type TableOption struct {
Tp TableOptionType
Default bool
StrValue string
UintValue uint64
}
Expand Down Expand Up @@ -1698,6 +1700,14 @@ func (n *TableOption) Restore(ctx *RestoreCtx) error {
ctx.WritePlain("= ")
ctx.WriteKeyWord("DEFAULT")
ctx.WritePlain(" /* TableOptionStatsPersistent is not supported */ ")
case TableOptionStatsAutoRecalc:
ctx.WriteKeyWord("STATS_AUTO_RECALC ")
ctx.WritePlain("= ")
if n.Default {
ctx.WriteKeyWord("DEFAULT")
} else {
ctx.WritePlainf("%d", n.UintValue)
}
case TableOptionShardRowID:
ctx.WriteKeyWord("SHARD_ROW_ID_BITS ")
ctx.WritePlainf("= %d", n.UintValue)
Expand Down Expand Up @@ -1731,7 +1741,7 @@ func (n *TableOption) Restore(ctx *RestoreCtx) error {
case TableOptionStatsSamplePages:
ctx.WriteKeyWord("STATS_SAMPLE_PAGES ")
ctx.WritePlain("= ")
if n.UintValue == 0 {
if n.Default {
ctx.WriteKeyWord("DEFAULT")
} else {
ctx.WritePlainf("%d", n.UintValue)
Expand Down
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ var tokenMap = map[string]int{
"STATS_HISTOGRAMS": statsHistograms,
"STATS_HEALTHY": statsHealthy,
"STATS_META": statsMeta,
"STATS_AUTO_RECALC": statsAutoRecalc,
"STATS_PERSISTENT": statsPersistent,
"STATS_SAMPLE_PAGES": statsSamplePages,
"STATUS": status,
Expand Down
Loading

0 comments on commit c7b203b

Please sign in to comment.