Skip to content

Commit

Permalink
fixed built in function unit tests (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
  • Loading branch information
AmoebaProtozoa authored Sep 14, 2021
1 parent 1719d28 commit 662a612
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,9 @@ func (s *testSuite5) TestShowBuiltin(c *C) {
res := tk.MustQuery("show builtins;")
c.Assert(res, NotNil)
rows := res.Rows()
c.Assert(278, Equals, len(rows))
c.Assert(281, Equals, len(rows))
c.Assert("abs", Equals, rows[0][0].(string))
c.Assert("yearweek", Equals, rows[277][0].(string))
c.Assert("yearweek", Equals, rows[280][0].(string))
}

func (s *testSuite5) TestShowClusterConfig(c *C) {
Expand Down
6 changes: 3 additions & 3 deletions expression/builtin_pg_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ type pgCurrentSchemaFunctionClass struct {
baseFunctionClass
}

func (p *pgCurrentSchemaFunctionClass)getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
func (p *pgCurrentSchemaFunctionClass) getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
if err := p.verifyArgs(args); err != nil {
return nil, err
}
Expand All @@ -509,7 +509,7 @@ type pgCurrentSchemasFunctionClass struct {
baseFunctionClass
}

func (p *pgCurrentSchemasFunctionClass)getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
func (p *pgCurrentSchemasFunctionClass) getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
if err := p.verifyArgs(args); err != nil {
return nil, err
}
Expand Down Expand Up @@ -571,7 +571,7 @@ func (b *builtinPgArrayPositionSig) evalInt(row chunk.Row) (int64, bool, error)
var res int64 = 0
strExist := strings.Contains(arrayList, array)
if strExist {
res =1
res = 1
}
return res, false, nil
}
2 changes: 1 addition & 1 deletion expression/builtin_pg_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *testEvaluatorSuite) TestCurrentSchema(c *C) {
fc := funcs[ast.PgFuncCurrentSchema]
ctx := mock.NewContext()
f, err := fc.getFunction(ctx, nil)
c.Assert(err, NotNil)
c.Assert(err, IsNil)
d, err := evalBuiltinFunc(f, chunk.Row{})
c.Assert(err, IsNil)
c.Assert(d.GetString(), Equals, "public")
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210906032539-5020c84eb0ab h1:H25pUoHH6J1OPNIZjFeHgeCsKvdpBL0iiMSMAt8SlTo=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210906032539-5020c84eb0ab/go.mod h1:3n404SkCabBM0pYRgCyXEKttOLdrmMyBaWMGvaRs/ns=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210909034839-f401b2c4f4dd h1:kYpjLNIuJSIBS7i9tSAcTaBH+/hGfN4+PnfVj1BbCL4=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210909034839-f401b2c4f4dd/go.mod h1:3n404SkCabBM0pYRgCyXEKttOLdrmMyBaWMGvaRs/ns=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210913013152-bbeff4b1e131 h1:PsGgaMEO+FUkIzheFAimGQF1xBVhKzub5Y6WarRS2es=
github.com/DigitalChinaOpenSource/DCParser v0.0.0-20210913013152-bbeff4b1e131/go.mod h1:3n404SkCabBM0pYRgCyXEKttOLdrmMyBaWMGvaRs/ns=
github.com/DigitalChinaOpenSource/dcbr v4.0.11+incompatible h1:ICQTYSnJC7i3Ns4xXGS5DMi1wTfg44woW4eWQi2ZNTQ=
Expand Down
6 changes: 3 additions & 3 deletions infoschema/pg_catalog_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const (
CatalogPgDatabase = "pg_database"
// CatalogPgDBRoleSetting is the string constant of pg_catalog table.
CatalogPgDBRoleSetting = "pg_db_role_setting"
// CatalogPgDefaultAcl is the string constant of pg_catalog table.
CatalogPgDefaultAcl = "pg_default_acl"
// CatalogPgDefaultACL is the string constant of pg_catalog table.
CatalogPgDefaultACL = "pg_default_acl"
// CatalogPgDepend is the string constant of pg_catalog table.
CatalogPgDepend = "pg_depend"
// CatalogPgDescription is the string constant of pg_catalog table.
Expand Down Expand Up @@ -127,7 +127,7 @@ var catalogTableIDMap = map[string]int64{
CatalogPgConversion: autoid.PgCatalogSchemaDBID + 12,
CatalogPgDatabase: autoid.PgCatalogSchemaDBID + 13,
CatalogPgDBRoleSetting: autoid.PgCatalogSchemaDBID + 14,
CatalogPgDefaultAcl: autoid.PgCatalogSchemaDBID + 15,
CatalogPgDefaultACL: autoid.PgCatalogSchemaDBID + 15,
CatalogPgDepend: autoid.PgCatalogSchemaDBID + 16,
CatalogPgDescription: autoid.PgCatalogSchemaDBID + 17,
CatalogPgEnum: autoid.PgCatalogSchemaDBID + 18,
Expand Down
3 changes: 1 addition & 2 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func (cc *clientConn) handleStmtBind(ctx context.Context, bind pgproto3.Bind) (e
return errors.New("the result format code parameter in the bind message is wrong")
}


stmt.SetResultFormat(bind.ResultFormatCodes)

// When create `Portal`, clients will send the portal name.
Expand Down Expand Up @@ -194,7 +193,7 @@ func (cc *clientConn) handleStmtDescription(ctx context.Context, desc pgproto3.D
}

// Get prepared stmt through stmtID.
stmt :=cc.ctx.GetStatement(int(stmtID))
stmt := cc.ctx.GetStatement(int(stmtID))
if stmt == nil {
return mysql.NewErr(mysql.ErrUnknownStmtHandler,
strconv.FormatUint(uint64(stmtID), 10), "stmt_description")
Expand Down

0 comments on commit 662a612

Please sign in to comment.