Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
daviszhen committed Dec 18, 2024
1 parent 8debb2a commit 44c925c
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions pkg/frontend/mysql_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/config"
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/bytejson"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/defines"
Expand Down Expand Up @@ -2875,3 +2876,80 @@ func (fp *testMysqlWriter) Flush() error {
func (fp *testMysqlWriter) MakeColumnDefData(ctx context.Context, columns []*planPb.ColDef) ([][]byte, error) {
return nil, nil
}

func newMrsForBinary() *MysqlResultSet {
mrs := &MysqlResultSet{}

col1 := &MysqlColumn{}
col1.SetName("a")
col1.SetColumnType(defines.MYSQL_TYPE_VARCHAR)

col2 := &MysqlColumn{}
col2.SetName("b")
col2.SetColumnType(defines.MYSQL_TYPE_STRING)

col3 := &MysqlColumn{}
col3.SetName("c")
col3.SetColumnType(defines.MYSQL_TYPE_JSON)

mrs.AddColumn(col1)
mrs.AddColumn(col2)
mrs.AddColumn(col3)

c3, _ := bytejson.CreateByteJSON("c1")

rows := [][]any{
{"a1", []byte("b1"), c3},
}

for _, row := range rows {
mrs.AddRow(row)
}

return mrs
}

func Test_appendResultSetBinaryRow(t *testing.T) {
ctx := context.TODO()
convey.Convey("append result set binary row", t, func() {
sv, err := getSystemVariables("test/system_vars_config.toml")
if err != nil {
t.Error(err)
}
pu := config.NewParameterUnit(sv, nil, nil, nil)
pu.SV.SkipCheckUser = true
pu.SV.KillRountinesInterval = 0
setSessionAlloc("", NewLeakCheckAllocator())
setPu("", pu)
ioses, err := NewIOSession(&testConn{}, pu, "")
convey.ShouldBeNil(err)
proto := NewMysqlClientProtocol("", 0, ioses, 1024, sv)

ses := NewSession(ctx, "", proto, nil)
proto.ses = ses

err = proto.appendResultSetBinaryRow(newMrsForBinary(), 0)
convey.So(err, convey.ShouldBeNil)
})

convey.Convey("append result set text row", t, func() {
sv, err := getSystemVariables("test/system_vars_config.toml")
if err != nil {
t.Error(err)
}
pu := config.NewParameterUnit(sv, nil, nil, nil)
pu.SV.SkipCheckUser = true
pu.SV.KillRountinesInterval = 0
setSessionAlloc("", NewLeakCheckAllocator())
setPu("", pu)
ioses, err := NewIOSession(&testConn{}, pu, "")
convey.ShouldBeNil(err)
proto := NewMysqlClientProtocol("", 0, ioses, 1024, sv)

ses := NewSession(ctx, "", proto, nil)
proto.ses = ses

err = proto.appendResultSetTextRow(newMrsForBinary(), 0)
convey.So(err, convey.ShouldBeNil)
})
}

0 comments on commit 44c925c

Please sign in to comment.