diff --git a/go/go.mod b/go/go.mod index eabb0783a7..8776b86532 100644 --- a/go/go.mod +++ b/go/go.mod @@ -57,7 +57,7 @@ require ( github.com/cespare/xxhash v1.1.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.18.1-0.20240403215131-bea58f6a1988 + github.com/dolthub/go-mysql-server v0.18.1-0.20240403225518-8145826df225 github.com/dolthub/swiss v0.1.0 github.com/goccy/go-json v0.10.2 github.com/google/go-github/v57 v57.0.0 diff --git a/go/go.sum b/go/go.sum index 8146631734..8b683df1e8 100644 --- a/go/go.sum +++ b/go/go.sum @@ -183,8 +183,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-20230524105445-af7e7991c97e h1:kPsT4a47cw1+y/N5SSCkma7FhAPw7KeGmD6c9PBZW9Y= github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168= -github.com/dolthub/go-mysql-server v0.18.1-0.20240403215131-bea58f6a1988 h1:a7GMWJBlE3gnPp7QEo2GQZhP5sBdF630JeW8X5rkSOU= -github.com/dolthub/go-mysql-server v0.18.1-0.20240403215131-bea58f6a1988/go.mod h1:SJleIOwC74u9tdUoGgVgM/eLlwVj3sJEFfx0sdStvW0= +github.com/dolthub/go-mysql-server v0.18.1-0.20240403225518-8145826df225 h1:63qiK4ooVG8yUrwwx8PzMQH2cBKQ3Fm/tzB8sRyiZ9U= +github.com/dolthub/go-mysql-server v0.18.1-0.20240403225518-8145826df225/go.mod h1:SJleIOwC74u9tdUoGgVgM/eLlwVj3sJEFfx0sdStvW0= github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488 h1:0HHu0GWJH0N6a6keStrHhUAK5/o9LVfkh44pvsV4514= github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488/go.mod h1:ehexgi1mPxRTk0Mok/pADALuHbvATulTh6gzr7NzZto= github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTEtT5tOBsCuCrlYnLRKpbJVJkDbrTRhwQ= diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go index 1dd4bd8694..56a9f2031c 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go @@ -342,30 +342,30 @@ var DescribeTableAsOfScriptTest = queries.ScriptTest{ { Query: "describe a as of @Commit1;", Expected: []sql.Row{ - {"pk", "int", "NO", "PRI", "NULL", ""}, - {"c1", "int", "YES", "", "NULL", ""}, + {"pk", "int", "NO", "PRI", nil, ""}, + {"c1", "int", "YES", "", nil, ""}, }, }, { Query: "describe a as of @Commit2;", Expected: []sql.Row{ - {"pk", "int", "NO", "PRI", "NULL", ""}, - {"c1", "int", "YES", "", "NULL", ""}, - {"c2", "varchar(20)", "YES", "", "NULL", ""}, + {"pk", "int", "NO", "PRI", nil, ""}, + {"c1", "int", "YES", "", nil, ""}, + {"c2", "varchar(20)", "YES", "", nil, ""}, }, }, { Query: "describe a as of @Commit3;", Expected: []sql.Row{ - {"pk", "int", "NO", "PRI", "NULL", ""}, - {"c2", "varchar(20)", "YES", "", "NULL", ""}, + {"pk", "int", "NO", "PRI", nil, ""}, + {"c2", "varchar(20)", "YES", "", nil, ""}, }, }, { Query: "describe a as of HEAD;", Expected: []sql.Row{ - {"pk", "int", "NO", "PRI", "NULL", ""}, - {"c2", "varchar(20)", "YES", "", "NULL", ""}, + {"pk", "int", "NO", "PRI", nil, ""}, + {"c2", "varchar(20)", "YES", "", nil, ""}, }, }, }, diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries_schema_override.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries_schema_override.go index d53d542479..f42766f8ea 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries_schema_override.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries_schema_override.go @@ -49,8 +49,8 @@ var SchemaOverrideTests = []queries.ScriptTest{ { Query: "describe t;", Expected: []sql.Row{ - {"pk", "int", "NO", "PRI", "NULL", ""}, - {"c2", "varchar(255)", "YES", "", "NULL", ""}, + {"pk", "int", "NO", "PRI", nil, ""}, + {"c2", "varchar(255)", "YES", "", nil, ""}, }, }, { diff --git a/go/libraries/doltcore/sqle/enginetest/privilege_test.go b/go/libraries/doltcore/sqle/enginetest/privilege_test.go index 8477288950..d2a2ac1931 100755 --- a/go/libraries/doltcore/sqle/enginetest/privilege_test.go +++ b/go/libraries/doltcore/sqle/enginetest/privilege_test.go @@ -589,8 +589,8 @@ var DoltOnlyRevisionDbPrivilegeTests = []queries.UserPrivilegeTest{ Host: "localhost", Query: "desc test;", Expected: []sql.Row{ - {"pk", "bigint", "NO", "PRI", "NULL", ""}, - {"a", "int", "YES", "", "NULL", ""}, + {"pk", "bigint", "NO", "PRI", nil, ""}, + {"a", "int", "YES", "", nil, ""}, }, }, }, @@ -641,8 +641,8 @@ var DoltOnlyRevisionDbPrivilegeTests = []queries.UserPrivilegeTest{ Host: "localhost", Query: "desc test;", Expected: []sql.Row{ - {"pk", "bigint", "NO", "PRI", "NULL", ""}, - {"a", "int", "YES", "MUL", "NULL", ""}, + {"pk", "bigint", "NO", "PRI", nil, ""}, + {"a", "int", "YES", "MUL", nil, ""}, }, }, { @@ -674,8 +674,8 @@ var DoltOnlyRevisionDbPrivilegeTests = []queries.UserPrivilegeTest{ Host: "localhost", Query: "desc test;", Expected: []sql.Row{ - {"pk", "bigint", "NO", "PRI", "NULL", ""}, - {"a", "int", "YES", "", "NULL", ""}, + {"pk", "bigint", "NO", "PRI", nil, ""}, + {"a", "int", "YES", "", nil, ""}, }, }, }, diff --git a/integration-tests/bats/create-views.bats b/integration-tests/bats/create-views.bats index a5e72b4127..a165761cbf 100644 --- a/integration-tests/bats/create-views.bats +++ b/integration-tests/bats/create-views.bats @@ -375,14 +375,14 @@ SQL run dolt sql -r csv -q "describe view1" [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 3 ] - [[ "${lines[1]}" =~ 'pk,int,NO,"",NULL,""' ]] || false - [[ "${lines[2]}" =~ 'val,int,YES,"",NULL,""' ]] || false + [[ "${lines[1]}" =~ 'pk,int,NO,"",,""' ]] || false + [[ "${lines[2]}" =~ 'val,int,YES,"",,""' ]] || false dolt sql -q "create view view2 as select pk from t" run dolt sql -r csv -q "describe view2" [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" =~ 'pk,int,NO,"",NULL,""' ]] || false + [[ "${lines[1]}" =~ 'pk,int,NO,"",,""' ]] || false dolt sql -q "create table t2(pk int primary key, val int)" dolt sql -q "insert into t values (1,1)" @@ -392,8 +392,8 @@ SQL run dolt sql -r csv -q "describe view3" [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 3 ] - [[ "${lines[1]}" =~ 'v1,int,YES,"",NULL,""' ]] || false - [[ "${lines[2]}" =~ 'v2,int,YES,"",NULL,""' ]] || false + [[ "${lines[1]}" =~ 'v1,int,YES,"",,""' ]] || false + [[ "${lines[2]}" =~ 'v2,int,YES,"",,""' ]] || false } @test "create-views: can correctly alter a view" { diff --git a/integration-tests/mysql-client-tests/node/index.js b/integration-tests/mysql-client-tests/node/index.js index bfeaf949f8..e7ebe20b52 100644 --- a/integration-tests/mysql-client-tests/node/index.js +++ b/integration-tests/mysql-client-tests/node/index.js @@ -21,7 +21,7 @@ const tests = [ Type: "int", Null: "NO", Key: "PRI", - Default: "NULL", + Default: null, Extra: "", }, { @@ -29,7 +29,7 @@ const tests = [ Type: "int", Null: "YES", Key: "", - Default: "NULL", + Default: null, Extra: "", }, ], diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/table.js b/integration-tests/mysql-client-tests/node/workbenchTests/table.js index 845933c174..ae1ea7c3e8 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/table.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/table.js @@ -55,7 +55,7 @@ export const tableTests = [ Type: "int", Null: "NO", Key: "PRI", - Default: "NULL", + Default: null, Extra: "", }, { @@ -63,7 +63,7 @@ export const tableTests = [ Type: "int", Null: "YES", Key: "", - Default: "NULL", + Default: null, Extra: "", }, ], diff --git a/integration-tests/mysql-client-tests/python/mysql.connector-test.py b/integration-tests/mysql-client-tests/python/mysql.connector-test.py index b7acd39e24..5edde38009 100644 --- a/integration-tests/mysql-client-tests/python/mysql.connector-test.py +++ b/integration-tests/mysql-client-tests/python/mysql.connector-test.py @@ -4,8 +4,8 @@ import sys QUERY_RESPONSE = [ {"create table test (pk int, `value` int, primary key(pk))": []}, {"describe test": [ - ('pk', 'int', 'NO', 'PRI', 'NULL', ''), - ('value', 'int', 'YES', '', 'NULL', '') + ('pk', 'int', 'NO', 'PRI', None, ''), + ('value', 'int', 'YES', '', None, '') ]}, {"insert into test (pk, `value`) values (0,0)": []}, {"select * from test": [(0, 0)]}, diff --git a/integration-tests/mysql-client-tests/python/pymysql-test.py b/integration-tests/mysql-client-tests/python/pymysql-test.py index fe5c148aad..dbbd8d61a8 100644 --- a/integration-tests/mysql-client-tests/python/pymysql-test.py +++ b/integration-tests/mysql-client-tests/python/pymysql-test.py @@ -4,8 +4,8 @@ import sys QUERY_RESPONSE = [ {"create table test (pk int, `value` int, primary key(pk))": ()}, {"describe test": ( - ('pk', 'int', 'NO', 'PRI', 'NULL', ''), - ('value', 'int', 'YES', '', 'NULL', '') + ('pk', 'int', 'NO', 'PRI', None, ''), + ('value', 'int', 'YES', '', None, '') )}, {"insert into test (pk, `value`) values (0,0)": ()}, {"select * from test": ((0, 0),)}, diff --git a/integration-tests/mysql-client-tests/python/sqlalchemy-test.py b/integration-tests/mysql-client-tests/python/sqlalchemy-test.py index 969d4a984b..a9a4b7b9fe 100644 --- a/integration-tests/mysql-client-tests/python/sqlalchemy-test.py +++ b/integration-tests/mysql-client-tests/python/sqlalchemy-test.py @@ -8,8 +8,8 @@ import sys QUERY_RESPONSE = [ {"create table test (pk int, `value` int, primary key(pk))": []}, {"describe test": [ - ('pk', 'int', 'NO', 'PRI', 'NULL', ''), - ('value', 'int', 'YES', '', 'NULL', '') + ('pk', 'int', 'NO', 'PRI', None, ''), + ('value', 'int', 'YES', '', None, '') ]}, {"insert into test (pk, `value`) values (0,0)": ()}, {"select * from test": [(0, 0)]}, diff --git a/integration-tests/mysql-client-tests/r/rmariadb-test.r b/integration-tests/mysql-client-tests/r/rmariadb-test.r index 16903185a8..c4175ebbe3 100644 --- a/integration-tests/mysql-client-tests/r/rmariadb-test.r +++ b/integration-tests/mysql-client-tests/r/rmariadb-test.r @@ -1,89 +1,89 @@ -library(RMariaDB) -library(DBI) - -args = commandArgs(trailingOnly=TRUE) - -user = args[1] -port = args[2] -db = args[3] - -conn = dbConnect(RMariaDB::MariaDB(), host="127.0.0.1", port = port, - username = user, dbname = db) - -# check standard queries -queries = list("create table test (pk int, value int, primary key(pk))", - "describe test", - "insert into test (pk, `value`) values (0,0)", - "select * from test") - -responses = list(NULL, - data.frame(Field = c("pk", "value"), Type = c("int", "int"), Null = c("NO", "YES"), Key = c("PRI", ""), Default = c("NULL", "NULL"), Extra = c("", ""), stringsAsFactors = FALSE), - NULL, - data.frame(pk = c(0), value = c(0), stringsAsFactors = FALSE)) - -for(i in 1:length(queries)) { - q = queries[[i]] - want = responses[[i]] - if (!is.null(want)) { - got <- dbGetQuery(conn, q) - if (!isTRUE(all.equal(want, got))) { - print(q) - print(want) - print(got) - quit(1) - } - } else { - dbExecute(conn, q) - } -} - -# check prepared statements -stmt <- dbSendStatement(conn, "INSERT INTO test values (?, ?)") -rs <- dbBind(stmt, list(1,1)) -rowsAff <- dbGetRowsAffected(rs) -dbClearResult(rs) - -if (rowsAff != 1) { - print("failed to execute prepared statement") - quit(1) -} - -got <- dbGetQuery(conn, "select * from test where pk = 1") -want = data.frame(pk = c(1), value = c(1)) -if (!isTRUE(all.equal(want, got))) { - print("unexpected prepared statement result") - print(got) - quit(1) -} - -dolt_queries = list("call DOLT_ADD('-A')", - "call dolt_commit('-m', 'my commit')", - "call dolt_checkout('-b', 'mybranch')", - "insert into test (pk, `value`) values (2,2)", - "call dolt_commit('-a', '-m', 'my commit2')", - "call dolt_checkout('main')", - "call dolt_merge('mybranch')") - -for(i in 1:length(dolt_queries)) { - q = dolt_queries[[i]] - dbExecute(conn, q) -} - -count <- dbGetQuery(conn, "select COUNT(*) as c from dolt_log") -want <- data.frame(c = c(3)) -ret <- all.equal(count, want) -if (!ret) { - print("Number of commits is incorrect") - quit(1) -} - -# Add a failing query and ensure that the connection does not quit. -# cc. https://github.com/dolthub/dolt/issues/3418 -try(dbExecute(conn, "insert into test values (0, 1)"), silent = TRUE) -one <- dbGetQuery(conn, "select 1 as pk") -ret <- one == data.frame(pk=1) -if (!ret) { - print("Number of commits is incorrect") - quit(1) -} - +library(RMariaDB) +library(DBI) + +args = commandArgs(trailingOnly=TRUE) + +user = args[1] +port = args[2] +db = args[3] + +conn = dbConnect(RMariaDB::MariaDB(), host="127.0.0.1", port = port, + username = user, dbname = db) + +# check standard queries +queries = list("create table test (pk int, value int, primary key(pk))", + "describe test", + "insert into test (pk, `value`) values (0,0)", + "select * from test") + +responses = list(NULL, + data.frame(Field = c("pk", "value"), Type = c("int", "int"), Null = c("NO", "YES"), Key = c("PRI", ""), Default = c(NA, NA), Extra = c("", ""), stringsAsFactors = FALSE), + NULL, + data.frame(pk = c(0), value = c(0), stringsAsFactors = FALSE)) + +for(i in 1:length(queries)) { + q = queries[[i]] + want = responses[[i]] + if (!is.null(want)) { + got <- dbGetQuery(conn, q) + if (!isTRUE(all.equal(want, got))) { + print(q) + print(want) + print(got) + quit(1) + } + } else { + dbExecute(conn, q) + } +} + +# check prepared statements +stmt <- dbSendStatement(conn, "INSERT INTO test values (?, ?)") +rs <- dbBind(stmt, list(1,1)) +rowsAff <- dbGetRowsAffected(rs) +dbClearResult(rs) + +if (rowsAff != 1) { + print("failed to execute prepared statement") + quit(1) +} + +got <- dbGetQuery(conn, "select * from test where pk = 1") +want = data.frame(pk = c(1), value = c(1)) +if (!isTRUE(all.equal(want, got))) { + print("unexpected prepared statement result") + print(got) + quit(1) +} + +dolt_queries = list("call DOLT_ADD('-A')", + "call dolt_commit('-m', 'my commit')", + "call dolt_checkout('-b', 'mybranch')", + "insert into test (pk, `value`) values (2,2)", + "call dolt_commit('-a', '-m', 'my commit2')", + "call dolt_checkout('main')", + "call dolt_merge('mybranch')") + +for(i in 1:length(dolt_queries)) { + q = dolt_queries[[i]] + dbExecute(conn, q) +} + +count <- dbGetQuery(conn, "select COUNT(*) as c from dolt_log") +want <- data.frame(c = c(3)) +ret <- all.equal(count, want) +if (!ret) { + print("Number of commits is incorrect") + quit(1) +} + +# Add a failing query and ensure that the connection does not quit. +# cc. https://github.com/dolthub/dolt/issues/3418 +try(dbExecute(conn, "insert into test values (0, 1)"), silent = TRUE) +one <- dbGetQuery(conn, "select 1 as pk") +ret <- one == data.frame(pk=1) +if (!ret) { + print("Number of commits is incorrect") + quit(1) +} + diff --git a/integration-tests/mysql-client-tests/r/rmysql-test.r b/integration-tests/mysql-client-tests/r/rmysql-test.r index 9e5a60f677..e38cd43fd8 100644 --- a/integration-tests/mysql-client-tests/r/rmysql-test.r +++ b/integration-tests/mysql-client-tests/r/rmysql-test.r @@ -1,59 +1,69 @@ -library(RMySQL) -library(DBI) - -args = commandArgs(trailingOnly=TRUE) - -user = args[1] -port = strtoi(args[2]) -db = args[3] - -conn = dbConnect(RMySQL::MySQL(), host="127.0.0.1", port = port, - username = user, dbname = db) - -# check standard queries -queries = list("create table test (pk int, value int, primary key(pk))", - "describe test", - "insert into test (pk, `value`) values (0,0)", - "select * from test") - -responses = list(NULL, - data.frame(Field = c("pk", "value"), Type = c("int", "int"), Null = c("NO", "YES"), Key = c("PRI", ""), Default = c("NULL", "NULL"), Extra = c("", ""), stringsAsFactors = FALSE), - NULL, - data.frame(pk = c(0), value = c(0), stringsAsFactors = FALSE)) - -for(i in 1:length(queries)) { - q = queries[[i]] - want = responses[[i]] - if (!is.null(want)) { - got <- dbGetQuery(conn, q) - if (!isTRUE(all.equal(want, got))) { - print(q) - print(want) - print(got) - quit(1) - } - } else { - dbExecute(conn, q) - } -} - -dolt_queries = list("call DOLT_ADD('-A')", - "call dolt_commit('-m', 'my commit')", - "call dolt_checkout('-b', 'mybranch')", - "insert into test (pk, `value`) values (1,1)", - "call dolt_commit('-a', '-m', 'my commit2')", - "call dolt_checkout('main')", - "call dolt_merge('mybranch')") - -for(i in 1:length(dolt_queries)) { - q = dolt_queries[[i]] - dbExecute(conn, q) -} - -count <- dbGetQuery(conn, "select COUNT(*) as c from dolt_log") -want <- data.frame(c = c(3)) -ret <- all.equal(count, want) -if (!ret) { - print("Number of commits is incorrect") - quit(1) -} +library(RMySQL) +library(DBI) + +args = commandArgs(trailingOnly=TRUE) + +user = args[1] +port = strtoi(args[2]) +db = args[3] + +conn = dbConnect(RMySQL::MySQL(), host="127.0.0.1", port = port, + username = user, dbname = db) + +# check standard queries +queries = list("create table test (pk int, value int, primary key(pk))", + "describe test", + "insert into test (pk, `value`) values (0,0)", + "select * from test") + +responses = list(NULL, + data.frame( + Field = c("pk", "value"), + Type = c("int", "int"), + Null = c("NO", "YES"), + Key = c("PRI", ""), + Default = c(NA_character_, NA_character_), + Extra = c("", ""), stringsAsFactors = FALSE), + NULL, + data.frame(pk = c(as.integer(0)), value = c(as.integer(0)), stringsAsFactors = FALSE)) + +for(i in 1:length(queries)) { + q = queries[[i]] + want = responses[[i]] + if (!is.null(want)) { + got <- dbGetQuery(conn, q) + if (length(want) == length(got)) { + for (j in 1:length(want)) { + if (!identical(want[[j]], got[[j]])) { + print(q) + print(c("want:", want[[j]], "type: ", typeof(want[[j]]))) + print(c("got:", got[[j]], "type: ", typeof(got[[j]]))) + quit("no", 1) + } + } + } + } else { + dbExecute(conn, q) + } +} + +dolt_queries = list("call DOLT_ADD('-A')", + "call dolt_commit('-m', 'my commit')", + "call dolt_checkout('-b', 'mybranch')", + "insert into test (pk, `value`) values (1,1)", + "call dolt_commit('-a', '-m', 'my commit2')", + "call dolt_checkout('main')", + "call dolt_merge('mybranch')") + +for(i in 1:length(dolt_queries)) { + q = dolt_queries[[i]] + dbExecute(conn, q) +} + +count <- dbGetQuery(conn, "select COUNT(*) as c from dolt_log") +want <- data.frame(c = c(3)) +ret <- all.equal(count, want) +if (!ret) { + print("Number of commits is incorrect") + quit(1) +}