Skip to content

Commit 4b7995c

Browse files
authored
Merge branch 'main' into jennifersp-79fc4cd2
2 parents 9df2297 + f770a5e commit 4b7995c

4 files changed

Lines changed: 912 additions & 2 deletions

File tree

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)