Skip to content

Commit

Permalink
Merge branch 'main' into nicktobey/autoinclock
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktobey committed Apr 6, 2024
2 parents e0d8534 + 5732cda commit ab54c2c
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 189 deletions.
2 changes: 1 addition & 1 deletion go/cmd/dolt/dolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import (
)

const (
Version = "1.35.7"
Version = "1.35.8"
)

var dumpDocsCommand = &commands.DumpDocsCmd{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,8 @@ func TestStartReplicaErrors(t *testing.T) {
defer teardown(t)
startSqlServers(t)

// START REPLICA returns an error if server_id has not been set to a non-zero value
_, err := replicaDatabase.Queryx("START REPLICA;")
require.Error(t, err)
require.ErrorContains(t, err, "invalid server ID configured")

replicaDatabase.MustExec("SET @@GLOBAL.server_id=4321")

// START REPLICA returns an error when no replication source is configured
_, err = replicaDatabase.Queryx("START REPLICA;")
_, err := replicaDatabase.Queryx("START REPLICA;")
require.Error(t, err)
require.ErrorContains(t, err, ErrServerNotConfiguredAsReplica.Error())

Expand Down
18 changes: 9 additions & 9 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""},
},
},
{
Expand Down
12 changes: 6 additions & 6 deletions go/libraries/doltcore/sqle/enginetest/privilege_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""},
},
},
},
Expand Down Expand Up @@ -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, ""},
},
},
{
Expand Down Expand Up @@ -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, ""},
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/bats/create-views.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/mysql-client-tests/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const tests = [
Type: "int",
Null: "NO",
Key: "PRI",
Default: "NULL",
Default: null,
Extra: "",
},
{
Field: "value",
Type: "int",
Null: "YES",
Key: "",
Default: "NULL",
Default: null,
Extra: "",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export const tableTests = [
Type: "int",
Null: "NO",
Key: "PRI",
Default: "NULL",
Default: null,
Extra: "",
},
{
Field: "value",
Type: "int",
Null: "YES",
Key: "",
Default: "NULL",
Default: null,
Extra: "",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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)]},
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/mysql-client-tests/python/pymysql-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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),)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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)]},
Expand Down
178 changes: 89 additions & 89 deletions integration-tests/mysql-client-tests/r/rmariadb-test.r
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit ab54c2c

Please sign in to comment.