Skip to content

Commit

Permalink
implement drop temporary table
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cor committed Jan 22, 2025
1 parent d6f17c2 commit eae2927
Show file tree
Hide file tree
Showing 4 changed files with 7,777 additions and 7,681 deletions.
6 changes: 5 additions & 1 deletion go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,11 @@ func (node *DDL) Format(buf *TrackedBuffer) {
}
buf.Myprintf(fmt.Sprintf("%s event%s %v", node.Action, exists, node.EventSpec.EventName))
} else {
buf.Myprintf("%s table%s %v", node.Action, exists, node.FromTables)
temporary := ""
if node.Temporary {
temporary = " " + TemporaryStr
}
buf.Myprintf("%s%s table%s %v", node.Action, temporary, exists, node.FromTables)
}
case RenameStr:
buf.Myprintf("%s table %v to %v", node.Action, node.FromTables[0], node.ToTables[0])
Expand Down
7 changes: 6 additions & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3777,10 +3777,15 @@ var (
}, {
input: "CREATE TABLE `dual` (id int)",
output: "create table `dual` (\n\tid int\n)",
}, {
},
{
input: "DROP TABLE `dual`",
output: "drop table `dual`",
},
{
input: "DROP TEMPORARY TABLE `dual`",
output: "drop temporary table `dual`",
},
{
input: "CREATE TABLE `t4` (`pk` int NOT NULL, `_tinytext` tinytext, `_text` text, `_longtext` longtext, `_mediumtext` mediumtext, PRIMARY KEY (`pk`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;",
output: "create table t4 (\n\tpk int not null,\n\t_tinytext tinytext,\n\t_text text,\n\t_longtext longtext,\n\t_mediumtext mediumtext,\n\tPRIMARY KEY (pk)\n) ENGINE InnoDB CHARACTER SET utf8mb3",
Expand Down
Loading

0 comments on commit eae2927

Please sign in to comment.