@@ -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{}
9394var _ sql.NullType = & DoltgresType {}
9495var _ sql.StringType = & DoltgresType {}
9596var _ 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.
10501078type TypeCastFunction func (ctx * sql.Context , val any , targetType * DoltgresType ) (any , error )
0 commit comments