Skip to content

Commit 3815061

Browse files
committed
PR feedback
1 parent 1743fe1 commit 3815061

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

server/ast/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ func nodeExpr(ctx *Context, node tree.Expr) (vitess.Expr, error) {
477477
return nil, errors.Errorf("the statement is not yet supported")
478478
case *tree.DBitArray:
479479
// We convert bitarray to string representation for engine representation purposes so that we don't have to
480-
// represent another fundamental type golang type. This means our representation in memory is more verbose.
480+
// represent another fundamental golang type. This means our representation in memory is more verbose.
481481
bitStr := tree.AsStringWithFlags(node, tree.FmtPgwireText)
482482
return vitess.InjectedExpr{
483483
Expression: pgexprs.NewUnsafeLiteral(bitStr, pgtypes.Bit),

server/functions/binary/equal.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
// initBinaryEqual registers the functions to the catalog.
3535
func initBinaryEqual() {
36+
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, biteq)
3637
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, booleq)
3738
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, bpchareq)
3839
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, byteaeq)
@@ -72,7 +73,7 @@ func initBinaryEqual() {
7273
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, timestamptz_eq)
7374
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, timetz_eq)
7475
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, uuid_eq)
75-
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, varbit_eq)
76+
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, varbiteq)
7677
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, xideqint4)
7778
framework.RegisterBinaryFunction(framework.Operator_BinaryEqual, xideq)
7879
}
@@ -524,21 +525,36 @@ func record_eq_callable(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1 any,
524525
return compare.CompareRecords(ctx, framework.Operator_BinaryEqual, val1, val2)
525526
}
526527

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",
528+
// varbiteq represents the PostgreSQL function of the same name, taking the same parameters.
529+
var varbiteq = framework.Function2{
530+
Name: "varbiteq",
530531
Return: pgtypes.Bool,
531532
Parameters: [2]*pgtypes.DoltgresType{pgtypes.VarBit, pgtypes.VarBit},
532533
Strict: true,
533534
Callable: varbit_eq_callable,
534535
}
535536

536-
// varbit_eq_callable is the callable logic for the varbit_eq function.
537+
// biteq represents the PostgreSQL function of the same name, taking the same parameters.
538+
var biteq = framework.Function2{
539+
Name: "biteq",
540+
Return: pgtypes.Bool,
541+
Parameters: [2]*pgtypes.DoltgresType{pgtypes.Bit, pgtypes.Bit},
542+
Strict: true,
543+
Callable: bit_eq_callable,
544+
}
545+
546+
// varbit_eq_callable is the callable logic for the varbiteq function.
537547
func varbit_eq_callable(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1 any, val2 any) (any, error) {
538548
res, err := pgtypes.VarBit.Compare(ctx, val1, val2)
539549
return res == 0, err
540550
}
541551

552+
// bit_eq_callable is the callable logic for the varbiteq function.
553+
func bit_eq_callable(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1 any, val2 any) (any, error) {
554+
res, err := pgtypes.Bit.Compare(ctx, val1, val2)
555+
return res == 0, err
556+
}
557+
542558
// record_eq represents the PostgreSQL function of the same name, taking the same parameters.
543559
var record_eq = framework.Function2{
544560
Name: "record_eq",

server/types/bit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var Bit = &DoltgresType{
5656
Acl: nil,
5757
Checks: nil,
5858
attTypMod: -1,
59-
CompareFunc: toFuncID("bttextcmp", toInternal("text"), toInternal("text")),
59+
CompareFunc: toFuncID("bitcmp", toInternal("bit"), toInternal("bit")),
6060
}
6161

6262
// NewBitType returns a Bit type with type modifier set

server/types/varbit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var VarBit = &DoltgresType{
5656
Acl: nil,
5757
Checks: nil,
5858
attTypMod: -1,
59-
CompareFunc: toFuncID("bttextcmp", toInternal("text"), toInternal("text")),
59+
CompareFunc: toFuncID("varbitcmp", toInternal("varbit"), toInternal("varbit")),
6060
}
6161

6262
// NewVarBitType returns a VarBit type with type modifier set

0 commit comments

Comments
 (0)