Skip to content

Commit 6ddfe1e

Browse files
committed
equality func for varbits
1 parent 4305371 commit 6ddfe1e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

server/functions/binary/equal.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func initBinaryEqual() {
7272
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, timestamptz_eq)
7373
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, timetz_eq)
7474
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, uuid_eq)
75+
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, varbit_eq)
7576
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, xideqint4)
7677
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, xideq)
7778
}
@@ -523,6 +524,21 @@ func record_eq_callable(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1 any,
523524
return compare.CompareRecords(ctx, framework.Operator_BinaryEqual, val1, val2)
524525
}
525526

527+
// varbit_eq represents the PostgreSQL function of the same name, taking the same parameters.
528+
var varbit_eq = framework.Function2{
529+
Name: "varbit_eq",
530+
Return: pgtypes.Bool,
531+
Parameters: [2]*pgtypes.DoltgresType{pgtypes.VarBit, pgtypes.VarBit},
532+
Strict: true,
533+
Callable: varbit_eq_callable,
534+
}
535+
536+
// varbit_eq_callable is the callable logic for the varbit_eq function.
537+
func varbit_eq_callable(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1 any, val2 any) (any, error) {
538+
res, err := pgtypes.VarBit.Compare(ctx, val1, val2)
539+
return res == 0, err
540+
}
541+
526542
// record_eq represents the PostgreSQL function of the same name, taking the same parameters.
527543
var record_eq = framework.Function2{
528544
Name: "record_eq",

0 commit comments

Comments
 (0)