Merged PRs
dolt
go-mysql-server
- 528: Hacky version of read committed isolation level, which begins a new t…
…ransaction on every statement. Basically it's read committed, but without the ability to turn off auto commit - 519: Fix explicit DEFAULT value in insert query
It seems thatgo-mysql-server
is not compatible with insert query like:WhereasINSERT INTO `users` (`id`, `deleted`) VALUES (1, DEFAULT)
DEFAULT
is just to specifydeleted
columns should use column default value explicitly.
The issue could be demostrated using below code:package main import ( dbsql "database/sql" sqle "github.com/dolthub/go-mysql-server" "github.com/dolthub/go-mysql-server/auth" "github.com/dolthub/go-mysql-server/memory" "github.com/dolthub/go-mysql-server/server" _ "github.com/go-sql-driver/mysql" ) func main() { db, _ := dbsql.Open("mysql", "root:@tcp(127.0.0.1:3307)/test") defer db.Close() query := `CREATE TABLE users ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, deleted tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4` stmt, _ := db.Prepare(query) stmt.Exec() _, err := db.Exec("INSERT INTO `users` (`id`, `deleted`) VALUES (1, DEFAULT)") if err != nil { panic(err.Error()) } stmtOut, _ := db.Prepare("SELECT `deleted` FROM `users` WHERE `id` = 1") defer stmtOut.Close() deleted := true err = stmtOut.QueryRow().Scan(&deleted) if err != nil { panic(err.Error()) } if deleted == true { panic("Wrong deleted value") } } var engine *sqle.Engine func init() { engine = sqle.NewDefault() db := memory.NewDatabase("test") engine.AddDatabase(db) config := server.Config{ Protocol: "tcp", Address: "localhost:3307", Auth: auth.NewNativeSingle("root", "", auth.AllPermissions), } s, _ := server.NewDefaultServer(config, engine) go s.Start() }
This pull request should avoid such issue by turning explicit`db.Exec("INSERT INTO `users` (`id`, `deleted`) VALUES (1, DEFAULT)")` will result in error: Error 1105: plan is not resolved because of node '*plan.Values'
DEFAULT
in insert query to implicit.
Closed Issues
- 1782: Conflict Logging/Resolution for
UNIQUE KEY
s