Skip to content

Commit 63368b8

Browse files
committed
Add MySQL INT type display width and SHOW CREATE TEMPORARY TABLE support
- Handle MySQL-compatible INT types (INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT) by ignoring the display width parameter like INT(11) - Handle UNSIGNED and SIGNED modifiers for INT types, appending them to the type name - Fix SHOW CREATE TEMPORARY TABLE parsing to skip TEMPORARY keyword Fixes 20 statements in 02271_int_sql_compatibility test.
1 parent b3b61bf commit 63368b8

2 files changed

Lines changed: 28 additions & 25 deletions

File tree

parser/parser.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,29 @@ func (p *Parser) parseDataType() *ast.DataType {
32263226
}
32273227
p.nextToken()
32283228

3229+
// For MySQL-compatible INT types, handle display width and UNSIGNED/SIGNED
3230+
upperName := strings.ToUpper(dt.Name)
3231+
isMySQLIntType := upperName == "INT" || upperName == "TINYINT" || upperName == "SMALLINT" ||
3232+
upperName == "MEDIUMINT" || upperName == "BIGINT"
3233+
3234+
if isMySQLIntType && p.currentIs(token.LPAREN) {
3235+
// Skip the display width parameter (e.g., INT(11))
3236+
p.nextToken() // skip (
3237+
for !p.currentIs(token.RPAREN) && !p.currentIs(token.EOF) {
3238+
p.nextToken()
3239+
}
3240+
p.expect(token.RPAREN)
3241+
}
3242+
3243+
// Handle UNSIGNED/SIGNED modifiers for MySQL INT types
3244+
if isMySQLIntType && p.currentIs(token.IDENT) {
3245+
modifier := strings.ToUpper(p.current.Value)
3246+
if modifier == "UNSIGNED" || modifier == "SIGNED" {
3247+
dt.Name = dt.Name + " " + p.current.Value
3248+
p.nextToken()
3249+
}
3250+
}
3251+
32293252
// Parse type parameters
32303253
if p.currentIs(token.LPAREN) {
32313254
dt.HasParentheses = true
@@ -4426,7 +4449,10 @@ func (p *Parser) parseShow() ast.Statement {
44264449
}
44274450
} else {
44284451
show.ShowType = ast.ShowCreate
4429-
// Handle SHOW CREATE TABLE, etc.
4452+
// Handle SHOW CREATE TABLE, SHOW CREATE TEMPORARY TABLE, etc.
4453+
if p.currentIs(token.TEMPORARY) {
4454+
p.nextToken()
4455+
}
44304456
if p.currentIs(token.TABLE) {
44314457
p.nextToken()
44324458
}
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt1": true,
4-
"stmt10": true,
5-
"stmt11": true,
6-
"stmt12": true,
7-
"stmt13": true,
8-
"stmt14": true,
9-
"stmt15": true,
10-
"stmt16": true,
11-
"stmt17": true,
12-
"stmt18": true,
13-
"stmt19": true,
14-
"stmt2": true,
15-
"stmt20": true,
16-
"stmt3": true,
17-
"stmt4": true,
18-
"stmt5": true,
19-
"stmt6": true,
20-
"stmt7": true,
21-
"stmt8": true,
22-
"stmt9": true
23-
}
24-
}
1+
{}

0 commit comments

Comments
 (0)