Skip to content

Commit

Permalink
[parser] Parser: Support SQL_BIG_RESULT, SQL_SMALL_RESULT, SQL_BUFFER…
Browse files Browse the repository at this point in the history
…_RESULT (#304)

* Support SQL_BIG_RESULT, SQL_SMALL_RESULT, SQL_BUFFER_RESULT

* update test case

* code formatting

* word wrap
  • Loading branch information
b41sh authored and ti-chi-bot committed Oct 9, 2021
1 parent 7038c2f commit e8b48ae
Show file tree
Hide file tree
Showing 6 changed files with 6,442 additions and 6,308 deletions.
12 changes: 12 additions & 0 deletions parser/ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,18 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
ctx.WritePlain(" ")
}

if n.SelectStmtOpts.SQLSmallResult {
ctx.WriteKeyWord("SQL_SMALL_RESULT ")
}

if n.SelectStmtOpts.SQLBigResult {
ctx.WriteKeyWord("SQL_BIG_RESULT ")
}

if n.SelectStmtOpts.SQLBufferResult {
ctx.WriteKeyWord("SQL_BUFFER_RESULT ")
}

if !n.SelectStmtOpts.SQLCache {
ctx.WriteKeyWord("SQL_NO_CACHE ")
}
Expand Down
15 changes: 9 additions & 6 deletions parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1974,12 +1974,15 @@ func (i Ident) String() string {

// SelectStmtOpts wrap around select hints and switches
type SelectStmtOpts struct {
Distinct bool
SQLCache bool
CalcFoundRows bool
StraightJoin bool
Priority mysql.PriorityEnum
TableHints []*TableOptimizerHint
Distinct bool
SQLBigResult bool
SQLBufferResult bool
SQLCache bool
SQLSmallResult bool
CalcFoundRows bool
StraightJoin bool
Priority mysql.PriorityEnum
TableHints []*TableOptimizerHint
}

// TableOptimizerHint is Table level optimizer hint
Expand Down
3 changes: 3 additions & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,12 @@ var tokenMap = map[string]int{
"SOME": some,
"SPLIT": split,
"SQL": sql,
"SQL_BIG_RESULT": sqlBigResult,
"SQL_BUFFER_RESULT": sqlBufferResult,
"SQL_CACHE": sqlCache,
"SQL_CALC_FOUND_ROWS": sqlCalcFoundRows,
"SQL_NO_CACHE": sqlNoCache,
"SQL_SMALL_RESULT": sqlSmallResult,
"SOURCE": source,
"SSL": ssl,
"START": start,
Expand Down
Loading

0 comments on commit e8b48ae

Please sign in to comment.