Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4dcdf56
debug info for missed foreign key lookups during merge
zachmu Jan 24, 2026
0636f33
Merge branch 'zachmu/merge-bug' of github.com:dolthub/dolt into zachm…
zachmu Jan 24, 2026
a655b58
Merge branch 'main' into zachmu/merge-bug
zachmu Jan 24, 2026
ea31452
first pass at converting incompatible foreign keys during merge
zachmu Jan 28, 2026
52abf34
type conversions during foreign key checks in merge
zachmu Jan 30, 2026
f5124ff
For secondary indexes on text types, use the correct schema when dete…
nicktobey Jan 29, 2026
4949096
First working conversion code
zachmu Jan 31, 2026
e62c33d
handle both kinds of adaptive encodings
zachmu Jan 31, 2026
15ee8b0
apply foreign key conversion in more places
zachmu Feb 2, 2026
a65f71a
cleanup
zachmu Feb 2, 2026
f81886d
another test
zachmu Feb 2, 2026
38bee70
bug fix: use the original key tuple, not the parent lookup key tuple,…
zachmu Feb 3, 2026
037b255
Bug fix: primary keys are not always found at the end of a secondary …
zachmu Feb 3, 2026
b70640a
rename
zachmu Feb 4, 2026
100d203
formatting
zachmu Feb 4, 2026
4598284
bug fix: secondary index prefix lookup wasn't using a prefix tuple bu…
zachmu Feb 4, 2026
e2c8d79
bug fix: correctly convert secondary to primary key lookups
zachmu Feb 4, 2026
ffd72e9
bug fix for keyless child tables
zachmu Feb 4, 2026
1eb324a
remove debug logging
zachmu Feb 4, 2026
cded20e
Merge branch 'main' into zachmu/merge-bug-2
zachmu Feb 4, 2026
831a3ce
bug fix: convert types in key for a child primary index diff
zachmu Feb 4, 2026
16d289b
Some refactoring
zachmu Feb 4, 2026
69eca82
more refactoring, bug fix
zachmu Feb 4, 2026
891dc92
remove debug logging
zachmu Feb 4, 2026
fc712b8
formatting
zachmu Feb 4, 2026
827faa1
better panic message
zachmu Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/libraries/doltcore/merge/mutable_secondary_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GetMutableSecondaryIdxsWithPending(ctx *sql.Context, ns tree.NodeStore, our
idxKeyDesc = idxKeyDesc.PrefixDesc(idxKeyDesc.Count() - 1)
}

if !idxKeyDesc.Equals(index.Schema().GetKeyDescriptorWithNoConversion(ns)) {
if !idxKeyDesc.Equals(index.Schema().GetKeyDescriptor(ns)) {
continue
}

Expand Down
25 changes: 19 additions & 6 deletions go/libraries/doltcore/merge/violations_fk.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ type FKViolationReceiver interface {
ProllyFKViolationFound(ctx context.Context, rowKey, rowValue val.Tuple) error
}

// GetForeignKeyViolations returns the violations that have been created as a
// result of the diff between |baseRoot| and |newRoot|. It sends the violations to |receiver|.
func GetForeignKeyViolations(ctx *sql.Context, tableResolver doltdb.TableResolver, newRoot, baseRoot doltdb.RootValue, tables *doltdb.TableNameSet, receiver FKViolationReceiver) error {
// RegisterForeignKeyViolations emits constraint violations that have been created as a
// result of the diff between |baseRoot| and |newRoot|. It sends violations to |receiver|.
func RegisterForeignKeyViolations(
ctx *sql.Context,
tableResolver doltdb.TableResolver,
newRoot, baseRoot doltdb.RootValue,
tables *doltdb.TableNameSet,
receiver FKViolationReceiver,
) error {
fkColl, err := newRoot.GetForeignKeyCollection(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -158,7 +164,7 @@ func GetForeignKeyViolations(ctx *sql.Context, tableResolver doltdb.TableResolve
// todo(andy): pass doltdb.Rootish
func AddForeignKeyViolations(ctx *sql.Context, tableResolver doltdb.TableResolver, newRoot, baseRoot doltdb.RootValue, tables *doltdb.TableNameSet, theirRootIsh hash.Hash) (doltdb.RootValue, *doltdb.TableNameSet, error) {
violationWriter := &foreignKeyViolationWriter{tableResolver: tableResolver, rootValue: newRoot, theirRootIsh: theirRootIsh, violatedTables: doltdb.NewTableNameSet(nil)}
err := GetForeignKeyViolations(ctx, tableResolver, newRoot, baseRoot, tables, violationWriter)
err := RegisterForeignKeyViolations(ctx, tableResolver, newRoot, baseRoot, tables, violationWriter)
if err != nil {
return nil, nil, err
}
Expand All @@ -169,7 +175,7 @@ func AddForeignKeyViolations(ctx *sql.Context, tableResolver doltdb.TableResolve
// violations based on the diff between |newRoot| and |baseRoot|.
func GetForeignKeyViolatedTables(ctx *sql.Context, tableResolver doltdb.TableResolver, newRoot, baseRoot doltdb.RootValue, tables *doltdb.TableNameSet) (*doltdb.TableNameSet, error) {
handler := &foreignKeyViolationTracker{tableSet: doltdb.NewTableNameSet(nil)}
err := GetForeignKeyViolations(ctx, tableResolver, newRoot, baseRoot, tables, handler)
err := RegisterForeignKeyViolations(ctx, tableResolver, newRoot, baseRoot, tables, handler)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -426,6 +432,7 @@ func childFkConstraintViolations(
if err != nil {
return err
}

return prollyChildSecDiffFkConstraintViolations(ctx, foreignKey, postParent, postChild, m, receiver)
}

Expand Down Expand Up @@ -689,7 +696,13 @@ func childFkConstraintViolationsProcess(

// newConstraintViolationsLoadedTable returns a *constraintViolationsLoadedTable. Returns false if the table was loaded
// but the index could not be found. If the table could not be found, then an error is returned.
func newConstraintViolationsLoadedTable(ctx *sql.Context, tableResolver doltdb.TableResolver, tblName doltdb.TableName, idxName string, root doltdb.RootValue) (*constraintViolationsLoadedTable, bool, error) {
func newConstraintViolationsLoadedTable(
ctx *sql.Context,
tableResolver doltdb.TableResolver,
tblName doltdb.TableName,
idxName string,
root doltdb.RootValue,
) (*constraintViolationsLoadedTable, bool, error) {
trueTblName, tbl, ok, err := tableResolver.ResolveTableInsensitive(ctx, root, tblName)
if err != nil {
return nil, false, err
Expand Down
Loading
Loading