// IsSelect returns true if PlanType is about a select query.
190697
func (pt PlanType) IsSelect() bool {
	return pt == PlanPassSelect || pt == PlanSelectLock || pt == PlanSelectImpossible
}
4479
func inSelectIM(p *parser) bool {
	switch p.tok.Type {
	case ErrorToken:
		// Stop parsing.
		return true
	case TextToken:
		p.addText(strings.Replace(p.tok.Data, "\x00", "", -1))
	case StartTagToken:
		switch p.tok.DataAtom {
		case a.Html:
			return inBodyIM(p)
		case a.Option:
			if p.top().DataAtom == a.Option {
				p.oe.pop()
			}
			p.addElement()
		case a.Optgroup:
			if p.top().DataAtom == a.Option {
				p.oe.pop()
			}
			if p.top().DataAtom == a.Optgroup {
				p.oe.pop()
			}
			p.addElement()
		case a.Select:
			p.tok.Type = EndTagToken
			return false
		case a.Input, a.Keygen, a.Textarea:
			if p.elementInScope(selectScope, a.Select) {
				p.parseImpliedToken(EndTagToken, a.Select, a.Select.String())
				return false
			}
			// In order to properly ignore <textarea>, we need to change the tokenizer mode.
			p.tokenizer.NextIsNotRawText()
			// Ignore the token.
			return true
		case a.Script:
			return inHeadIM(p)
		}
	case EndTagToken:
		switch p.tok.DataAtom {
		case a.Option:
			if p.top().DataAtom == a.Option {
				p.oe.pop()
			}
		case a.Optgroup:
			i := len(p.oe) - 1
			if p.oe[i].DataAtom == a.Option {
				i--
			}
			if p.oe[i].DataAtom == a.Optgroup {
				p.oe = p.oe[:i]
			}
		case a.Select:
			if p.popUntil(selectScope, a.Select) {
				p.resetInsertionMode()
			}
		}
	case CommentToken:
		p.addChild(&Node{
			Type: CommentNode,
			Data: p.tok.Data,
		})
	case DoctypeToken:
		// Ignore the token.
		return true
	}

	return true
}
482116
func (me *Dataset) isDefaultSelect() bool {
	ret := false
	if me.clauses.Select != nil {
		selects := me.clauses.Select.Columns()
		if len(selects) == 1 {
			if l, ok := selects[0].(LiteralExpression); ok && l.Literal() == "*" {
				ret = true
			}
		}
	}
	return ret
}
723432
func (this *Engine) RawSelect(fields string, table string, where string, params ...interface{}) SelectRows {
	if fields == "" {
		fields = "*"
	} else {
		fields = this.ReplaceTablePrefix(fields)
	}
	sql := `SELECT ` + fields + ` FROM ` + this.fullTableName(table) + ` WHERE ` + this.ReplaceTablePrefix(where)
	if len(params) == 1 {
		switch params[0].(type) {
		case []interface{}:
			return this.GetRows(sql, params[0].([]interface{})...)
		}
	}
	return SelectRows(this.GetRows(sql, params...))
}
766175
func (tx *Tx) Select(column ...string) *SelectStmt {
	b := Select(prepareSelect(column)...)
	b.runner = tx
	b.EventReceiver = tx.EventReceiver
	b.Dialect = tx.Dialect
	return b
}
264974
func Select(v T, indexes []int) T {
	switch v := v.(type) {
	case []int:
		res := make([]int, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res

	case []float64:
		res := make([]float64, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res

	case []string:
		res := make([]string, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res
	}

	rv := reflectSlice(v)
	res := reflect.MakeSlice(rv.Type(), len(indexes), len(indexes))
	for i, x := range indexes {
		res.Index(i).Set(rv.Index(x))
	}
	return res.Interface()
}
841865
func (m *JobExecutor) WalkSelect(p *plan.Select) (Task, error) {
	root := m.NewTask(p)
	return root, m.WalkChildren(p, root)
}
37491
func (table *TableElem) Select(selections ...Selectable) SelectStmt {
	// If additional selections were provide, use the new behavior of
	// selection - this will not add the additional selections to the
	// SelectStmt's FROM clause
	if len(selections) > 0 {
		return SelectTable(table, selections...)
	}

	// Otherwise, use the old behavior
	return Select(table)
}
1315204
func (g *Generator) isSelectorTaken(path, selector string) bool {
	for p, imp := range g.imports {
		if imp.String() == selector && p != path {
			return true
		}
	}

	return false
}
80867
func (s *Selection) HasSelection(sel *Selection) *Selection {
	if sel == nil {
		return s.HasNodes()
	}
	return s.HasNodes(sel.Nodes...)
}
980997
func (c ConfigSelector) Select(r *http.Request) (config HandlerConfig) {
	for i := range c {
		if !c[i].Match(r) {
			continue
		}
		if config == nil || len(c[i].BasePath()) > len(config.BasePath()) {
			config = c[i]
		}
	}
	return config
}
1178198
func (m *PlannerDefault) WalkSelect(p *Select) error {

	// u.Debugf("VisitSelect ctx:%p  %+v", p.Ctx, p.Stmt)

	needsFinalProject := true

	if len(p.Stmt.From) == 0 {

		return m.WalkLiteralQuery(p)

	} else if len(p.Stmt.From) == 1 {

		p.Stmt.From[0].Source = p.Stmt // TODO:   move to a Finalize() in query parser/planner

		srcPlan, err := NewSource(m.Ctx, p.Stmt.From[0], true)
		if err != nil {
			return err
		}
		p.From = append(p.From, srcPlan)
		p.Add(srcPlan)

		err = m.Planner.WalkSourceSelect(srcPlan)
		if err != nil {
			return err
		}

		if srcPlan.Complete && !needsFinalProjection(p.Stmt) {
			goto finalProjection
		}

	} else {

		var prevSource *Source
		var prevTask Task

		for i, from := range p.Stmt.From {

			// Need to rewrite the From statement to ensure all fields necessary to support
			//  joins, wheres, etc exist but is standalone query
			from.Rewrite(p.Stmt)
			srcPlan, err := NewSource(m.Ctx, from, false)
			if err != nil {
				return nil
			}
			err = m.Planner.WalkSourceSelect(srcPlan)
			if err != nil {
				u.Errorf("Could not visitsubselect %v  %s", err, from)
				return err
			}

			// now fold into previous task
			if i != 0 {
				from.Seekable = true
				// fold this source into previous
				curMergeTask := NewJoinMerge(prevTask, srcPlan, prevSource.Stmt, srcPlan.Stmt)
				prevTask = curMergeTask
			} else {
				prevTask = srcPlan
			}
			prevSource = srcPlan
			//u.Debugf("got task: %T", lastSource)
		}
		p.Add(prevTask)

	}

	if p.Stmt.Where != nil {
		switch {
		case p.Stmt.Where.Source != nil:
			// SELECT id from article WHERE id in (select article_id from comments where comment_ct > 50);
			u.Warnf("Found un-supported subquery: %#v", p.Stmt.Where)
			return ErrNotImplemented
		case p.Stmt.Where.Expr != nil:
			p.Add(NewWhere(p.Stmt))
		default:
			u.Warnf("Found un-supported where type: %#v", p.Stmt.Where)
			return fmt.Errorf("Unsupported Where Type")
		}
	}

	if p.Stmt.IsAggQuery() {
		//u.Debugf("Adding aggregate/group by? %#v", m.Planner)
		p.Add(NewGroupBy(p.Stmt))
		needsFinalProject = false
	}

	if p.Stmt.Having != nil {
		p.Add(NewHaving(p.Stmt))
	}

	if len(p.Stmt.OrderBy) > 0 {
		p.Add(NewOrder(p.Stmt))
	}

	if needsFinalProject {
		err := m.WalkProjectionFinal(p)
		if err != nil {
			return err
		}
	}

finalProjection:
	if m.Ctx.Projection == nil {
		proj, err := NewProjectionFinal(m.Ctx, p)
		//u.Infof("Projection:  %T:%p   %T:%p", proj, proj, proj.Proj, proj.Proj)
		if err != nil {
			u.Errorf("projection error? %v", err)
			return err
		}
		m.Ctx.Projection = proj
		//u.Debugf("m.Ctx: %p m.Ctx.Projection:    %T:%p", m.Ctx, m.Ctx.Projection, m.Ctx.Projection)
	}

	return nil
}
878037
func hasDescendantSelector(a Selector) Selector {
	return func(n *html.Node) bool {
		if n.Type != html.ElementNode {
			return false
		}
		return hasDescendantMatch(n, a)
	}
}
1342186
func (m *Parser) parseSelect(comment string) (*Ast, error) {

	selStmt := SelectStmt{}
	ast := Ast{Comments: comment, Select: &selStmt}

	// we have already parsed SELECT lex.Token to get here, so this should be first col
	m.curToken = m.l.NextToken()
	if m.curToken.T != lex.TokenStar {
		if err := m.parseColumns(&selStmt); err != nil {
			return nil, err
		}
	} else {
		// * mark as star?
		return nil, fmt.Errorf("not implemented")
	}

	// FROM - required
	if m.curToken.T != lex.TokenFrom {
		return nil, fmt.Errorf("expected From")
	}

	// table/metric
	m.curToken = m.l.NextToken()
	if m.curToken.T != lex.TokenIdentity && m.curToken.T != lex.TokenValue {
		return nil, fmt.Errorf("expected from name fot %v", m.curToken)
	} else if m.curToken.T == lex.TokenRegex {
		selStmt.From = &From{Value: m.curToken.V, Regex: true}
	}

	// Where is optional
	if err := m.parseWhere(&selStmt); err != nil {
		return nil, err
	}
	// limit is optional
	// if err := m.parseLimit(&selStmt); err != nil {
	// 	return nil, err
	// }

	// we are finished, nice!
	return &ast, nil
}
424260
func (db *baseDB) Select(model interface{}) error {
	return orm.Select(db.db, model)
}
276554
func (l VirtualDeviceList) Select(f func(device types.BaseVirtualDevice) bool) VirtualDeviceList {
	var found VirtualDeviceList

	for _, device := range l {
		if f(device) {
			found = append(found, device)
		}
	}

	return found
}
1079687
func (s *QueryInput) SetSelect(v string) *QueryInput {
	s.Select = &v
	return s
}