Skip to content

Commit f770a5e

Browse files
authored
Merge pull request #2272 from dolthub/zachmu/merge-bug2
Correctly support foreign key constraint violation checks during merge
2 parents 47ac3a6 + cbafedf commit f770a5e

6 files changed

Lines changed: 915 additions & 5 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/PuerkitoBio/goquery v1.8.1
77
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
88
github.com/cockroachdb/errors v1.7.5
9-
github.com/dolthub/dolt/go v0.40.5-0.20260205001014-db7263eb669c
9+
github.com/dolthub/dolt/go v0.40.5-0.20260205190625-38d74885c6f4
1010
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca
1111
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
1212
github.com/dolthub/go-mysql-server v0.20.1-0.20260204193159-86990113e4cc

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:I
228228
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
229229
github.com/dolthub/dolt-mcp v0.2.2 h1:bpROmam74n95uU4EA3BpOIVlTDT0pzeFMBwe/YRq2mI=
230230
github.com/dolthub/dolt-mcp v0.2.2/go.mod h1:S++DJ4QWTAXq+0TNzFa7Oq3IhoT456DJHwAINFAHgDQ=
231-
github.com/dolthub/dolt/go v0.40.5-0.20260205001014-db7263eb669c h1:lrTKtYUO5T5ka0/rgOx9TnSIFuzUv6R86wx7cRDVuUU=
232-
github.com/dolthub/dolt/go v0.40.5-0.20260205001014-db7263eb669c/go.mod h1:GTxR5JEXqpGgYHQc6nBnu/m+TgEC/LP9IPB+b3tIrvc=
231+
github.com/dolthub/dolt/go v0.40.5-0.20260205190625-38d74885c6f4 h1:RiRxt09K8viSZwl4f72KTLZQ228y59tPgdPJXSKvNnA=
232+
github.com/dolthub/dolt/go v0.40.5-0.20260205190625-38d74885c6f4/go.mod h1:GTxR5JEXqpGgYHQc6nBnu/m+TgEC/LP9IPB+b3tIrvc=
233233
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca h1:BGFz/0OlKIuC6qHIZQbvPapFvdAJkeEyGXWVgL5clmE=
234234
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca/go.mod h1:CoDLfgPqHyBtth0Cp+fi/CmC4R81zJNX4wPjShdZ+Bw=
235235
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=

server/hook/delete_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
// BeforeTableDeletion performs all validation necessary to ensure that table deletion does not leave the database in an
3232
// invalid state.
33-
func BeforeTableDeletion(ctx *sql.Context, runner sql.StatementRunner, nodeInterface sql.Node) (sql.Node, error) {
33+
func BeforeTableDeletion(ctx *sql.Context, _ sql.StatementRunner, nodeInterface sql.Node) (sql.Node, error) {
3434
n, ok := nodeInterface.(*plan.DropTable)
3535
if !ok {
3636
return nil, errors.Newf("DROP TABLE pre-hook expected `*plan.DropTable` but received `%T`", nodeInterface)

server/types/type.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
"github.com/cockroachdb/errors"
27+
"github.com/dolthub/dolt/go/store/val"
2728
"github.com/dolthub/go-mysql-server/sql"
2829
"github.com/dolthub/go-mysql-server/sql/types"
2930
"github.com/dolthub/vitess/go/sqltypes"
@@ -93,6 +94,7 @@ var _ sql.ExtendedType = &DoltgresType{}
9394
var _ sql.NullType = &DoltgresType{}
9495
var _ sql.StringType = &DoltgresType{}
9596
var _ sql.NumberType = &DoltgresType{}
97+
var _ val.TupleTypeHandler = &DoltgresType{}
9698

9799
// NewUnresolvedDoltgresType returns a DoltgresType that is not resolved.
98100
// The type will have the schema and name defined with given values, with IsUnresolved == true.
@@ -1045,6 +1047,32 @@ func (t *DoltgresType) DeserializeValue(ctx context.Context, val []byte) (any, e
10451047
}
10461048
}
10471049

1050+
// SerializationCompatible implements the val.TupleTypeHandler interface.
1051+
func (t *DoltgresType) SerializationCompatible(other val.TupleTypeHandler) bool {
1052+
ot, ok := other.(*DoltgresType)
1053+
return ok && t.Equals(ot)
1054+
}
1055+
1056+
// ConvertSerialized implements the val.TupleTypeHandler interface.
1057+
func (t *DoltgresType) ConvertSerialized(ctx context.Context, other val.TupleTypeHandler, val []byte) ([]byte, error) {
1058+
ot, ok := other.(*DoltgresType)
1059+
if !ok {
1060+
return nil, errors.Errorf("expected DoltgresType, got %T", other)
1061+
}
1062+
1063+
value, err := ot.DeserializeValue(ctx, val)
1064+
if err != nil {
1065+
return nil, err
1066+
}
1067+
1068+
toValue, _, err := t.ConvertToType(nil, ot, value)
1069+
if err != nil {
1070+
return nil, err
1071+
}
1072+
1073+
return t.SerializeValue(ctx, toValue)
1074+
}
1075+
10481076
// TypeCastFunction is a function that takes a value of a particular kind of type, and returns it as another kind of type.
10491077
// The targetType given should match the "To" type used to obtain the cast.
10501078
type TypeCastFunction func(ctx *sql.Context, val any, targetType *DoltgresType) (any, error)

servercfg/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"github.com/dolthub/go-mysql-server/sql"
2222
"gopkg.in/yaml.v2"
2323

24+
"github.com/dolthub/doltgresql/server/hook"
25+
2426
pgsql "github.com/dolthub/doltgresql/postgres/parser/parser/sql"
2527
"github.com/dolthub/doltgresql/server/analyzer"
2628
"github.com/dolthub/doltgresql/server/expression"
27-
"github.com/dolthub/doltgresql/server/hook"
2829
"github.com/dolthub/doltgresql/servercfg/cfgdetails"
2930
)
3031

0 commit comments

Comments
 (0)