Skip to content

Commit

Permalink
fix ignore/docs tables
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hoffman committed May 20, 2024
1 parent 1bde799 commit c1f36dd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/libraries/doltcore/merge/schema_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ func makeRootWithTable(t *testing.T, ddb *doltdb.DoltDB, eo editor.Options, tbl
require.NoError(t, err)
noop := func(ctx *sql.Context, dbName string, root doltdb.RootValue) (err error) { return }
sess := writer.NewWriteSession(ddb.Format(), ws, gst, eo)
wr, err := sess.GetTableWriter(sql.NewContext(ctx), doltdb.TableName{Name: tbl.ns.name}, "test", noop)
wr, err := sess.GetTableWriter(sql.NewContext(ctx), dt, doltdb.TableName{Name: tbl.ns.name}, "test", noop)
require.NoError(t, err)

sctx := sql.NewEmptyContext()
Expand Down
3 changes: 3 additions & 0 deletions go/libraries/doltcore/sqle/dsess/table_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type WriteSession interface {
// GetTableWriter creates a TableWriter and adds it to the WriteSession.
GetTableWriter(ctx *sql.Context, t *doltdb.Table, table doltdb.TableName, db string, setter SessionRootSetter) (TableWriter, error)

// GetWorkingSet returns the session's current working set.
GetWorkingSet() *doltdb.WorkingSet

// SetWorkingSet modifies the state of the WriteSession. The WorkingSetRef of |ws| must match the existing Ref.
SetWorkingSet(ctx *sql.Context, ws *doltdb.WorkingSet) error

Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/dtables/docs_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (iw *docsWriter) StatementBegin(ctx *sql.Context) {
}

if ws := dbState.WriteSession(); ws != nil {
table, _, err := roots.Working.GetTable(ctx, doltdb.TableName{Name: doltdb.DocTableName})
table, _, err := ws.GetWorkingSet().WorkingRoot().GetTable(ctx, doltdb.TableName{Name: doltdb.IgnoreTableName})
if err != nil {
iw.errDuringStatementBegin = err
return
Expand Down
7 changes: 5 additions & 2 deletions go/libraries/doltcore/sqle/dtables/ignore_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (iw *ignoreWriter) StatementBegin(ctx *sql.Context) {
}

if ws := dbState.WriteSession(); ws != nil {
table, _, err := roots.Working.GetTable(ctx, doltdb.TableName{Name: doltdb.IgnoreTableName})
table, _, err := ws.GetWorkingSet().WorkingRoot().GetTable(ctx, doltdb.TableName{Name: doltdb.IgnoreTableName})
if err != nil {
iw.errDuringStatementBegin = err
return
Expand All @@ -300,7 +300,10 @@ func (iw *ignoreWriter) DiscardChanges(ctx *sql.Context, errorEncountered error)
// StatementComplete is called after the last operation of the statement, indicating that it has successfully completed.
// The mark set in StatementBegin may be removed, and a new one should be created on the next StatementBegin.
func (iw *ignoreWriter) StatementComplete(ctx *sql.Context) error {
return iw.tableWriter.StatementComplete(ctx)
if iw.tableWriter != nil {
return iw.tableWriter.StatementComplete(ctx)
}
return nil
}

// Close finalizes the delete operation, persisting the result.
Expand Down
4 changes: 4 additions & 0 deletions go/libraries/doltcore/sqle/writer/noms_write_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func NewWriteSession(nbf *types.NomsBinFormat, ws *doltdb.WorkingSet, aiTracker
}
}

func (s *nomsWriteSession) GetWorkingSet() *doltdb.WorkingSet {
return s.workingSet
}

func (s *nomsWriteSession) GetTableWriter(ctx *sql.Context, _ *doltdb.Table, table doltdb.TableName, db string, setter dsess.SessionRootSetter) (dsess.TableWriter, error) {
s.mut.Lock()
defer s.mut.Unlock()
Expand Down
4 changes: 4 additions & 0 deletions go/libraries/doltcore/sqle/writer/prolly_write_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type prollyWriteSession struct {

var _ dsess.WriteSession = &prollyWriteSession{}

func (s *prollyWriteSession) GetWorkingSet() *doltdb.WorkingSet {
return s.workingSet
}

// GetTableWriter implemented WriteSession.
func (s *prollyWriteSession) GetTableWriter(ctx *sql.Context, t *doltdb.Table, tableName doltdb.TableName, db string, setter dsess.SessionRootSetter) (dsess.TableWriter, error) {
s.mut.Lock()
Expand Down

0 comments on commit c1f36dd

Please sign in to comment.