func (parser *ParserImpl) transformTargetEntry(restarget *ResTarget) (tle *TargetEntry, err error) { tle = &TargetEntry{} err = nil tle.Expr, err = parser.transformExpr(restarget.val) /* ResName, ResNo */ tle.ResName = system.Name(restarget.name) tle.ResJunk = false return }
func (s *MySuite) TestYYParse_1(c *C) { query := " select col1, col2 FROM tab1" lexer := newLexer(query) yyParse(lexer) node, ok := TopList[0].(*SelectStmt) if !ok { c.Error("node is not SelectStmt") } c.Check(node.targetList[0].name, Equals, "col1") c.Check(node.targetList[1].name, Equals, "col2") c.Check(node.fromList[0].(*RangeVar).RelationName, Equals, system.Name("tab1")) }
func (s *MySuite) TestHeapTuple(c *C) { values := []system.Datum{ system.Int4(1), system.Oid(999990), nil, system.Name("fooname"), } tupdesc := &TupleDesc{ Attrs: []*Attribute{ { Name: "col1", TypeId: system.Int4Type, }, { Name: "col2", TypeId: system.OidType, }, { Name: "col3nil", TypeId: system.NameType, }, { Name: "col4", TypeId: system.NameType, }, }, } initTupleDesc(tupdesc) htuple := FormHeapTuple(values, tupdesc) c.Check(htuple.Fetch(1), Equals, values[0]) c.Check(htuple.Fetch(2), Equals, values[1]) c.Check(htuple.Fetch(3), Equals, values[2]) c.Check(htuple.Fetch(4), Equals, values[3]) c.Check(htuple.data.Oid(), Equals, system.InvalidOid) c.Check(htuple.data.HasNulls(), Equals, true) c.Check(htuple.data.Natts(), Equals, system.AttrNumber(4)) }