Merge branch 'main' into james/zbbox

This commit is contained in:
James Cor
2023-03-08 14:12:36 -08:00
47 changed files with 200 additions and 291 deletions

View File

@@ -59,7 +59,7 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
role-duration-seconds: 10800 # 3 hours D:
- name: Setup Go 1.x
uses: actions/setup-go@v3
with:

View File

@@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-22.04 ]
dolt_fmt: [ "__DOLT__", "__LD_1__", "__DOLT_DEV__" ]
dolt_fmt: [ "__DOLT__", "__LD_1__" ]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3

View File

@@ -25,9 +25,6 @@ jobs:
dolt_fmt: [ "__DOLT__", "__LD_1__" ]
journal_store: [ "" ]
include:
- os: "ubuntu-22.04"
dolt_fmt: "__DOLT_DEV__"
journal_store: ""
- os: "ubuntu-22.04"
dolt_fmt: "__DOLT__"
journal_store: "true"
@@ -81,9 +78,6 @@ jobs:
matrix:
os: [macos-latest, ubuntu-22.04, windows-latest]
dolt_fmt: [ "__DOLT__", "__LD_1__" ]
include:
- os: "ubuntu-22.04"
dolt_fmt: "__DOLT_DEV__"
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3

View File

@@ -58,7 +58,7 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3
github.com/cespare/xxhash v1.1.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/go-mysql-server v0.14.1-0.20230306183503-0eb7ae0ff7a5
github.com/dolthub/go-mysql-server v0.14.1-0.20230307172231-6ffcb4eb16e5
github.com/google/flatbuffers v2.0.6+incompatible
github.com/jmoiron/sqlx v1.3.4
github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6

View File

@@ -166,8 +166,8 @@ github.com/dolthub/flatbuffers v1.13.0-dh.1 h1:OWJdaPep22N52O/0xsUevxJ6Qfw1M2txC
github.com/dolthub/flatbuffers v1.13.0-dh.1/go.mod h1:CorYGaDmXjHz1Z7i50PYXG1Ricn31GcA2wNOTFIQAKE=
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.14.1-0.20230306183503-0eb7ae0ff7a5 h1:RLEZhffGxUB+YPdva+fiPGZuOXcYsaCDPn30BLFSzoQ=
github.com/dolthub/go-mysql-server v0.14.1-0.20230306183503-0eb7ae0ff7a5/go.mod h1:6UJk5NlguuhVg/qahl/7+lk4mxJn0NKHCPvBxz978sU=
github.com/dolthub/go-mysql-server v0.14.1-0.20230307172231-6ffcb4eb16e5 h1:SzePrTa2MDWlYzbEmIrdEkdCY0i63xeuvL3m1MK9lto=
github.com/dolthub/go-mysql-server v0.14.1-0.20230307172231-6ffcb4eb16e5/go.mod h1:6UJk5NlguuhVg/qahl/7+lk4mxJn0NKHCPvBxz978sU=
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.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8=

View File

@@ -30,12 +30,23 @@ import (
"github.com/dolthub/dolt/go/store/types"
)
func init() {
// default to chunk journal unless feature flag is set
if os.Getenv("DOLT_DISABLE_CHUNK_JOURNAL") != "" {
chunkJournalFeatureFlag = false
}
}
var chunkJournalFeatureFlag = true
const (
// DoltDir defines the directory used to hold the dolt repo data within the filesys
DoltDir = ".dolt"
// DataDir is the directory internal to the DoltDir which holds the noms files.
DataDir = "noms"
ChunkJournalParam = "journal"
)
// DoltDataDir is the directory where noms files will be stored
@@ -103,12 +114,11 @@ func (fact FileFactory) CreateDB(ctx context.Context, nbf *types.NomsBinFormat,
singletonLock.Lock()
defer singletonLock.Unlock()
if s, ok := singletons[urlObj.String()]; ok {
if s, ok := singletons[urlObj.Path]; ok {
return s.ddb, s.vrw, s.ns, nil
}
path, err := url.PathUnescape(urlObj.Path)
if err != nil {
return nil, nil, nil, err
}
@@ -121,9 +131,14 @@ func (fact FileFactory) CreateDB(ctx context.Context, nbf *types.NomsBinFormat,
return nil, nil, nil, err
}
var useJournal bool
if params != nil {
_, useJournal = params[ChunkJournalParam]
}
var newGenSt *nbs.NomsBlockStore
q := nbs.NewUnlimitedMemQuotaProvider()
if nbs.UseJournalStore(path) {
if useJournal && chunkJournalFeatureFlag {
newGenSt, err = nbs.NewLocalJournalingStore(ctx, nbf.VersionString(), path, q)
} else {
newGenSt, err = nbs.NewLocalStore(ctx, nbf.VersionString(), path, defaultMemTableSize, q)
@@ -159,7 +174,7 @@ func (fact FileFactory) CreateDB(ctx context.Context, nbf *types.NomsBinFormat,
ns := tree.NewNodeStore(st)
ddb := datas.NewTypesDatabase(vrw, ns)
singletons[urlObj.String()] = singletonDB{
singletons[urlObj.Path] = singletonDB{
ddb: ddb,
vrw: vrw,
ns: ns,

View File

@@ -24,8 +24,9 @@ import (
"time"
"github.com/dolthub/dolt/go/libraries/doltcore/dbfactory"
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
"github.com/dolthub/dolt/go/libraries/utils/filesys"
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
"github.com/dolthub/dolt/go/store/chunks"
"github.com/dolthub/dolt/go/store/datas"
"github.com/dolthub/dolt/go/store/datas/pull"
@@ -95,7 +96,6 @@ func LoadDoltDB(ctx context.Context, nbf *types.NomsBinFormat, urlStr string, fs
func LoadDoltDBWithParams(ctx context.Context, nbf *types.NomsBinFormat, urlStr string, fs filesys.Filesys, params map[string]interface{}) (*DoltDB, error) {
if urlStr == LocalDirDoltDB {
exists, isDir := fs.Exists(dbfactory.DoltDataDir)
if !exists {
return nil, errors.New("missing dolt data directory")
} else if !isDir {
@@ -108,14 +108,17 @@ func LoadDoltDBWithParams(ctx context.Context, nbf *types.NomsBinFormat, urlStr
}
urlStr = fmt.Sprintf("file://%s", filepath.ToSlash(absPath))
if params == nil {
params = make(map[string]any)
}
params[dbfactory.ChunkJournalParam] = struct{}{}
}
db, vrw, ns, err := dbfactory.CreateDB(ctx, nbf, urlStr, params)
if err != nil {
return nil, err
}
return &DoltDB{hooksDatabase{Database: db}, vrw, ns}, nil
}

View File

@@ -42,7 +42,7 @@ type ArtifactIndex interface {
// RefFromArtifactIndex persists |idx| and returns the types.Ref targeting it.
func RefFromArtifactIndex(ctx context.Context, vrw types.ValueReadWriter, idx ArtifactIndex) (types.Ref, error) {
switch idx.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
panic("TODO")
case types.Format_DOLT:
@@ -57,7 +57,7 @@ func RefFromArtifactIndex(ctx context.Context, vrw types.ValueReadWriter, idx Ar
// NewEmptyArtifactIndex returns an ArtifactIndex with no artifacts.
func NewEmptyArtifactIndex(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeStore, tableSch schema.Schema) (ArtifactIndex, error) {
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
panic("TODO")
case types.Format_DOLT:
@@ -94,7 +94,7 @@ func artifactIndexFromAddr(ctx context.Context, vrw types.ValueReadWriter, ns tr
}
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
panic("TODO")
case types.Format_DOLT:

View File

@@ -33,7 +33,7 @@ type ConflictIndex interface {
// RefFromConflictIndex persists |idx| and returns the types.Ref targeting it.
func RefFromConflictIndex(ctx context.Context, vrw types.ValueReadWriter, idx ConflictIndex) (types.Ref, error) {
switch idx.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
return refFromNomsValue(ctx, vrw, idx.(nomsConflictIndex).index)
case types.Format_DOLT:
@@ -47,7 +47,7 @@ func RefFromConflictIndex(ctx context.Context, vrw types.ValueReadWriter, idx Co
// NewEmptyConflictIndex returns an ConflictIndex with no rows.
func NewEmptyConflictIndex(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeStore, oursSch, theirsSch, baseSch schema.Schema) (ConflictIndex, error) {
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
m, err := types.NewMap(ctx, vrw)
if err != nil {
return nil, err
@@ -84,7 +84,7 @@ func conflictIndexFromAddr(ctx context.Context, vrw types.ValueReadWriter, ns tr
}
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
return ConflictIndexFromNomsMap(v.(types.Map), vrw), nil
case types.Format_DOLT:

View File

@@ -77,7 +77,7 @@ type IndexSet interface {
// RefFromIndex persists the Index and returns a types.Ref to it.
func RefFromIndex(ctx context.Context, vrw types.ValueReadWriter, idx Index) (types.Ref, error) {
switch idx.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
return refFromNomsValue(ctx, vrw, idx.(nomsIndex).index)
case types.Format_DOLT:
@@ -101,7 +101,7 @@ func indexFromAddr(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeS
}
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
return IndexFromNomsMap(v.(types.Map), vrw, ns), nil
case types.Format_DOLT:
@@ -119,7 +119,7 @@ func indexFromAddr(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeS
// NewEmptyIndex returns an index with no rows.
func NewEmptyIndex(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeStore, sch schema.Schema) (Index, error) {
switch vrw.Format() {
case types.Format_LD_1, types.Format_7_18, types.Format_DOLT_DEV:
case types.Format_LD_1, types.Format_7_18:
m, err := types.NewMap(ctx, vrw)
if err != nil {
return nil, err

View File

@@ -26,7 +26,6 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/conflict"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/schema/encoding"
"github.com/dolthub/dolt/go/store/chunks"
"github.com/dolthub/dolt/go/store/hash"
"github.com/dolthub/dolt/go/store/pool"
"github.com/dolthub/dolt/go/store/prolly"
@@ -722,19 +721,12 @@ func (t doltDevTable) DebugString(ctx context.Context) string {
panic(err)
}
if t.vrw.Format() == types.Format_DOLT_DEV {
m := NomsMapFromIndex(rows)
var b bytes.Buffer
_ = types.WriteEncodedValue(ctx, &b, m)
return b.String()
} else {
m := ProllyMapFromIndex(rows)
var b bytes.Buffer
m.WalkNodes(ctx, func(ctx context.Context, nd tree.Node) error {
return tree.OutputProllyNode(&b, nd)
})
return b.String()
}
m := ProllyMapFromIndex(rows)
var b bytes.Buffer
m.WalkNodes(ctx, func(ctx context.Context, nd tree.Node) error {
return tree.OutputProllyNode(&b, nd)
})
return b.String()
}
var _ Table = doltDevTable{}
@@ -877,24 +869,15 @@ func (t doltDevTable) SetSchema(ctx context.Context, sch schema.Schema) (Table,
func (t doltDevTable) GetTableRows(ctx context.Context) (Index, error) {
rowbytes := t.msg.PrimaryIndexBytes()
if t.vrw.Format() == types.Format_DOLT_DEV {
rowchunk := chunks.NewChunk(rowbytes)
tv, err := types.DecodeValue(rowchunk, t.vrw)
if err != nil {
return nil, err
}
return IndexFromNomsMap(tv.(types.Map), t.vrw, t.ns), nil
} else {
sch, err := t.GetSchema(ctx)
if err != nil {
return nil, err
}
m, err := shim.MapFromValue(types.SerialMessage(rowbytes), sch, t.ns)
if err != nil {
return nil, err
}
return IndexFromProllyMap(m), nil
sch, err := t.GetSchema(ctx)
if err != nil {
return nil, err
}
m, err := shim.MapFromValue(types.SerialMessage(rowbytes), sch, t.ns)
if err != nil {
return nil, err
}
return IndexFromProllyMap(m), nil
}
func (t doltDevTable) SetTableRows(ctx context.Context, rows Index) (Table, error) {

View File

@@ -457,7 +457,6 @@ func NewPullSpec(_ context.Context, rsr RepoStateReader, remoteName, remoteRefNa
func GetAbsRemoteUrl(fs filesys2.Filesys, cfg config.ReadableConfig, urlArg string) (string, string, error) {
u, err := earl.Parse(urlArg)
if err != nil {
return "", "", err
}

View File

@@ -137,10 +137,11 @@ func initMigrationDB(ctx context.Context, existing *env.DoltEnv, src, dest files
return err
}
db, vrw, ns, err := dbfactory.FileFactory{}.CreateDB(ctx, targetFormat, u, nil)
if err != nil {
return err
}
params := map[string]any{dbfactory.ChunkJournalParam: struct{}{}}
ddb, err := doltdb.LoadDoltDBWithParams(ctx, targetFormat, u.String(), dest, params)
vrw := ddb.ValueReadWriter()
ns := ddb.NodeStore()
db := doltdb.HackDatasDatabaseFromDoltDB(ddb)
// write init commit for migration
name, email, err := env.GetNameAndEmail(existing.Config)

View File

@@ -334,13 +334,22 @@ var ErrKeylessAltTbl = errors.New("schema alterations not supported for keyless
// backupFkcIndexesForKeyDrop finds backup indexes to cover foreign key references during a primary
// key drop. If multiple indexes are valid, we sort by unique and select the first.
// This will not work with a non-pk index drop without an additional index filter argument.
func backupFkcIndexesForPkDrop(ctx *sql.Context, sch schema.Schema, fkc *doltdb.ForeignKeyCollection) ([]doltdb.FkIndexUpdate, error) {
func backupFkcIndexesForPkDrop(ctx *sql.Context, tbl string, sch schema.Schema, fkc *doltdb.ForeignKeyCollection) ([]doltdb.FkIndexUpdate, error) {
fkUpdates := make([]doltdb.FkIndexUpdate, 0)
for _, fk := range fkc.AllKeys() {
// if an index doesn't reference primary key, it is unaffected
declared, referenced := fkc.KeysForTable(tbl)
for _, fk := range declared {
if fk.TableIndex == "" {
// pk used in fk definition on |tbl|
return nil, sql.ErrCantDropIndex.New("PRIMARY", fk.Name)
}
}
for _, fk := range referenced {
if fk.ReferencedTableIndex != "" {
// if an index doesn't reference primary key, it is unaffected
continue
}
// pk reference by fk definition on |fk.TableName|
// get column names from tags in foreign key
fkParentCols := make([]string, len(fk.ReferencedTableColumns))
@@ -353,9 +362,8 @@ func backupFkcIndexesForPkDrop(ctx *sql.Context, sch schema.Schema, fkc *doltdb.
newIdx, ok, err := findIndexWithPrefix(sch, sch.GetPKCols().GetColumnNames())
if err != nil {
return nil, err
}
if !ok {
return nil, sql.ErrCantDropIndex.New("PRIMARY")
} else if !ok {
return nil, sql.ErrCantDropIndex.New("PRIMARY", fk.Name)
}
fkUpdates = append(fkUpdates, doltdb.FkIndexUpdate{FkName: fk.Name, FromIdx: fk.ReferencedTableIndex, ToIdx: newIdx.Name()})

View File

@@ -304,7 +304,7 @@ func (d *doltBinlogReplicaController) ResetReplica(ctx *sql.Context, resetAll bo
return err
}
d.filters = nil
d.filters = newFilterConfiguration()
}
return nil

View File

@@ -519,8 +519,8 @@ func assertValues(t *testing.T, assertionIndex int, row map[string]interface{})
actualValue = row[typeDesc.ColumnName()].(string)
}
if typeDesc.TypeDefinition == "json" {
// LD_1, DOLT_DEV, and DOLT storage formats return JSON strings slightly differently; DOLT removes spaces
// while LD_1 and DOLT_DEV add whitespace, so for json comparison, we sanitize by removing whitespace.
// LD_1 and DOLT storage formats return JSON strings slightly differently; DOLT removes spaces
// while LD_1 add whitespace, so for json comparison, we sanitize by removing whitespace.
actualValue = strings.ReplaceAll(actualValue, " ", "")
}

View File

@@ -137,8 +137,8 @@ func requireRecentTimeString(t *testing.T, datetime interface{}) {
// name of each column.
func showReplicaStatus(t *testing.T) map[string]interface{} {
rows, err := replicaDatabase.Queryx("show replica status;")
defer rows.Close()
require.NoError(t, err)
defer rows.Close()
return convertByteArraysToStrings(readNextRow(t, rows))
}

View File

@@ -33,9 +33,10 @@ import (
"time"
"github.com/jmoiron/sqlx"
_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
"github.com/dolthub/go-mysql-server/sql/binlogreplication"
_ "github.com/go-sql-driver/mysql"
)
var mySqlPort, doltPort int
@@ -51,7 +52,7 @@ func teardown(t *testing.T) {
mySqlProcess.Kill()
}
if doltProcess != nil {
doltProcess.Kill()
stopDoltSqlServer(t)
}
if mysqlLogFile != nil {
mysqlLogFile.Close()
@@ -172,6 +173,14 @@ func TestResetReplica(t *testing.T) {
require.NoError(t, err)
require.False(t, rows.Next())
require.NoError(t, rows.Close())
// Start replication again and verify that we can still query replica status
startReplication(t, mySqlPort)
replicaStatus := showReplicaStatus(t)
require.Equal(t, "0", replicaStatus["Last_Errno"])
require.Equal(t, "", replicaStatus["Last_Error"])
require.True(t, replicaStatus["Replica_IO_Running"] == binlogreplication.ReplicaIoRunning ||
replicaStatus["Replica_IO_Running"] == binlogreplication.ReplicaIoConnecting)
}
// TestStartReplicaErrors tests that the "START REPLICA" command returns appropriate responses
@@ -205,6 +214,18 @@ func TestStartReplicaErrors(t *testing.T) {
assertWarning(t, replicaDatabase, 3083, "Replication thread(s) for channel '' are already running.")
}
// TestShowReplicaStatus tests various cases "SHOW REPLICA STATUS" that aren't covered by other tests.
func TestShowReplicaStatus(t *testing.T) {
defer teardown(t)
startSqlServers(t)
// Assert that very long hostnames are handled correctly
longHostname := "really.really.really.really.long.host.name.012345678901234567890123456789012345678901234567890123456789.com"
replicaDatabase.MustExec(fmt.Sprintf("CHANGE REPLICATION SOURCE TO SOURCE_HOST='%s';", longHostname))
status := showReplicaStatus(t)
require.Equal(t, longHostname, status["Source_Host"])
}
// TestStopReplica tests that STOP REPLICA correctly stops the replication process, and that
// warnings are logged when STOP REPLICA is invoked when replication is not running.
func TestStopReplica(t *testing.T) {

View File

@@ -653,7 +653,7 @@ func (p DoltDatabaseProvider) DropDatabase(ctx *sql.Context, name string) error
}
// If this database is re-created, we don't want to return any cached results.
err = dbfactory.DeleteFromSingletonCache("file://" + dropDbLoc + "/.dolt/noms")
err = dbfactory.DeleteFromSingletonCache(dropDbLoc + "/.dolt/noms")
if err != nil {
return err
}

View File

@@ -442,7 +442,7 @@ func TestDoltUserPrivileges(t *testing.T) {
}
func TestJoinOps(t *testing.T) {
if types.IsFormat_DOLT_DEV(types.Format_Default) || types.IsFormat_LD(types.Format_Default) {
if types.IsFormat_LD(types.Format_Default) {
t.Skip("DOLT_LD keyless indexes are not sorted")
}
@@ -450,7 +450,7 @@ func TestJoinOps(t *testing.T) {
}
func TestJoinPlanningPrepared(t *testing.T) {
if types.IsFormat_DOLT_DEV(types.Format_Default) || types.IsFormat_LD(types.Format_Default) {
if types.IsFormat_LD(types.Format_Default) {
t.Skip("DOLT_LD keyless indexes are not sorted")
}
@@ -458,7 +458,7 @@ func TestJoinPlanningPrepared(t *testing.T) {
}
func TestJoinPlanning(t *testing.T) {
if types.IsFormat_DOLT_DEV(types.Format_Default) || types.IsFormat_LD(types.Format_Default) {
if types.IsFormat_LD(types.Format_Default) {
t.Skip("DOLT_LD keyless indexes are not sorted")
}
@@ -466,7 +466,7 @@ func TestJoinPlanning(t *testing.T) {
}
func TestJoinOpsPrepared(t *testing.T) {
if types.IsFormat_DOLT_DEV(types.Format_Default) || types.IsFormat_LD(types.Format_Default) {
if types.IsFormat_LD(types.Format_Default) {
t.Skip("DOLT_LD keyless indexes are not sorted")
}

View File

@@ -217,6 +217,9 @@ func PutField(ctx context.Context, ns tree.NodeStore, tb *val.TupleBuilder, i in
case val.CommitAddrEnc:
tb.PutCommitAddr(i, v.(hash.Hash))
case val.CellEnc:
if _, ok := v.([]byte); ok {
v = deserializeGeometry(v.([]byte))
}
tb.PutCell(i, ZCell(v.(types.GeometryValue)))
default:
panic(fmt.Sprintf("unknown encoding %v %v", enc, v))

View File

@@ -92,8 +92,6 @@ func BasicSelectTests() []SelectTest {
switch types.Format_Default {
case types.Format_DOLT:
headCommitHash = "a0gt4vif0b0bf19g89k87gs55qqlqpod"
case types.Format_DOLT_DEV:
headCommitHash = "a0gt4vif0b0bf19g89k87gs55qqlqpod"
case types.Format_LD_1:
headCommitHash = "73hc2robs4v0kt9taoe3m5hd49dmrgun"
}

View File

@@ -1395,7 +1395,7 @@ func (t *AlterableDoltTable) RewriteInserter(
}
if len(oldSchema.PkOrdinals) > 0 && len(newSchema.PkOrdinals) == 0 {
newRoot, err = t.adjustForeignKeysForDroppedPk(ctx, newRoot)
newRoot, err = t.adjustForeignKeysForDroppedPk(ctx, t.Name(), newRoot)
if err != nil {
return nil, err
}
@@ -1534,7 +1534,7 @@ func validateSchemaChange(
return nil
}
func (t *AlterableDoltTable) adjustForeignKeysForDroppedPk(ctx *sql.Context, root *doltdb.RootValue) (*doltdb.RootValue, error) {
func (t *AlterableDoltTable) adjustForeignKeysForDroppedPk(ctx *sql.Context, tbl string, root *doltdb.RootValue) (*doltdb.RootValue, error) {
if t.autoIncCol.AutoIncrement {
return nil, sql.ErrWrongAutoKey.New()
}
@@ -1544,7 +1544,7 @@ func (t *AlterableDoltTable) adjustForeignKeysForDroppedPk(ctx *sql.Context, roo
return nil, err
}
fkcUpdates, err := backupFkcIndexesForPkDrop(ctx, t.sch, fkc)
fkcUpdates, err := backupFkcIndexesForPkDrop(ctx, tbl, t.sch, fkc)
if err != nil {
return nil, err
}

View File

@@ -564,7 +564,7 @@ func SqlRowsFromDurableIndex(idx durable.Index, sch schema.Schema) ([]sql.Row, e
}
} else {
// types.Format_LD_1 and types.Format_DOLT_DEV
// types.Format_LD_1
rowData := durable.NomsMapFromIndex(idx)
_ = rowData.IterAll(ctx, func(key, value types.Value) error {
r, err := row.FromNoms(sch, key.(types.Tuple), value.(types.Tuple))

View File

@@ -26,6 +26,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/writer"
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
"github.com/dolthub/dolt/go/store/prolly"
@@ -141,7 +142,7 @@ func CreateIndex(
func BuildSecondaryIndex(ctx context.Context, tbl *doltdb.Table, idx schema.Index, opts editor.Options) (durable.Index, error) {
switch tbl.Format() {
case types.Format_LD_1, types.Format_DOLT_DEV:
case types.Format_LD_1:
m, err := editor.RebuildIndex(ctx, tbl, idx.Name(), opts)
if err != nil {
return nil, err
@@ -211,7 +212,11 @@ func BuildSecondaryProllyIndex(ctx context.Context, vrw types.ValueReadWriter, n
keyBld.PutRaw(to, k.GetField(from))
} else {
from -= pkLen
keyBld.PutRaw(to, v.GetField(from))
if keyBld.Desc.Types[to].Enc == val.CellEnc {
index.PutField(ctx, ns, keyBld, to, v.GetField(from))
} else {
keyBld.PutRaw(to, v.GetField(from))
}
}
}

View File

@@ -174,12 +174,6 @@ func SetupDB(ctx context.Context, mConfig MysqlConfig, databaseName string) (err
if err != nil {
return err
}
// set MySQL durability level to match Dolt
// dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit
_, err = db.ExecContext(ctx, "SET GLOBAL innodb_flush_log_at_trx_commit=2;")
if err != nil {
return err
}
// Required for running groupby_scan.lua without error
_, err = db.ExecContext(ctx, "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));")
if err != nil {

View File

@@ -69,9 +69,6 @@ func (s *nomsDsTestSuite) TestNomsDs() {
case types.Format_LD_1:
golden1 = "oetp3jigkp5pid2f5c4mknpo17mso31b"
golden2 = "tsbj1qq88llk3k8qqqb5n3188sbpiu7r"
case types.Format_DOLT_DEV:
golden1 = "c7g244286kom2a1326kkgs85pi97cjs7"
golden2 = "rn7dsl1146qr2n4chtg41n24n0jqgnte"
default:
s.Fail("no golden values exist for NBF %s", types.Format_Default.VersionString())
}

View File

@@ -60,9 +60,6 @@ func (s *nomsRootTestSuite) TestBasic() {
case types.Format_LD_1:
goldenHello = "u8g2r4qg97kkqn42lvao77st2mv3bpl0\n"
goldenGoodbye = "70b9adi6amrab3a5t4hcibdob0cq49m0\n"
case types.Format_DOLT_DEV:
goldenHello = "sf173aaa57qjoakme0iufkg4c17beoqe\n"
goldenGoodbye = "gjcehnn4v0sbtt1hste082hfv1kg0hqv\n"
default:
s.Fail("no golden values exist for NBF %s", types.Format_Default.VersionString())
}

View File

@@ -41,13 +41,4 @@ const Format718String = "7.18"
const FormatLD1String = "__LD_1__"
const FormatDoltString = "__DOLT__"
// A temporary format used for developing flatbuffers serialization of
// top-of-DAG entities like StoreRoot, {Tag,WorkingSet,Commit}Head, etc.
// Semantics are: __LD_1__ for everything that hasn't been migrated, and what
// will become top-of-DAG in __DOLT__ for everything else.
//
// Things that will migrate are all structs leading up to table data and index
// data maps.
const FormatDoltDevString = "__DOLT_DEV__"
var FormatDefaultString = FormatDoltString

View File

@@ -19,7 +19,6 @@ import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
"sort"
"time"
@@ -28,31 +27,12 @@ import (
"github.com/dolthub/dolt/go/store/hash"
)
var chunkJournalFeatureFlag = false
func init() {
if os.Getenv("DOLT_ENABLE_CHUNK_JOURNAL") != "" {
chunkJournalFeatureFlag = true
}
}
func UseJournalStore(path string) bool {
if chunkJournalFeatureFlag {
return true
}
ok, err := fileExists(filepath.Join(path, chunkJournalAddr))
if err != nil {
panic(err)
}
return ok
}
const (
chunkJournalName = chunkJournalAddr // todo
)
// chunkJournal is a persistence abstraction for a NomsBlockStore.
// It implemented both manifest and tablePersister, durably writing
// It implements both manifest and tablePersister, durably writing
// both memTable persists and manifest updates to a single file.
type chunkJournal struct {
wr *journalWriter
@@ -92,11 +72,11 @@ func newChunkJournal(ctx context.Context, nbfVers, dir string, m manifest, p *fs
}
// bootstrapJournalWriter initializes the journalWriter, which manages access to the
// journal file for this chunkJournal. The bootstrapping process differed depending
// journal file for this chunkJournal. The bootstrapping process differs depending
// on whether a journal file exists at startup time.
//
// If a journal file does not exist, we create one and commit a root hash record
// which we read from the manifest file.
// containing the root hash we read from the manifest file.
//
// If a journal file does exist, we process its records to build up an index of its
// resident chunks. Processing journal records is potentially accelerated by an index

View File

@@ -518,12 +518,8 @@ func (idx rangeIndex) novelLookups() (lookups []lookup) {
}
func (idx rangeIndex) flatten() {
if len(idx.cached) == 0 {
idx.cached = idx.novel
} else {
for a, r := range idx.novel {
idx.cached[a] = r
}
for a, r := range idx.novel {
idx.cached[a] = r
delete(idx.novel, a)
}
idx.novel = make(map[addr]Range)
}

View File

@@ -402,3 +402,20 @@ func corruptJournalIndex(t *testing.T, path string) {
_, err = f.WriteAt(buf, info.Size()/2)
require.NoError(t, err)
}
func TestRangeIndex(t *testing.T) {
data := randomCompressedChunks(1024)
idx := newRangeIndex()
for _, c := range data {
idx.put(addr(c.Hash()), Range{})
}
for _, c := range data {
_, ok := idx.get(addr(c.Hash()))
assert.True(t, ok)
}
assert.Equal(t, len(data), idx.novelCount())
assert.Equal(t, len(data), int(idx.count()))
idx.flatten()
assert.Equal(t, 0, idx.novelCount())
assert.Equal(t, len(data), int(idx.count()))
}

View File

@@ -26,6 +26,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"sort"
"sync"
"sync/atomic"
@@ -486,6 +487,12 @@ func newLocalStore(ctx context.Context, nbfVerStr string, dir string, memTableSi
if err := checkDir(dir); err != nil {
return nil, err
}
ok, err := fileExists(filepath.Join(dir, chunkJournalAddr))
if err != nil {
return nil, err
} else if ok {
return nil, fmt.Errorf("cannot create NBS store for directory containing chunk journal: %s", dir)
}
m, err := getFileManifest(ctx, dir, asyncFlush)
if err != nil {

View File

@@ -654,7 +654,5 @@ func TestNomsBinFormat(t *testing.T) {
assert.Equal(t, Format_LD_1, Format_Default)
case constants.FormatDoltString:
assert.Equal(t, Format_DOLT, Format_Default)
case constants.FormatDoltDevString:
assert.Equal(t, Format_DOLT_DEV, Format_Default)
}
}

View File

@@ -42,12 +42,10 @@ type formatTag struct {
var formatTag_7_18 *formatTag = nil
var formatTag_LD_1 = &formatTag{}
var formatTag_DOLT = &formatTag{}
var formatTag_DOLT_DEV = &formatTag{}
var Format_7_18 = &NomsBinFormat{}
var Format_LD_1 = &NomsBinFormat{formatTag_LD_1}
var Format_DOLT = &NomsBinFormat{formatTag_DOLT}
var Format_DOLT_DEV = &NomsBinFormat{formatTag_DOLT_DEV}
var nbfLock = &sync.Mutex{}
var Format_Default *NomsBinFormat
@@ -57,7 +55,6 @@ var emptyTuples = make(map[*NomsBinFormat]Tuple)
func init() {
emptyTuples[Format_7_18], _ = NewTuple(Format_7_18)
emptyTuples[Format_LD_1], _ = NewTuple(Format_LD_1)
emptyTuples[Format_DOLT_DEV], _ = NewTuple(Format_DOLT_DEV)
}
func isFormat_7_18(nbf *NomsBinFormat) bool {
@@ -68,10 +65,6 @@ func IsFormat_DOLT(nbf *NomsBinFormat) bool {
return nbf.tag == formatTag_DOLT
}
func IsFormat_DOLT_DEV(nbf *NomsBinFormat) bool {
return nbf.tag == formatTag_DOLT_DEV
}
func IsFormat_LD(nbf *NomsBinFormat) bool {
return nbf.tag == formatTag_LD_1
}
@@ -83,8 +76,6 @@ func GetFormatForVersionString(s string) (*NomsBinFormat, error) {
return Format_LD_1, nil
} else if s == constants.FormatDoltString {
return Format_DOLT, nil
} else if s == constants.FormatDoltDevString {
return Format_DOLT_DEV, nil
} else {
return nil, errors.New("unsupported ChunkStore version " + s)
}
@@ -97,13 +88,11 @@ func (nbf *NomsBinFormat) VersionString() string {
return constants.FormatLD1String
} else if nbf.tag == formatTag_DOLT {
return constants.FormatDoltString
} else if nbf.tag == formatTag_DOLT_DEV {
return constants.FormatDoltDevString
} else {
panic("unrecognized NomsBinFormat tag value")
}
}
func (nbf *NomsBinFormat) UsesFlatbuffers() bool {
return nbf.tag == formatTag_DOLT || nbf.tag == formatTag_DOLT_DEV
return nbf.tag == formatTag_DOLT
}

View File

@@ -339,19 +339,7 @@ func (sm SerialMessage) WalkAddrs(nbf *NomsBinFormat, cb func(addr hash.Hash) er
}
mapbytes := msg.PrimaryIndexBytes()
if nbf == Format_DOLT_DEV {
dec := newValueDecoder(mapbytes, nil)
v, err := dec.readValue(nbf)
if err != nil {
return err
}
return v.walkRefs(nbf, func(ref Ref) error {
return cb(ref.TargetHash())
})
} else {
return SerialMessage(mapbytes).WalkAddrs(nbf, cb)
}
return SerialMessage(mapbytes).WalkAddrs(nbf, cb)
case serial.CommitFileID:
parents, err := SerialCommitParentAddrs(nbf, sm)
if err != nil {

View File

@@ -240,8 +240,6 @@ func read(ctx context.Context, rd io.Reader) (hash.Hash, *FileValueStore, error)
nbf = types.Format_7_18
case types.Format_LD_1.VersionString():
nbf = types.Format_LD_1
case types.Format_DOLT_DEV.VersionString():
nbf = types.Format_DOLT_DEV
case types.Format_DOLT.VersionString():
nbf = types.Format_DOLT
default:

View File

@@ -301,12 +301,6 @@ DELIM
[ $status -ne 0 ]
echo $output
[[ $output =~ "update-tag is only available in storage format __DOLT__" ]] || false
cd ../dev
DOLT_DEFAULT_BIN_FORMAT=__DOLT_DEV__ dolt init
run dolt schema update-tag t col 5
[ $status -ne 0 ]
[[ $output =~ "update-tag is only available in storage format __DOLT__" ]] || false
}
@test "column_tags: update-tag updates a columns tag" {

View File

@@ -64,22 +64,14 @@ assert_feature_version() {
}
skip_nbf_dolt() {
if [ ! "$DOLT_DEFAULT_BIN_FORMAT" = "__LD_1__" ] &&
[ ! "$DOLT_DEFAULT_BIN_FORMAT" = "__DOLT_DEV__" ];
if [ ! "$DOLT_DEFAULT_BIN_FORMAT" = "__LD_1__" ]
then
skip "skipping test for nomsBinFormat __DOLT__"
fi
}
skip_nbf_dolt_dev() {
if [ "$DOLT_DEFAULT_BIN_FORMAT" = "__DOLT_DEV__" ]; then
skip "skipping test for nomsBinFormat __DOLT_DEV__"
fi
}
skip_nbf_not_dolt() {
if [ "$DOLT_DEFAULT_BIN_FORMAT" = "__LD_1__" ] ||
[ "$DOLT_DEFAULT_BIN_FORMAT" = "__DOLT_DEV__" ];
if [ "$DOLT_DEFAULT_BIN_FORMAT" = "__LD_1__" ]
then
skip "skipping test since nomsBinFormat != __DOLT__"
fi

View File

@@ -588,6 +588,7 @@ DELIM
dolt gc
AFTER=$(du -c .dolt/noms/ | grep total | sed 's/[^0-9]*//g')
skip "chunk journal doesn't shrink"
# less than 10% smaller
[ "$BEFORE" -lt $(($AFTER * 11 / 10)) ]
}

View File

@@ -2,8 +2,6 @@
load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
skip_nbf_dolt_dev
TARGET_NBF="__DOLT__"
setup_no_dolt_init
dolt init --old-format

View File

@@ -3,7 +3,6 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
skip_nbf_dolt
skip_nbf_dolt_dev
setup_common
TARGET_NBF="__DOLT__"

View File

@@ -455,7 +455,7 @@ SQL
run dolt sql -q "ALTER TABLE child DROP PRIMARY KEY"
[ "$status" -eq 1 ]
[[ "$output" =~ "error: can't drop index 'PRIMARY': needed in a foreign key constraint" ]] || false
[[ "$output" =~ "error: can't drop index 'PRIMARY': needed in foreign key constraint" ]] || false
}
@test "primary-key-changes: dolt constraints verify works gracefully with schema violations" {

View File

@@ -11,9 +11,6 @@ teardown() {
}
skip_if_no_aws_tests() {
if [ "$DOLT_DEFAULT_BIN_FORMAT" = "__DOLT_DEV__" ]; then
skip "skipping aws tests; DOLT_DEFAULT_BIN_FORMAT is __DOLT_DEV__"
fi
if [ -z "$DOLT_BATS_AWS_TABLE" -o -z "$DOLT_BATS_AWS_BUCKET" -o -z "$DOLT_BATS_AWS_EXISTING_REPO" ]; then
skip "skipping aws tests; set DOLT_BATS_AWS_TABLE, DOLT_BATS_AWS_BUCKET and DOLT_BATS_AWS_EXISTING_REPO to run"
fi

View File

@@ -1797,66 +1797,21 @@ setup_ref_test() {
dolt push
}
@test "remotes: clone local repo with file url" {
mkdir repo1
cd repo1
dolt init
dolt commit --allow-empty -am "commit from repo1"
cd ..
dolt clone file://./repo1/.dolt/noms repo2
cd repo2
run dolt log
[[ "$output" =~ "commit from repo1" ]] || false
run dolt status
[[ "$output" =~ "nothing to commit, working tree clean" ]] || false
dolt commit --allow-empty -am "commit from repo2"
dolt push
cd ../repo1
run dolt log
[[ "$output" =~ "commit from repo1" ]]
[[ "$output" =~ "commit from repo2" ]]
}
@test "remotes: clone local repo with absolute file path" {
skiponwindows "absolute paths don't work on windows"
mkdir repo1
cd repo1
dolt init
dolt commit --allow-empty -am "commit from repo1"
cd ..
dolt clone file://$(pwd)/repo1/.dolt/noms repo2
cd repo2
run dolt log
[[ "$output" =~ "commit from repo1" ]] || false
run dolt status
[[ "$output" =~ "nothing to commit, working tree clean" ]] || false
dolt commit --allow-empty -am "commit from repo2"
dolt push
cd ../repo1
run dolt log
[[ "$output" =~ "commit from repo1" ]]
[[ "$output" =~ "commit from repo2" ]]
}
@test "remotes: local clone does not contain working set changes" {
mkdir repo1
mkdir rem1
cd repo1
dolt init
run dolt sql -q "create table t (i int)"
[ "$status" -eq 0 ]
dolt sql -q "create table t (i int)"
run dolt status
[[ "$output" =~ "new table:" ]] || false
dolt commit -Am "new table"
dolt sql -q "create table t2 (i int)"
dolt remote add rem1 file://../rem1
dolt push rem1 main
cd ..
dolt clone file://./repo1/.dolt/noms repo2
dolt clone file://./rem1/ repo2
cd repo2
run dolt status
@@ -1865,19 +1820,28 @@ setup_ref_test() {
@test "remotes: local clone pushes to other branch" {
mkdir repo1
mkdir rem1
cd repo1
dolt init
dolt sql -q "create table t (i int)"
run dolt status
[[ "$output" =~ "new table:" ]] || false
dolt commit -Am "new table"
dolt remote add rem1 file://../rem1
dolt push rem1 main
cd ..
dolt clone file://./repo1/.dolt/noms repo2
dolt clone file://./rem1/ repo2
cd repo2
dolt checkout -b other
dolt sql -q "create table t (i int)"
dolt sql -q "create table t2 (i int)"
dolt add .
dolt commit -am "adding table from other"
dolt push origin other
dolt remote add rem1 file://../rem1
dolt push rem1 other
cd ../repo1
dolt fetch rem1
dolt checkout other
run dolt log
[[ "$output" =~ "adding table from other" ]]

View File

@@ -12,10 +12,6 @@ make_repo() {
setup() {
skiponwindows "tests are flaky on Windows"
setup_no_dolt_init
mkdir $BATS_TMPDIR/sql-server-test$$
nativevar DOLT_ROOT_PATH $BATS_TMPDIR/sql-server-test$$ /p
dolt config --global --add user.email "test@test.com"
dolt config --global --add user.name "test"
make_repo repo1
make_repo repo2
}
@@ -26,6 +22,16 @@ teardown() {
teardown_common
}
@test "sql-server: sanity check" {
cd repo1
for i in {1..16};
do
dolt sql -q "create table t_$i (pk int primary key, c$i int)"
dolt add -A
dolt commit -m "new table t_$i"
done
}
@test "sql-server: can create savepoint when no database is selected" {
skiponwindows "Missing dependencies"
skip "currently fails with: Error 1105: plan is not resolved because of node '*plan.CreateSavepoint' in server log"
@@ -1507,8 +1513,6 @@ databases:
run grep '\"/tmp/mysql.sock\"' log.txt
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 1 ]
rm /tmp/mysql.sock
}
@test "sql-server: the second server starts without unix socket set up if there is already a file in the socket file path" {
@@ -1629,7 +1633,6 @@ s.close()
run ls repo2/.dolt
[[ "$output" =~ "sql-server.lock" ]] || false
skip "this now fails because of the socket file not being cleaned up"
start_sql_server
run dolt sql-client -P $PORT -u dolt --use-db repo2 -q "select 1 as col1"
[ $status -eq 0 ]
@@ -1701,7 +1704,7 @@ s.close()
[ $status -eq 0 ]
skip "Forcefully deleting a database doesn't cause direct panics, but also doesn't stop the server"
run grep "panic" server_log.txt
[ "${#lines[@]}" -eq 0 ]
@@ -1775,12 +1778,10 @@ s.close()
dolt sql-client -P $PORT -u dolt --use-db '' -q "CREATE DATABASE mydb1;"
[ -d mydb1 ]
run dolt sql-client -P $PORT -u dolt --use-db '' -q "DROP DATABASE mydb1;"
[ $status -eq 0 ]
dolt sql-client -P $PORT -u dolt --use-db '' -q "DROP DATABASE mydb1;"
[ ! -d mydb1 ]
run dolt sql-client -P $PORT -u dolt --use-db '' -q "CREATE DATABASE mydb1;"
[ $status -eq 0 ]
dolt sql-client -P $PORT -u dolt --use-db '' -q "CREATE DATABASE mydb1;"
[ -d mydb1 ]
run dolt sql-client -P $PORT -u dolt --use-db '' -q "SHOW DATABASES;"
@@ -1806,47 +1807,27 @@ s.close()
}
@test "sql-server: dolt_clone procedure in empty dir" {
repoDir="$BATS_TMPDIR/dolt-repo-$$"
# make directories outside of the dolt repo
repo1=$(mktemp -d)
cd $repo1
# init and populate repo 1
dolt init
mkdir rem1
cd repo1
dolt sql -q "CREATE TABLE test (pk INT PRIMARY KEY);"
dolt sql -q "INSERT INTO test VALUES (1), (2), (3);"
dolt sql -q "CREATE PROCEDURE test() SELECT 42;"
dolt add -A
dolt commit -m "initial commit"
dolt remote add remote1 file://../rem1
dolt push remote1 main
# verify data
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq 0 ]
[[ "$output" =~ "1" ]] || false
[[ "$output" =~ "2" ]] || false
[[ "$output" =~ "3" ]] || false
# verify procedure
run dolt sql -q "call test()"
[ "$status" -eq 0 ]
[[ "$output" =~ "42" ]] || false
# make repo 2 directory outside of the dolt repo
repo2=$(mktemp -d)
cd $repo2
# Clone repo 1 into repo 2
run dolt sql -q "call dolt_clone('file://$repo1/.dolt/noms', 'repo1');"
[ "$status" -eq 0 ]
cd ..
dolt sql -q "call dolt_clone('file://./rem1', 'repo3');"
cd repo3
# verify databases
run dolt sql -q "show databases;"
[ "$status" -eq 0 ]
[[ "$output" =~ "repo1" ]] || false
[[ "$output" =~ "repo3" ]] || false
run dolt sql -q "select database();"
[[ "$output" =~ "repo1" ]] || false
[[ "$output" =~ "repo3" ]] || false
# verify data
run dolt sql -q "SELECT * FROM test"

View File

@@ -435,6 +435,7 @@ SQL
}
@test "status: roots runs even if status fails" {
skip "todo: fix roots with chunk journal"
mv .dolt/repo_state.json .dolt/repo_state.backup
run dolt status