本文整理匯總了Golang中github.com/pingcap/tidb/rset/rsets.Recordset.Rows方法的典型用法代碼示例。如果您正苦於以下問題:Golang Recordset.Rows方法的具體用法?Golang Recordset.Rows怎麽用?Golang Recordset.Rows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/rset/rsets.Recordset
的用法示例。
在下文中一共展示了Recordset.Rows方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestShowCollation
func (p *testShowSuit) TestShowCollation(c *C) {
pln := &plans.ShowPlan{}
pln.Target = stmt.ShowCollation
fls := pln.GetFields()
c.Assert(fls, HasLen, 6)
c.Assert(fls[2].Col.Tp, Equals, mysql.TypeLonglong)
pln.Pattern = &expression.PatternLike{
Pattern: &expression.Value{
Val: "utf8%",
},
}
rset := rsets.Recordset{
Ctx: p.ctx,
Plan: pln,
}
rows, err := rset.Rows(-1, 0)
c.Assert(err, IsNil)
c.Assert(len(rows), Greater, 0)
pln.Close()
pln.Pattern = nil
tblWhere := []struct {
Key string
Value interface{}
}{
{"Collation", "utf8_bin"},
{"Charset", "utf8"},
{"Id", 83},
{"Default", "Yes"},
{"Compiled", "Yes"},
{"Sortlen", 1},
}
for _, w := range tblWhere {
pln.Where = &expression.BinaryOperation{
L: &expression.Ident{CIStr: model.NewCIStr(w.Key)},
R: expression.Value{Val: w.Value},
Op: opcode.EQ,
}
row, err := rset.FirstRow()
c.Assert(err, IsNil)
c.Assert(row, HasLen, 6)
pln.Close()
}
}
示例2: TestRowStackFromPlan
func (s *testOuterQuerySuite) TestRowStackFromPlan(c *C) {
var data = []*testRowData{
{1, []interface{}{10, "hello"}},
}
pln := &testTablePlan{data, []string{"id", "name"}, 0}
p := &plans.RowStackFromPlan{
Src: pln,
}
fields := p.GetFields()
c.Assert(fields, HasLen, 2)
rset := rsets.Recordset{
Plan: p,
Ctx: mock.NewContext()}
_, err := rset.Rows(-1, 0)
c.Assert(err, IsNil)
}