mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-14 18:18:55 -06:00
Merge branch 'main' of github.com:dolthub/dolt into main
This commit is contained in:
@@ -68,7 +68,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220518220116-fbd5e8b1e49e
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220519235058-86955e343071
|
||||
github.com/google/flatbuffers v2.0.5+incompatible
|
||||
github.com/gosuri/uilive v0.0.4
|
||||
github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6
|
||||
|
||||
@@ -178,8 +178,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
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-mysql-server v0.11.1-0.20220518220116-fbd5e8b1e49e h1:FjcKz25G9ttEqxYePnEyZPk9fSegEC/tf06ZHOp/LOs=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220518220116-fbd5e8b1e49e/go.mod h1:h0gpkn07YqshhXbeNkOfII0uV+I37SJYyvccH77+FOk=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220519235058-86955e343071 h1:dxrZSTEaCY6fXlTX6gEF7HC30rQjNwLr0ZJxzus2YnA=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220519235058-86955e343071/go.mod h1:h0gpkn07YqshhXbeNkOfII0uV+I37SJYyvccH77+FOk=
|
||||
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371 h1:oyPHJlzumKta1vnOQqUnfdz+pk3EmnHS3Nd0cCT0I2g=
|
||||
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms=
|
||||
github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8=
|
||||
|
||||
@@ -458,7 +458,7 @@ func (is doltDevIndexSet) PutNomsIndex(ctx context.Context, name string, idx typ
|
||||
|
||||
func (is doltDevIndexSet) DropIndex(ctx context.Context, name string) (IndexSet, error) {
|
||||
builder := flatbuffers.NewBuilder(1024)
|
||||
off := datas.RefMapApplyEdits(is.msg, builder, []datas.RefMapEdit{{Name: name}})
|
||||
off := datas.RefMapApplyEdits(is.msg, builder, []datas.RefMapEdit{{Name: name, Addr: hash.Hash{}}})
|
||||
builder.Finish(off)
|
||||
msg := serial.GetRootAsRefMap(builder.FinishedBytes(), 0)
|
||||
return doltDevIndexSet{is.vrw, msg}, nil
|
||||
|
||||
3
go/libraries/doltcore/env/actions/reset.go
vendored
3
go/libraries/doltcore/env/actions/reset.go
vendored
@@ -25,6 +25,9 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/utils/argparser"
|
||||
)
|
||||
|
||||
// resetHardTables resolves a new HEAD commit from a refSpec and updates working set roots by
|
||||
// resetting the table contexts for tracked tables. New tables are ignored. Returns new HEAD
|
||||
// Commit and Roots.
|
||||
func resetHardTables(ctx context.Context, dbData env.DbData, cSpecStr string, roots doltdb.Roots) (*doltdb.Commit, doltdb.Roots, error) {
|
||||
ddb := dbData.Ddb
|
||||
rsr := dbData.Rsr
|
||||
|
||||
@@ -23,6 +23,7 @@ var DoltFunctions = []sql.Function{
|
||||
sql.Function0{Name: VersionFuncName, Fn: NewVersion},
|
||||
sql.FunctionN{Name: DoltCommitFuncName, Fn: NewDoltCommitFunc},
|
||||
sql.FunctionN{Name: DoltAddFuncName, Fn: NewDoltAddFunc},
|
||||
sql.FunctionN{Name: DoltCleanFuncName, Fn: NewDoltCleanFunc},
|
||||
sql.FunctionN{Name: DoltResetFuncName, Fn: NewDoltResetFunc},
|
||||
sql.FunctionN{Name: DoltCheckoutFuncName, Fn: NewDoltCheckoutFunc},
|
||||
sql.FunctionN{Name: DoltMergeFuncName, Fn: NewDoltMergeFunc},
|
||||
|
||||
@@ -21,9 +21,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/scriptgen/setup"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/plan"
|
||||
"github.com/pkg/profile"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -37,7 +38,8 @@ import (
|
||||
)
|
||||
|
||||
var skipPrepared bool
|
||||
var skipPreparedFlag = "DOLT_SKIP_PREPARED_ENGINETESTS"
|
||||
|
||||
const skipPreparedFlag = "DOLT_SKIP_PREPARED_ENGINETESTS"
|
||||
|
||||
func init() {
|
||||
sqle.MinRowsPerPartition = 8
|
||||
@@ -49,15 +51,14 @@ func init() {
|
||||
}
|
||||
|
||||
func TestQueries(t *testing.T) {
|
||||
defer profile.Start().Stop()
|
||||
enginetest.TestQueries(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestSingleQuery(t *testing.T) {
|
||||
t.Skip()
|
||||
|
||||
var test enginetest.QueryTest
|
||||
test = enginetest.QueryTest{
|
||||
var test queries.QueryTest
|
||||
test = queries.QueryTest{
|
||||
Query: `select i from mytable where i = 1`,
|
||||
Expected: []sql.Row{
|
||||
{1},
|
||||
@@ -70,20 +71,20 @@ func TestSingleQuery(t *testing.T) {
|
||||
//engine.Analyzer.Debug = true
|
||||
//engine.Analyzer.Verbose = true
|
||||
|
||||
enginetest.TestQuery(t, harness, engine, test.Query, test.Expected, test.ExpectedColumns)
|
||||
enginetest.TestQuery(t, harness, test.Query, test.Expected, test.ExpectedColumns, nil)
|
||||
}
|
||||
|
||||
// Convenience test for debugging a single query. Unskip and set to the desired query.
|
||||
func TestSingleScript(t *testing.T) {
|
||||
t.Skip()
|
||||
|
||||
var scripts = []enginetest.ScriptTest{
|
||||
var scripts = []queries.ScriptTest{
|
||||
{
|
||||
Name: "Multialter DDL with ADD/DROP Primary Key",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE t(pk int primary key, v1 int)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "ALTER TABLE t ADD COLUMN (v2 int), drop primary key, add primary key (v2)",
|
||||
Expected: []sql.Row{{sql.NewOkResult(0)}},
|
||||
@@ -126,8 +127,8 @@ func TestSingleScript(t *testing.T) {
|
||||
func TestSingleQueryPrepared(t *testing.T) {
|
||||
t.Skip()
|
||||
|
||||
var test enginetest.QueryTest
|
||||
test = enginetest.QueryTest{
|
||||
var test queries.QueryTest
|
||||
test = queries.QueryTest{
|
||||
Query: `SELECT ST_SRID(g, 0) from geometry_table order by i`,
|
||||
Expected: []sql.Row{
|
||||
{sql.Point{X: 1, Y: 2}},
|
||||
@@ -146,7 +147,7 @@ func TestSingleQueryPrepared(t *testing.T) {
|
||||
engine.Analyzer.Debug = true
|
||||
engine.Analyzer.Verbose = true
|
||||
|
||||
enginetest.TestQuery(t, harness, engine, test.Query, test.Expected, nil)
|
||||
enginetest.TestQuery(t, harness, test.Query, test.Expected, nil, nil)
|
||||
}
|
||||
|
||||
func TestVersionedQueries(t *testing.T) {
|
||||
@@ -198,10 +199,10 @@ func TestAmbiguousColumnResolution(t *testing.T) {
|
||||
|
||||
func TestInsertInto(t *testing.T) {
|
||||
if types.IsFormat_DOLT_1(types.Format_Default) {
|
||||
for i := len(enginetest.InsertScripts) - 1; i >= 0; i-- {
|
||||
for i := len(queries.InsertScripts) - 1; i >= 0; i-- {
|
||||
//TODO: test uses keyless foreign key logic which is not yet fully implemented
|
||||
if enginetest.InsertScripts[i].Name == "Insert on duplicate key" {
|
||||
enginetest.InsertScripts = append(enginetest.InsertScripts[:i], enginetest.InsertScripts[i+1:]...)
|
||||
if queries.InsertScripts[i].Name == "Insert on duplicate key" {
|
||||
queries.InsertScripts = append(queries.InsertScripts[:i], queries.InsertScripts[i+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,10 +233,10 @@ func TestReplaceIntoErrors(t *testing.T) {
|
||||
func TestUpdate(t *testing.T) {
|
||||
var skipped []string
|
||||
if types.IsFormat_DOLT_1(types.Format_Default) {
|
||||
// skip update ffor join
|
||||
// skip update for join
|
||||
patternToSkip := "join"
|
||||
skipped = make([]string, 0)
|
||||
for _, q := range enginetest.UpdateTests {
|
||||
for _, q := range queries.UpdateTests {
|
||||
if strings.Contains(strings.ToLower(q.WriteQuery), patternToSkip) {
|
||||
skipped = append(skipped, q.WriteQuery)
|
||||
}
|
||||
@@ -257,6 +258,16 @@ func TestDeleteFromErrors(t *testing.T) {
|
||||
enginetest.TestDeleteErrors(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestSpatialDelete(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
enginetest.TestSpatialDelete(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestSpatialScripts(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
enginetest.TestSpatialScripts(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
enginetest.TestTruncate(t, newDoltHarness(t))
|
||||
}
|
||||
@@ -448,11 +459,6 @@ func TestDropCheckConstraints(t *testing.T) {
|
||||
enginetest.TestDropCheckConstraints(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestExplode(t *testing.T) {
|
||||
t.Skipf("Unsupported types")
|
||||
enginetest.TestExplode(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestReadOnly(t *testing.T) {
|
||||
enginetest.TestReadOnly(t, newDoltHarness(t))
|
||||
}
|
||||
@@ -546,14 +552,14 @@ func TestRollbackTriggers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStoredProcedures(t *testing.T) {
|
||||
tests := make([]enginetest.ScriptTest, 0, len(enginetest.ProcedureLogicTests))
|
||||
for _, test := range enginetest.ProcedureLogicTests {
|
||||
tests := make([]queries.ScriptTest, 0, len(queries.ProcedureLogicTests))
|
||||
for _, test := range queries.ProcedureLogicTests {
|
||||
//TODO: fix REPLACE always returning a successful deletion
|
||||
if test.Name != "Parameters resolve inside of REPLACE" {
|
||||
tests = append(tests, test)
|
||||
}
|
||||
}
|
||||
enginetest.ProcedureLogicTests = tests
|
||||
queries.ProcedureLogicTests = tests
|
||||
|
||||
enginetest.TestStoredProcedures(t, newDoltHarness(t))
|
||||
}
|
||||
@@ -614,7 +620,9 @@ func TestShowCreateTableAsOf(t *testing.T) {
|
||||
func TestDoltMerge(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
harness := newDoltHarness(t)
|
||||
for _, script := range DoltMerge {
|
||||
harness.Setup(setup.MydbData)
|
||||
for _, script := range MergeScripts {
|
||||
harness.engine = nil
|
||||
enginetest.TestScript(t, harness, script)
|
||||
}
|
||||
}
|
||||
@@ -623,6 +631,7 @@ func TestDoltReset(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
harness := newDoltHarness(t)
|
||||
for _, script := range DoltReset {
|
||||
harness.engine = nil
|
||||
enginetest.TestScript(t, harness, script)
|
||||
}
|
||||
}
|
||||
@@ -632,14 +641,14 @@ func TestDoltReset(t *testing.T) {
|
||||
func TestSingleTransactionScript(t *testing.T) {
|
||||
t.Skip()
|
||||
|
||||
script := enginetest.TransactionTest{
|
||||
script := queries.TransactionTest{
|
||||
Name: "allow commit conflicts on, conflict on dolt_merge",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE test (pk int primary key, val int)",
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off, dolt_allow_commit_conflicts = on",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -859,7 +868,7 @@ func TestUpdateQueriesPrepared(t *testing.T) {
|
||||
if types.IsFormat_DOLT_1(types.Format_Default) {
|
||||
// skip select join for update
|
||||
skipped = make([]string, 0)
|
||||
for _, q := range enginetest.UpdateTests {
|
||||
for _, q := range queries.UpdateTests {
|
||||
if strings.Contains(strings.ToLower(q.WriteQuery), "join") {
|
||||
skipped = append(skipped, q.WriteQuery)
|
||||
}
|
||||
@@ -875,7 +884,7 @@ func TestInsertQueriesPrepared(t *testing.T) {
|
||||
if types.IsFormat_DOLT_1(types.Format_Default) {
|
||||
// skip keyless
|
||||
skipped = make([]string, 0)
|
||||
for _, q := range enginetest.UpdateTests {
|
||||
for _, q := range queries.UpdateTests {
|
||||
if strings.Contains(strings.ToLower(q.WriteQuery), "keyless") {
|
||||
skipped = append(skipped, q.WriteQuery)
|
||||
}
|
||||
@@ -931,19 +940,13 @@ func TestInsertErrorScriptsPrepared(t *testing.T) {
|
||||
enginetest.TestInsertErrorScriptsPrepared(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestExplodePrepared(t *testing.T) {
|
||||
t.Skip("feature not supported")
|
||||
skipPreparedTests(t)
|
||||
enginetest.TestExplodePrepared(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestViewsPrepared(t *testing.T) {
|
||||
skipPreparedTests(t)
|
||||
enginetest.TestViewsPrepared(t, newDoltHarness(t))
|
||||
}
|
||||
|
||||
func TestVersionedViewsPrepared(t *testing.T) {
|
||||
t.Skip("unsupported for prepareds")
|
||||
t.Skip("not supported for prepareds")
|
||||
skipPreparedTests(t)
|
||||
enginetest.TestVersionedViewsPrepared(t, newDoltHarness(t))
|
||||
}
|
||||
@@ -972,7 +975,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
t.Run("adding and dropping primary keys does not result in duplicate NOT NULL constraints", func(t *testing.T) {
|
||||
harness := newDoltHarness(t)
|
||||
addPkScript := enginetest.ScriptTest{
|
||||
addPkScript := queries.ScriptTest{
|
||||
Name: "add primary keys",
|
||||
SetUpScript: []string{
|
||||
"create table test (id int not null, c1 int);",
|
||||
@@ -986,7 +989,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
"ALTER TABLE test DROP PRIMARY KEY",
|
||||
"ALTER TABLE test ADD PRIMARY KEY(id)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table test",
|
||||
Expected: []sql.Row{
|
||||
@@ -1026,7 +1029,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
|
||||
t.Run("Add primary key to table with index", func(t *testing.T) {
|
||||
harness := newDoltHarness(t)
|
||||
script := enginetest.ScriptTest{
|
||||
script := queries.ScriptTest{
|
||||
Name: "add primary keys to table with index",
|
||||
SetUpScript: []string{
|
||||
"create table test (id int not null, c1 int);",
|
||||
@@ -1035,7 +1038,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
"ALTER TABLE test ADD constraint test_check CHECK (c1 > 0)",
|
||||
"ALTER TABLE test ADD PRIMARY KEY(id)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table test",
|
||||
Expected: []sql.Row{
|
||||
@@ -1071,7 +1074,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
|
||||
t.Run("Add primary key when one more cells contain NULL", func(t *testing.T) {
|
||||
harness := newDoltHarness(t)
|
||||
script := enginetest.ScriptTest{
|
||||
script := queries.ScriptTest{
|
||||
Name: "Add primary key when one more cells contain NULL",
|
||||
SetUpScript: []string{
|
||||
"create table test (id int not null, c1 int);",
|
||||
@@ -1081,7 +1084,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
"ALTER TABLE test ADD COLUMN (c2 INT NULL)",
|
||||
"ALTER TABLE test DROP PRIMARY KEY",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "ALTER TABLE test ADD PRIMARY KEY (id, c1, c2)",
|
||||
ExpectedErrStr: "primary key cannot have NULL values",
|
||||
@@ -1093,7 +1096,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
|
||||
t.Run("Drop primary key from table with index", func(t *testing.T) {
|
||||
harness := newDoltHarness(t)
|
||||
script := enginetest.ScriptTest{
|
||||
script := queries.ScriptTest{
|
||||
Name: "Drop primary key from table with index",
|
||||
SetUpScript: []string{
|
||||
"create table test (id int not null primary key, c1 int);",
|
||||
@@ -1101,7 +1104,7 @@ func TestAddDropPrimaryKeys(t *testing.T) {
|
||||
"insert into test values (1,1),(2,2)",
|
||||
"ALTER TABLE test DROP PRIMARY KEY",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table test",
|
||||
Expected: []sql.Row{
|
||||
|
||||
@@ -16,11 +16,14 @@ package enginetest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
gms "github.com/dolthub/go-mysql-server"
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/scriptgen/setup"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -46,8 +49,12 @@ type DoltHarness struct {
|
||||
session *dsess.DoltSession
|
||||
databases []sqle.Database
|
||||
databaseGlobalStates []globalstate.GlobalState
|
||||
hashes []string
|
||||
parallelism int
|
||||
skippedQueries []string
|
||||
setupData []setup.SetupScript
|
||||
resetData []setup.SetupScript
|
||||
engine *gms.Engine
|
||||
}
|
||||
|
||||
var _ enginetest.Harness = (*DoltHarness)(nil)
|
||||
@@ -96,17 +103,85 @@ var defaultSkippedQueries = []string{
|
||||
"show global variables like", // we set extra variables
|
||||
}
|
||||
|
||||
func (d *DoltHarness) Setup(setupData ...[]setup.SetupScript) {
|
||||
d.engine = nil
|
||||
d.setupData = nil
|
||||
for i := range setupData {
|
||||
d.setupData = append(d.setupData, setupData[i]...)
|
||||
}
|
||||
}
|
||||
|
||||
func resetScripts(dbs []string, autoInc bool) []setup.SetupScript {
|
||||
var resetCmds setup.SetupScript
|
||||
for i := range dbs {
|
||||
db := dbs[i]
|
||||
resetCmds = append(resetCmds, fmt.Sprintf("use %s", db))
|
||||
resetCmds = append(resetCmds, "call dclean()")
|
||||
resetCmds = append(resetCmds, "call dreset('--hard', 'head')")
|
||||
if autoInc {
|
||||
resetCmds = append(resetCmds, setup.AutoincrementData[0]...)
|
||||
}
|
||||
}
|
||||
resetCmds = append(resetCmds, "use mydb")
|
||||
return []setup.SetupScript{resetCmds}
|
||||
}
|
||||
|
||||
func commitScripts(dbs []string) []setup.SetupScript {
|
||||
var commitCmds setup.SetupScript
|
||||
for i := range dbs {
|
||||
db := dbs[i]
|
||||
commitCmds = append(commitCmds, fmt.Sprintf("use %s", db))
|
||||
commitCmds = append(commitCmds, fmt.Sprintf("call dcommit('--allow-empty', '-am', 'checkpoint enginetest database %s')", db))
|
||||
}
|
||||
commitCmds = append(commitCmds, "use mydb")
|
||||
return []setup.SetupScript{commitCmds}
|
||||
}
|
||||
|
||||
func (d *DoltHarness) NewEngine(t *testing.T) (*gms.Engine, error) {
|
||||
if d.engine == nil {
|
||||
e, err := enginetest.NewEngineWithSetup(t, d, d.setupData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.engine = e
|
||||
ctx := enginetest.NewContext(d)
|
||||
|
||||
res := enginetest.MustQuery(ctx, e, "select schema_name from information_schema.schemata where schema_name not in ('information_schema');")
|
||||
var dbs []string
|
||||
for i := range res {
|
||||
dbs = append(dbs, res[i][0].(string))
|
||||
}
|
||||
|
||||
res = enginetest.MustQuery(ctx, e, "select count(*) from information_schema.tables where table_name = 'auto_increment_tbl';")
|
||||
autoInc := res[0][0].(int64) > 0
|
||||
|
||||
e, err = enginetest.RunEngineScripts(ctx, e, commitScripts(dbs), d.SupportsNativeIndexCreation())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
d.resetData = resetScripts(dbs, autoInc)
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
ctx := enginetest.NewContext(d)
|
||||
return enginetest.RunEngineScripts(ctx, d.engine, d.resetData, d.SupportsNativeIndexCreation())
|
||||
}
|
||||
|
||||
// WithParallelism returns a copy of the harness with parallelism set to the given number of threads. A value of 0 or
|
||||
// less means to use the system parallelism settings.
|
||||
func (d DoltHarness) WithParallelism(parallelism int) *DoltHarness {
|
||||
d.parallelism = parallelism
|
||||
return &d
|
||||
func (d *DoltHarness) WithParallelism(parallelism int) *DoltHarness {
|
||||
nd := *d
|
||||
nd.parallelism = parallelism
|
||||
return &nd
|
||||
}
|
||||
|
||||
// WithSkippedQueries returns a copy of the harness with the given queries skipped
|
||||
func (d DoltHarness) WithSkippedQueries(queries []string) *DoltHarness {
|
||||
d.skippedQueries = append(d.skippedQueries, queries...)
|
||||
return &d
|
||||
func (d *DoltHarness) WithSkippedQueries(queries []string) *DoltHarness {
|
||||
nd := *d
|
||||
nd.skippedQueries = append(d.skippedQueries, queries...)
|
||||
return &nd
|
||||
}
|
||||
|
||||
// SkipQueryTest returns whether to skip a query
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle"
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
)
|
||||
|
||||
var ShowCreateTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
var ShowCreateTableAsOfScriptTest = queries.ScriptTest{
|
||||
Name: "Show create table as of",
|
||||
SetUpScript: []string{
|
||||
"set @Commit0 = hashof('main');",
|
||||
@@ -38,7 +38,7 @@ var ShowCreateTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
"alter table a add constraint unique_c2 unique(c2);",
|
||||
"set @Commit3 = dolt_commit('-am', 'dropping column c1');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table a as of @Commit0;",
|
||||
ExpectedErr: sql.ErrTableNotFound,
|
||||
@@ -81,7 +81,7 @@ var ShowCreateTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DescribeTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
var DescribeTableAsOfScriptTest = queries.ScriptTest{
|
||||
Name: "Describe table as of",
|
||||
SetUpScript: []string{
|
||||
"set @Commit0 = dolt_commit('--allow-empty', '-m', 'before creating table a');",
|
||||
@@ -92,7 +92,7 @@ var DescribeTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
"alter table a drop column c1;",
|
||||
"set @Commit3 = dolt_commit('-am', 'dropping column c1');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "describe a as of @Commit0;",
|
||||
ExpectedErr: sql.ErrTableNotFound,
|
||||
@@ -124,7 +124,7 @@ var DescribeTableAsOfScriptTest = enginetest.ScriptTest{
|
||||
|
||||
// DoltScripts are script tests specific to Dolt (not the engine in general), e.g. by involving Dolt functions. Break
|
||||
// this slice into others with good names as it grows.
|
||||
var DoltScripts = []enginetest.ScriptTest{
|
||||
var DoltScripts = []queries.ScriptTest{
|
||||
{
|
||||
Name: "test as of indexed join (https://github.com/dolthub/dolt/issues/2189)",
|
||||
SetUpScript: []string{
|
||||
@@ -136,7 +136,7 @@ var DoltScripts = []enginetest.ScriptTest{
|
||||
"set @second_commit = (select commit_hash from dolt_log order by date desc limit 1)",
|
||||
"set @first_commit = (select commit_hash from dolt_log order by date desc limit 1,1)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select a1.* from a as of @second_commit a1 " +
|
||||
"left join a as of @first_commit a2 on a1.pk = a2.pk where a2.pk is null order by 1",
|
||||
@@ -163,7 +163,7 @@ var DoltScripts = []enginetest.ScriptTest{
|
||||
"alter table t2 add constraint fk1 foreign key (d) references t1 (b)",
|
||||
"alter table t2 add constraint t2du unique (d)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table t1",
|
||||
Expected: []sql.Row{
|
||||
@@ -196,7 +196,7 @@ var DoltScripts = []enginetest.ScriptTest{
|
||||
"create table bigTable (pk int primary key, c0 int);",
|
||||
makeLargeInsert(10_000),
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from bigTable;",
|
||||
Expected: []sql.Row{
|
||||
@@ -217,7 +217,7 @@ var DoltScripts = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Name: "SHOW CREATE PROCEDURE works with Dolt external procedures",
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SHOW CREATE PROCEDURE dolt_checkout;",
|
||||
Expected: []sql.Row{
|
||||
@@ -246,7 +246,7 @@ func makeLargeInsert(sz int) string {
|
||||
}
|
||||
|
||||
// DoltUserPrivTests are tests for Dolt-specific functionality that includes privilege checking logic.
|
||||
var DoltUserPrivTests = []enginetest.UserPrivilegeTest{
|
||||
var DoltUserPrivTests = []queries.UserPrivilegeTest{
|
||||
{
|
||||
Name: "dolt_diff table function privilege checking",
|
||||
SetUpScript: []string{
|
||||
@@ -257,7 +257,7 @@ var DoltUserPrivTests = []enginetest.UserPrivilegeTest{
|
||||
"SELECT DOLT_COMMIT('-am', 'inserting into test');",
|
||||
"CREATE USER tester@localhost;",
|
||||
},
|
||||
Assertions: []enginetest.UserPrivilegeTestAssertion{
|
||||
Assertions: []queries.UserPrivilegeTestAssertion{
|
||||
{
|
||||
// Without access to the database, dolt_diff should fail with a database access error
|
||||
User: "tester",
|
||||
@@ -360,14 +360,14 @@ var DoltUserPrivTests = []enginetest.UserPrivilegeTest{
|
||||
},
|
||||
}
|
||||
|
||||
var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
var HistorySystemTableScriptTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "empty table",
|
||||
SetUpScript: []string{
|
||||
"create table t (n int, c text);",
|
||||
"set @Commit1 = dolt_commit('-am', 'creating table t');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from DOLT_HISTORY_t;",
|
||||
Expected: []sql.Row{{0}},
|
||||
@@ -387,7 +387,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into foo1 values (4, 'Vier');",
|
||||
"set @Commit3 = dolt_commit('-am', 'inserting data in foo1');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from DOLT_HISTORY_foO1;",
|
||||
Expected: []sql.Row{{10}},
|
||||
@@ -420,7 +420,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"update foo1 set fr='Un' where n=1;",
|
||||
"set @Commit3 = dolt_commit('-am', 'updating data in foo1');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from Dolt_History_Foo1;",
|
||||
Expected: []sql.Row{{11}},
|
||||
@@ -452,7 +452,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"alter table t rename column c1 to c2;",
|
||||
"set @Commit3 = DOLT_COMMIT('-am', 'renaming c1 to c2');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from dolt_history_t;",
|
||||
Expected: []sql.Row{{6}},
|
||||
@@ -488,7 +488,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"alter table t rename to t2;",
|
||||
"set @Commit2 = DOLT_COMMIT('-am', 'renaming table to t2');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select count(*) from dolt_history_t;",
|
||||
ExpectedErr: sql.ErrTableNotFound,
|
||||
@@ -516,7 +516,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"create table t (pk int primary key, c1 int);",
|
||||
"set @Commit3 = DOLT_COMMIT('-am', 'recreating table t');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
// TODO: The history system table processes history in parallel and pulls the rows for the
|
||||
// user table at all commits. This means we can't currently detect when a table was dropped
|
||||
@@ -532,7 +532,7 @@ var HistorySystemTableScriptTests = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DoltMerge = []enginetest.ScriptTest{
|
||||
var MergeScripts = []queries.ScriptTest{
|
||||
{
|
||||
Name: "DOLT_MERGE ff correctly works with autocommit off",
|
||||
SetUpScript: []string{
|
||||
@@ -546,7 +546,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
// FF-Merge
|
||||
Query: "SELECT DOLT_MERGE('feature-branch')",
|
||||
@@ -579,7 +579,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
// No-FF-Merge
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-no-ff', '-m', 'this is a no-ff')",
|
||||
@@ -591,7 +591,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{4}}, // includes the merge commit created by no-ff
|
||||
Expected: []sql.Row{{5}}, // includes the merge commit created by no-ff and setup commits
|
||||
},
|
||||
{
|
||||
Query: "select message from dolt_log order by date DESC LIMIT 1;",
|
||||
@@ -618,7 +618,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"INSERT INTO test VALUES (5),(6),(7);",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'add some more values');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-m', 'this is a merge')",
|
||||
Expected: []sql.Row{{1}},
|
||||
@@ -629,7 +629,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{3}},
|
||||
Expected: []sql.Row{{4}},
|
||||
},
|
||||
{
|
||||
Query: "select message from dolt_log order by date DESC LIMIT 1;",
|
||||
@@ -656,7 +656,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"UPDATE test SET val=1001 WHERE pk=0;",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'update a value');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-m', 'this is a merge')",
|
||||
Expected: []sql.Row{{0}},
|
||||
@@ -667,7 +667,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{3}},
|
||||
Expected: []sql.Row{{4}},
|
||||
},
|
||||
{
|
||||
Query: "select message from dolt_log order by date DESC LIMIT 1;",
|
||||
@@ -708,7 +708,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '--squash')",
|
||||
Expected: []sql.Row{{1}},
|
||||
@@ -719,7 +719,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{2}},
|
||||
Expected: []sql.Row{{3}},
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM test order by pk",
|
||||
@@ -740,7 +740,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '--squash')",
|
||||
Expected: []sql.Row{{1}},
|
||||
@@ -767,7 +767,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
// FF-Merge
|
||||
Query: "SELECT DOLT_MERGE('feature-branch')",
|
||||
@@ -799,7 +799,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'this is a ff');",
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
// No-FF-Merge
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-no-ff', '-m', 'this is a no-ff')",
|
||||
@@ -811,7 +811,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{4}}, // includes the merge commit created by no-ff
|
||||
Expected: []sql.Row{{5}}, // includes the merge commit created by no-ff and setup commits
|
||||
},
|
||||
{
|
||||
Query: "select message from dolt_log order by date DESC LIMIT 1;",
|
||||
@@ -837,7 +837,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"INSERT INTO test VALUES (5),(6),(7);",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'add some more values');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-m', 'this is a merge')",
|
||||
Expected: []sql.Row{{1}},
|
||||
@@ -848,7 +848,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{3}},
|
||||
Expected: []sql.Row{{4}},
|
||||
},
|
||||
{
|
||||
Query: "select message from dolt_log order by date DESC LIMIT 1;",
|
||||
@@ -875,7 +875,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'update a value');",
|
||||
"set dolt_allow_commit_conflicts = on",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch')",
|
||||
Expected: []sql.Row{{0}},
|
||||
@@ -929,7 +929,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"UPDATE test SET val=1001 WHERE pk=0;",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'update a value');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-m', 'this is a merge')",
|
||||
Expected: []sql.Row{{0}},
|
||||
@@ -952,7 +952,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM dolt_log",
|
||||
Expected: []sql.Row{{3}},
|
||||
Expected: []sql.Row{{4}},
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM test ORDER BY pk",
|
||||
@@ -978,7 +978,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
"SELECT DOLT_CHECKOUT('main');",
|
||||
"UPDATE test SET val=1001 WHERE pk=0;",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch', '-m', 'this is a merge')",
|
||||
ExpectedErr: dfunctions.ErrUncommittedChanges,
|
||||
@@ -987,7 +987,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DoltReset = []enginetest.ScriptTest{
|
||||
var DoltReset = []queries.ScriptTest{
|
||||
{
|
||||
Name: "CALL DOLT_RESET('--hard') should reset the merge state after uncommitted merge",
|
||||
SetUpScript: []string{
|
||||
@@ -1007,7 +1007,7 @@ var DoltReset = []enginetest.ScriptTest{
|
||||
|
||||
"CALL DOLT_RESET('--hard');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "CALL DOLT_MERGE('--abort')",
|
||||
ExpectedErrStr: "fatal: There is no merge to abort",
|
||||
@@ -1033,7 +1033,7 @@ var DoltReset = []enginetest.ScriptTest{
|
||||
"CALL DOLT_MERGE('merge_branch');",
|
||||
"CALL DOLT_RESET('--hard');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "CALL DOLT_MERGE('--abort')",
|
||||
ExpectedErrStr: "fatal: There is no merge to abort",
|
||||
@@ -1042,7 +1042,7 @@ var DoltReset = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
var DiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "base case: added rows",
|
||||
SetUpScript: []string{
|
||||
@@ -1050,7 +1050,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (1, 2, 3), (4, 5, 6);",
|
||||
"set @Commit1 = (select DOLT_COMMIT('-am', 'creating table t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{2}},
|
||||
@@ -1074,7 +1074,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"update t set c2=0 where pk=1",
|
||||
"set @Commit2 = (select DOLT_COMMIT('-am', 'modifying row'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{3}},
|
||||
@@ -1097,7 +1097,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"delete from t where pk=1",
|
||||
"set @Commit2 = (select DOLT_COMMIT('-am', 'modifying row'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{3}},
|
||||
@@ -1125,7 +1125,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 200), (300, 400);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'recreating table t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t",
|
||||
Expected: []sql.Row{{2}},
|
||||
@@ -1150,7 +1150,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"alter table t drop column c1;",
|
||||
"set @Commit2 = (select DOLT_COMMIT('-am', 'dropping column c'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{4}},
|
||||
@@ -1186,7 +1186,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'inserting into t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1228,7 +1228,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'inserting into t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1271,7 +1271,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, '101');",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 're-adding column c'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1312,7 +1312,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 're-adding column c'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1364,7 +1364,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, '101');",
|
||||
"set @Commit4 = (select DOLT_COMMIT('-am', 'recreating column c2'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1413,7 +1413,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (7, 8);",
|
||||
"set @Commit4 = (select DOLT_COMMIT('-am', 'adding more data'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select * from dolt_diff_t;",
|
||||
ExpectedWarning: 1105,
|
||||
@@ -1439,7 +1439,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"INSERT INTO t VALUES (1, 'hi');",
|
||||
"CALL dolt_commit('-am', 'insert data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_commit, from_pk, from_commit, diff_type from dolt_diff_t;",
|
||||
Expected: []sql.Row{{1, "hi", nil, nil, "added"}},
|
||||
@@ -1448,7 +1448,7 @@ var DiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
var DiffTableFunctionScriptTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "invalid arguments",
|
||||
SetUpScript: []string{
|
||||
@@ -1458,7 +1458,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values(1, 'one', 'two'), (2, 'two', 'three');",
|
||||
"set @Commit2 = dolt_commit('-am', 'inserting into t');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT * from dolt_diff('t');",
|
||||
ExpectedErr: sql.ErrInvalidArgumentNumber,
|
||||
@@ -1532,7 +1532,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"update t set c1='uno', c2='dos' where pk=1;",
|
||||
"set @Commit4 = dolt_commit('-am', 'inserting into table t');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{{1, "one", "two", nil, nil, nil, "added"}},
|
||||
@@ -1596,7 +1596,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (2, 'two', 'three');",
|
||||
"set @Commit6 = dolt_commit('-am', 'inserting row 2 in main');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, from_pk, from_c1, from_c2, diff_type from dolt_diff('t', 'main', 'branch1');",
|
||||
Expected: []sql.Row{
|
||||
@@ -1637,7 +1637,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"update t set c2='foo' where pk=1;",
|
||||
"set @Commit4 = dolt_commit('-am', 'adding column c2, inserting, and updating data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{
|
||||
@@ -1699,7 +1699,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (4, 'four', -4);",
|
||||
"set @Commit5 = dolt_commit('-am', 'renaming column c3 to c2, and inserting data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{
|
||||
@@ -1767,7 +1767,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (4, 'four', -4);",
|
||||
"set @Commit5 = dolt_commit('-am', 'adding column c2, and inserting data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{
|
||||
@@ -1814,7 +1814,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
"INSERT INTO t VALUES (1, 'hi');",
|
||||
"set @Commit2 = dolt_commit('-am', 'insert data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_commit, from_pk, from_commit, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{{1, "hi", nil, nil, "added"}},
|
||||
@@ -1823,7 +1823,7 @@ var DiffTableFunctionScriptTests = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
var UnscopedDiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "basic case with three tables",
|
||||
SetUpScript: []string{
|
||||
@@ -1843,7 +1843,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"alter table y add column d int;",
|
||||
"set @Commit4 = (select DOLT_COMMIT('-am', 'Modify schema of table y'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{6}},
|
||||
@@ -1881,7 +1881,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"rename table x1 to x2",
|
||||
"set @Commit4 = (select DOLT_COMMIT('-am', 'Renaming table x1 to x2'))",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -1918,7 +1918,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"drop table y",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'Dropping empty table y'))",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{4}},
|
||||
@@ -1950,7 +1950,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into y values (-1, -2, -3), (-2, -3, -4)",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'Inserting into table y'))",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{3}},
|
||||
@@ -1987,7 +1987,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into z values (101, 102, 103)",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'Inserting into tables y and z'))",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{5}},
|
||||
@@ -2026,7 +2026,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"select DOLT_MERGE('branch1')",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'Merging branch1 into branch2'))",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF",
|
||||
Expected: []sql.Row{{3}},
|
||||
@@ -2047,7 +2047,7 @@ var UnscopedDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
},
|
||||
}
|
||||
|
||||
var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
var CommitDiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "error handling",
|
||||
SetUpScript: []string{
|
||||
@@ -2055,7 +2055,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (1, 2, 3), (4, 5, 6);",
|
||||
"set @Commit1 = (select DOLT_COMMIT('-am', 'creating table t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT * FROM DOLT_COMMIT_DIFF_t;",
|
||||
ExpectedErrStr: "error querying table dolt_commit_diff_t: dolt_commit_diff_* tables must be filtered to a single 'to_commit'",
|
||||
@@ -2090,7 +2090,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"delete from t where pk=1",
|
||||
"set @Commit5 = (select DOLT_COMMIT('-am', 'modifying row'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2136,7 +2136,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"alter table t drop column c1;",
|
||||
"set @Commit2 = (select DOLT_COMMIT('-am', 'dropping column c'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c2, from_pk, from_c2 FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0 ORDER BY to_pk;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2169,7 +2169,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'inserting into t'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c, from_pk, from_c, diff_type FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0 ORDER BY to_pk;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2208,7 +2208,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = DOLT_COMMIT('-am', 'inserting into t');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, from_pk, from_c1, diff_type FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0 ORDER BY to_pk;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2249,7 +2249,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, '101');",
|
||||
"set @Commit3 = DOLT_COMMIT('-am', 're-adding column c');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c, from_pk, from_c, diff_type FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0 ORDER BY to_pk;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2287,7 +2287,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (100, 101);",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 're-adding column c'));",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c, from_pk, from_c, diff_type FROM DOLT_COMMIT_DIFF_t WHERE TO_COMMIT=@Commit1 and FROM_COMMIT=@Commit0 ORDER BY to_pk;",
|
||||
Expected: []sql.Row{
|
||||
@@ -2334,7 +2334,7 @@ var CommitDiffSystemTableScriptTests = []enginetest.ScriptTest{
|
||||
"insert into t values (7, 8);",
|
||||
"set @Commit4 = DOLT_COMMIT('-am', 'adding more data');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select * from dolt_commit_diff_t where from_commit=@Commit1 and to_commit=@Commit4;",
|
||||
ExpectedWarning: 1105,
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
package enginetest
|
||||
|
||||
import (
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
)
|
||||
|
||||
var BrokenSystemTableQueries = []enginetest.QueryTest{
|
||||
var BrokenSystemTableQueries = []queries.QueryTest{
|
||||
{
|
||||
Query: `SELECT
|
||||
myTable.i,
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -36,13 +37,13 @@ func TestDoltTransactionCommitOneClient(t *testing.T) {
|
||||
// In this test, we're setting only one client to match transaction commits to dolt commits.
|
||||
// Autocommit is disabled for the enabled client, as it's the recommended way to use this feature.
|
||||
harness := newDoltHarness(t)
|
||||
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
|
||||
enginetest.TestTransactionScript(t, harness, queries.TransactionTest{
|
||||
Name: "dolt commit on transaction commit one client",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE x (y BIGINT PRIMARY KEY, z BIGINT);",
|
||||
"INSERT INTO x VALUES (1,1);",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ SET @@autocommit=0;",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -175,13 +176,13 @@ func TestDoltTransactionCommitTwoClients(t *testing.T) {
|
||||
// In this test, we're setting both clients to match transaction commits to dolt commits.
|
||||
// Autocommit is disabled, as it's the recommended way to use this feature.
|
||||
harness := newDoltHarness(t)
|
||||
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
|
||||
enginetest.TestTransactionScript(t, harness, queries.TransactionTest{
|
||||
Name: "dolt commit on transaction commit two clients",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE x (y BIGINT PRIMARY KEY, z BIGINT);",
|
||||
"INSERT INTO x VALUES (1,1);",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ SET @@autocommit=0;",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -307,13 +308,13 @@ func TestDoltTransactionCommitAutocommit(t *testing.T) {
|
||||
// In this test, each insertion from both clients cause a commit as autocommit is enabled.
|
||||
// Not the recommended way to use the feature, but it's permitted.
|
||||
harness := newDoltHarness(t)
|
||||
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
|
||||
enginetest.TestTransactionScript(t, harness, queries.TransactionTest{
|
||||
Name: "dolt commit with autocommit",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE x (y BIGINT PRIMARY KEY, z BIGINT);",
|
||||
"INSERT INTO x VALUES (1,1);",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
// these SET statements currently commit a transaction (since autocommit is on)
|
||||
{
|
||||
Query: "/* client a */ SET @@dolt_transaction_commit=1;",
|
||||
@@ -383,7 +384,7 @@ func TestDoltTransactionCommitLateFkResolution(t *testing.T) {
|
||||
}
|
||||
|
||||
harness := newDoltHarness(t)
|
||||
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
|
||||
enginetest.TestTransactionScript(t, harness, queries.TransactionTest{
|
||||
Name: "delayed foreign key resolution with transaction commits",
|
||||
SetUpScript: []string{
|
||||
"SET foreign_key_checks=0;",
|
||||
@@ -392,7 +393,7 @@ func TestDoltTransactionCommitLateFkResolution(t *testing.T) {
|
||||
"CREATE TABLE parent (pk BIGINT PRIMARY KEY);",
|
||||
"INSERT INTO parent VALUES (1), (2);",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ SET @@autocommit=0;",
|
||||
Expected: []sql.Row{{}},
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
package enginetest
|
||||
|
||||
import (
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/plan"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
)
|
||||
|
||||
var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
var DoltTransactionTests = []queries.TransactionTest{
|
||||
{
|
||||
// Repro for https://github.com/dolthub/dolt/issues/3402
|
||||
Name: "DDL changes from transactions are available before analyzing statements in other sessions (autocommit on)",
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ select @@autocommit;",
|
||||
Expected: []sql.Row{{1}},
|
||||
@@ -59,7 +59,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ insert into t values (2, 2)",
|
||||
Expected: []sql.Row{{sql.NewOkResult(1)}},
|
||||
@@ -76,7 +76,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -117,7 +117,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -166,7 +166,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ update t set y = 2",
|
||||
Expected: []sql.Row{{sql.OkResult{
|
||||
@@ -203,7 +203,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -256,7 +256,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -317,7 +317,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -370,7 +370,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int, z int)",
|
||||
"insert into t values (1, 1, 1), (2, 2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -423,7 +423,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ delete from t where y = 2",
|
||||
Expected: []sql.Row{{sql.NewOkResult(1)}},
|
||||
@@ -448,7 +448,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -489,7 +489,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2), (3, 3)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -530,7 +530,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -581,7 +581,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int)",
|
||||
"insert into t values (1, 1), (2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -626,7 +626,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table t (x int primary key, y int, z int)",
|
||||
"insert into t values (1, 1, 1), (2, 2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -707,7 +707,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
"create table test (x int, y int, z int, primary key(z, y))",
|
||||
"insert into test values (1, 1, 1), (2, 2, 2)",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client b */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
@@ -756,7 +756,7 @@ var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
var DoltConflictHandlingTests = []queries.TransactionTest{
|
||||
{
|
||||
Name: "default behavior (rollback on commit conflict)",
|
||||
SetUpScript: []string{
|
||||
@@ -764,7 +764,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -814,7 +814,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off, dolt_allow_commit_conflicts = on",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -860,7 +860,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off, dolt_force_transaction_commit = on",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -906,7 +906,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off, dolt_allow_commit_conflicts = on",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -996,7 +996,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off, dolt_force_transaction_commit = on",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -1084,7 +1084,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
"INSERT INTO test VALUES (0, 0)",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'initial table');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ set autocommit = off",
|
||||
Expected: []sql.Row{{}},
|
||||
@@ -1149,7 +1149,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
},
|
||||
}
|
||||
|
||||
var DoltSqlFuncTransactionTests = []enginetest.TransactionTest{
|
||||
var DoltSqlFuncTransactionTests = []queries.TransactionTest{
|
||||
{
|
||||
Name: "committed conflicts are seen by other sessions",
|
||||
SetUpScript: []string{
|
||||
@@ -1164,7 +1164,7 @@ var DoltSqlFuncTransactionTests = []enginetest.TransactionTest{
|
||||
"UPDATE test SET val=1001 WHERE pk=0;",
|
||||
"SELECT DOLT_COMMIT('-a', '-m', 'update a value');",
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ start transaction",
|
||||
Expected: []sql.Row{},
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/plan"
|
||||
|
||||
@@ -30,7 +31,7 @@ func TestSysbenchTransactionCV(t *testing.T) {
|
||||
}
|
||||
|
||||
harness := newDoltHarness(t)
|
||||
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
|
||||
enginetest.TestTransactionScript(t, harness, queries.TransactionTest{
|
||||
Name: "Sysbench Transactions Shouldn't Cause Constraint Violations",
|
||||
SetUpScript: []string{
|
||||
`SET FOREIGN_KEY_CHECKS=0;`,
|
||||
@@ -103,7 +104,7 @@ s_dist_07, s_dist_08, s_dist_09, s_dist_10, s_ytd, s_order_cnt, s_remote_cnt, s_
|
||||
(88405, 1, 60,'c24','o24','u24','k24','n24','d24','u24','q24','t24','s24',0,0,0,'n46');`,
|
||||
`SET FOREIGN_KEY_CHECKS=1;`,
|
||||
},
|
||||
Assertions: []enginetest.ScriptTestAssertion{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "/* client a */ SET SESSION transaction_isolation='REPEATABLE-READ';",
|
||||
Expected: []sql.Row{{}},
|
||||
|
||||
@@ -1384,10 +1384,6 @@ func (t *AlterableDoltTable) CreateIndex(
|
||||
|
||||
// DropIndex implements sql.IndexAlterableTable
|
||||
func (t *AlterableDoltTable) DropIndex(ctx *sql.Context, indexName string) error {
|
||||
if types.IsFormat_DOLT_1(t.nbf) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// We disallow removing internal dolt_ tables from SQL directly
|
||||
if strings.HasPrefix(indexName, "dolt_") {
|
||||
return fmt.Errorf("dolt internal indexes may not be dropped")
|
||||
|
||||
@@ -162,17 +162,9 @@ func (m prollyIndexWriter) Update(ctx context.Context, oldRow sql.Row, newRow sq
|
||||
}
|
||||
newKey := m.keyBld.Build(sharePool)
|
||||
|
||||
ok, err := m.mut.Has(ctx, newKey)
|
||||
_, err := m.mut.Has(ctx, newKey)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
// All secondary writers have a name, while the primary does not. If this is a secondary writer, then we can
|
||||
// bypass the keyError() call as it will be done in the calling primary writer.
|
||||
if m.name == "" {
|
||||
return m.keyError(ctx, newKey, true)
|
||||
} else {
|
||||
return sql.ErrUniqueKeyViolation.New()
|
||||
}
|
||||
}
|
||||
|
||||
for to := range m.valMap {
|
||||
|
||||
@@ -301,7 +301,7 @@ func newHead(head types.Value, addr hash.Hash) (dsHead, error) {
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
return nil, fmt.Errorf("database: fetched head at %v by it was not a commit, tag or working set.", addr)
|
||||
return nil, fmt.Errorf("database: fetched head at %v but it was not a commit, tag or working set.", addr)
|
||||
}
|
||||
|
||||
return nomsHead{head.(types.Struct), addr}, nil
|
||||
|
||||
Reference in New Issue
Block a user