Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement and test drop temporary table ... and show create table statements #8781

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/dolthub/fslock v0.0.3
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
github.com/dolthub/vitess v0.0.0-20250115003116-d6f17c220028
github.com/dolthub/vitess v0.0.0-20250122194149-eae2927a6092
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568
Expand Down Expand Up @@ -56,7 +56,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.19.1-0.20250122180808-0e32f1d293ee
github.com/dolthub/go-mysql-server v0.19.1-0.20250122213503-b6b01d135942
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/esote/minmaxheap v1.0.0
Expand Down
10 changes: 4 additions & 6 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90 h1:Sni8jrP0sy/w9ZYXoff4g/ixe+7bFCZlfCqXKJSU+zM=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122100341-c5d0e527c855 h1:TpoMmjRofO1JOTxp14t/pDyr0RLi29ybLAMhV3ZZ+R0=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122100341-c5d0e527c855/go.mod h1:5HtKnb+IAiv+27bo50KGANbUB4HAzGEF9rlFF2ZBLZg=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122180808-0e32f1d293ee h1:/rxD9Pn5WpHso6dH0HE3FKRDMMZ1b7ueqo9Q18rOr6s=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122180808-0e32f1d293ee/go.mod h1:5HtKnb+IAiv+27bo50KGANbUB4HAzGEF9rlFF2ZBLZg=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122213503-b6b01d135942 h1:yToeSVuTw0iIbMt+4EgwDF84ekV5FVzauZgQVsllKt0=
github.com/dolthub/go-mysql-server v0.19.1-0.20250122213503-b6b01d135942/go.mod h1:54jSNVxgjBO+bxSA3+KrMfnWjGbbq3nf7ZdLp3Vcl+E=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand All @@ -195,8 +193,8 @@ github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9X
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/swiss v0.1.0 h1:EaGQct3AqeP/MjASHLiH6i4TAmgbG/c4rA6a1bzCOPc=
github.com/dolthub/swiss v0.1.0/go.mod h1:BeucyB08Vb1G9tumVN3Vp/pyY4AMUnr9p7Rz7wJ7kAQ=
github.com/dolthub/vitess v0.0.0-20250115003116-d6f17c220028 h1:lgcIsCUaNDde+lS+aYGYGML95qrQlBMEpaXFN1Pmk+4=
github.com/dolthub/vitess v0.0.0-20250115003116-d6f17c220028/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250122194149-eae2927a6092 h1:DXG7Tw0jCM3VUG0C2pWEHGexEzmZuhQTPGqIn5aE+k0=
github.com/dolthub/vitess v0.0.0-20250122194149-eae2927a6092/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/mvdata/engine_table_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (s *SqlEngineTableWriter) createTable() error {
sqlCols = append(sqlCols, fmt.Sprintf("PRIMARY KEY (%s)", pks))
}

createTable := sql.GenerateCreateTableStatement(s.tableName, sqlCols, "", sql.CharacterSet_utf8mb4.String(), sql.Collation_Default.String(), "")
createTable := sql.GenerateCreateTableStatement(s.tableName, sqlCols, "", "", sql.CharacterSet_utf8mb4.String(), sql.Collation_Default.String(), "")
_, iter, _, err := s.se.Query(s.sqlCtx, createTable)
if err != nil {
return err
Expand Down
42 changes: 39 additions & 3 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -7591,7 +7591,7 @@ var DoltTempTableScripts = []queries.ScriptTest{
{
Query: "show create table t;",
Expected: []sql.Row{
{"t", "CREATE TABLE `t` (\n" +
{"t", "CREATE TEMPORARY TABLE `t` (\n" +
" `i` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`i`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
Expand All @@ -7606,7 +7606,7 @@ var DoltTempTableScripts = []queries.ScriptTest{
{
Query: "show create table t;",
Expected: []sql.Row{
{"t", "CREATE TABLE `t` (\n" +
{"t", "CREATE TEMPORARY TABLE `t` (\n" +
" `i` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`i`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
Expand All @@ -7629,7 +7629,7 @@ var DoltTempTableScripts = []queries.ScriptTest{
{
Query: "show create table t;",
Expected: []sql.Row{
{"t", "CREATE TABLE `t` (\n" +
{"t", "CREATE TEMPORARY TABLE `t` (\n" +
" `i` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`i`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
Expand Down Expand Up @@ -7670,4 +7670,40 @@ var DoltTempTableScripts = []queries.ScriptTest{
},
},
},
{
Name: "drop temporary table behavior",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should go in GMS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can't, gms doesn't support temporary tables

Dialect: "mysql",
SetUpScript: []string{
"create table t (i int);",
"create temporary table tmp (i int);",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "show create table t;",
Expected: []sql.Row{
{"t", "CREATE TABLE `t` (\n" +
" `i` int\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "show create table tmp;",
Expected: []sql.Row{
{"tmp", "CREATE TEMPORARY TABLE `tmp` (\n" +
" `i` int\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "drop temporary table t;",
ExpectedErr: sql.ErrUnknownTable,
},
{
Query: "drop temporary table tmp;",
Expected: []sql.Row{
{types.NewOkResult(0)},
},
},
},
},
}
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/sqlfmt/schema_fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func GenerateCreateTableStatement(tblName string, sch schema.Schema, fks []doltd
}

coll := sql.CollationID(sch.GetCollation())
createTableStmt := sql.GenerateCreateTableStatement(tblName, colStmts, "", coll.CharacterSet().Name(), coll.Name(), sch.GetComment())
createTableStmt := sql.GenerateCreateTableStatement(tblName, colStmts, "", "", coll.CharacterSet().Name(), coll.Name(), sch.GetComment())
return fmt.Sprintf("%s;", createTableStmt), nil
}

Expand Down
Loading