// corColInAccess checks whether there's correlated column in access conditions.
2564
func (b *executorBuilder) corColInAccess(p plannercore.PhysicalPlan) bool {
	var access []expression.Expression
	switch x := p.(type) {
	case *plannercore.PhysicalTableScan:
		access = x.AccessCondition
	case *plannercore.PhysicalIndexScan:
		access = x.AccessCondition
	}
	for _, cond := range access {
		if len(expression.ExtractCorColumns(cond)) > 0 {
			return true
		}
	}
	return false
}
755338
func checkCellInArea(cell, area string) (bool, error) {
	col, row, err := CellNameToCoordinates(cell)
	if err != nil {
		return false, err
	}

	rng := strings.Split(area, ":")
	if len(rng) != 2 {
		return false, err
	}

	firstCol, firstRow, _ := CellNameToCoordinates(rng[0])
	lastCol, lastRow, _ := CellNameToCoordinates(rng[1])

	return col >= firstCol && col <= lastCol && row >= firstRow && row <= lastRow, err
}
337682
func (arb *Arbiter) applyCachedImpulse(dt_coef vect.Float) {
	if arb.state == arbiterStateFirstColl && arb.NumContacts > 0 {
		return
	}
	//println("asd")
	a := arb.ShapeA.Body
	b := arb.ShapeB.Body
	var j vect.Vect

	for _, con := range arb.Contacts {
		//transform.RotateVect(con.n, transform.Rotation{con.jnAcc, con.jtAcc})
		j.X = ((con.n.X * con.jnAcc) - (con.n.Y * con.jtAcc)) * dt_coef
		j.Y = ((con.n.X * con.jtAcc) + (con.n.Y * con.jnAcc)) * dt_coef

		//apply_impulses(a, b, con.r1, con.r2, vect.Mult(j, dt_coef))
		a.v.X = (-j.X * a.m_inv) + a.v.X
		a.v.Y = (-j.Y * a.m_inv) + a.v.Y
		a.w += a.i_inv * ((con.r1.X * -j.Y) - (con.r1.Y * -j.X))

		b.v.X = (j.X * b.m_inv) + b.v.X
		b.v.Y = (j.Y * b.m_inv) + b.v.Y

		b.w += b.i_inv * ((con.r2.X * j.Y) - (con.r2.Y * j.X))
	}
}
755379
func builtinCoalesce(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
	for _, d = range args {
		if !d.IsNull() {
			return d, nil
		}
	}
	return d, nil
}
727591
func (c *CORS) isOriginAllowed(origin string) (allowed bool) {
	for _, allowedOriginPattern := range c.allowOriginPatterns {
		allowed, _ = regexp.MatchString(allowedOriginPattern, origin)
		if allowed {
			return
		}
	}
	return
}
626754
func (d *decoder) coerce(query string, target reflect.Kind, field reflect.Value) error {
	var err error
	var c interface{}

	switch target {
	case reflect.String:
		field.SetString(query)
	case reflect.Bool:
		c, err = strconv.ParseBool(query)
		if err == nil {
			field.SetBool(c.(bool))
		}
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		c, err = strconv.ParseInt(query, 10, 64)
		if err == nil {
			field.SetInt(c.(int64))
		}
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		c, err = strconv.ParseUint(query, 10, 64)
		if err == nil {
			field.SetUint(c.(uint64))
		}
	case reflect.Float32, reflect.Float64:
		c, err = strconv.ParseFloat(query, 64)
		if err == nil {
			field.SetFloat(c.(float64))
		}
	case reflect.Struct:
		// unescape the query parameter before attempting to parse it
		query, err = url.QueryUnescape(query)
		if err != nil {
			return err
		}

		switch field.Interface().(type) {
		case time.Time:
			var t time.Time
			t, err = time.Parse(time.RFC3339, query)
			if err == nil {
				field.Set(reflect.ValueOf(t))
			}
		case ComparativeTime:
			t := *NewComparativeTime()
			err = t.Parse(query)
			if err == nil {
				field.Set(reflect.ValueOf(t))
			}
		default:
			d.value(field)
		}
	}

	return err
}
812686
func isColEqCorColOrConstant(filter expression.Expression, col *expression.Column) bool {
	f, ok := filter.(*expression.ScalarFunction)
	if !ok || f.FuncName.L != ast.EQ {
		return false
	}
	if c, ok := f.GetArgs()[0].(*expression.Column); ok {
		if _, ok := f.GetArgs()[1].(*expression.Constant); ok {
			if col.Equal(nil, c) {
				return true
			}
		}
		if _, ok := f.GetArgs()[1].(*expression.CorrelatedColumn); ok {
			if col.Equal(nil, c) {
				return true
			}
		}
	}
	if c, ok := f.GetArgs()[1].(*expression.Column); ok {
		if _, ok := f.GetArgs()[0].(*expression.Constant); ok {
			if col.Equal(nil, c) {
				return true
			}
		}
		if _, ok := f.GetArgs()[0].(*expression.CorrelatedColumn); ok {
			if col.Equal(nil, c) {
				return true
			}
		}
	}
	return false
}
1073421
func isCacheExcludeDirective(s string) bool {
	for _, directive := range cacheExcludeDirectives {
		if s == directive {
			return true
		}
	}
	return false
}
1041849
func checkCacheDisksSliceConsistency(formats []*formatCacheV1) error {
	var sentinelDisks []string
	// Extract first valid Disks slice.
	for _, format := range formats {
		if format == nil {
			continue
		}
		sentinelDisks = format.Cache.Disks
		break
	}
	for _, format := range formats {
		if format == nil {
			continue
		}
		currentDisks := format.Cache.Disks
		if !reflect.DeepEqual(sentinelDisks, currentDisks) {
			return errors.New("inconsistent cache drives found")
		}
	}
	return nil
}
1196991
func DefaultCORSConfig() cors.Config {
	CORSConfig := cors.DefaultConfig()
	CORSConfig.AllowCredentials = true
	CORSConfig.AllowAllOrigins = true
	CORSConfig.AllowHeaders = []string{"*"}
	CORSConfig.AllowMethods = []string{"GET", "PUT", "POST", "DELETE", "OPTIONS"}
	return CORSConfig
}
672564
func (s *Serf) GetCachedCoordinate(name string) (coord *coordinate.Coordinate, ok bool) {
	if !s.config.DisableCoordinates {
		s.coordCacheLock.RLock()
		defer s.coordCacheLock.RUnlock()
		if coord, ok = s.coordCache[name]; ok {
			return coord, true
		}

		return nil, false
	}

	return nil, false
}
1047650
func (session *Session) Incr(column string, arg ...interface{}) *Session {
	session.Statement.Incr(column, arg...)
	return session
}
309896
func doSetAccess(targetURL string, targetPERMS accessPerms) *probe.Error {
	clnt, err := newClient(targetURL)
	if err != nil {
		return err.Trace(targetURL)
	}
	policy := accessPermToString(targetPERMS)
	if err = clnt.SetAccess(policy, false); err != nil {
		return err.Trace(targetURL, string(targetPERMS))
	}
	return nil
}
356120
func (t Term) CoerceTo(args ...interface{}) Term {
	return constructMethodTerm(t, "CoerceTo", p.Term_COERCE_TO, args, map[string]interface{}{})
}
1099013
func (p *PhysicalApply) SetCorrelated() {
	corColumns := p.GetChildren()[1].extractCorrelatedCols()
	p.correlated = p.GetChildren()[0].IsCorrelated()
	for _, corCol := range corColumns {
		if idx := p.GetChildren()[0].GetSchema().GetColumnIndex(&corCol.Column); idx == -1 {
			p.correlated = true
			break
		}
	}
}
83934
func SkipQueryPlanCacheDirective(stmt Statement) bool {
	switch stmt := stmt.(type) {
	case *Select:
		directives := ExtractCommentDirectives(stmt.Comments)
		if directives.IsSet(DirectiveSkipQueryPlanCache) {
			return true
		}
	case *Insert:
		directives := ExtractCommentDirectives(stmt.Comments)
		if directives.IsSet(DirectiveSkipQueryPlanCache) {
			return true
		}
	case *Update:
		directives := ExtractCommentDirectives(stmt.Comments)
		if directives.IsSet(DirectiveSkipQueryPlanCache) {
			return true
		}
	case *Delete:
		directives := ExtractCommentDirectives(stmt.Comments)
		if directives.IsSet(DirectiveSkipQueryPlanCache) {
			return true
		}
	default:
		return false
	}
	return false
}
377311
func (s *UpdateUserRequest) SetConsoleAccess(v bool) *UpdateUserRequest {
	s.ConsoleAccess = &v
	return s
}