// Schema is similar to Value.Schema.
5436
func (s *String) Schema(schema interface{}) *String {
	checkSchema(&s.chain, s.value, schema)
	return s
}
545725
func ValidateSchema(schema, cfg string) []serror.SnapError {
	return cfgValidator.validateSchema(schema, cfg)
}
1232877
func ParseSchema(rawSchema string) (Schema, error) {
	return ParseSchemaWithRegistry(rawSchema, make(map[string]Schema))
}
627294
func Schema(extra environschema.Fields) (environschema.Fields, error) {
	fields := make(environschema.Fields)
	for name, field := range configSchema {
		if controller.ControllerOnlyAttribute(name) {
			return nil, errors.Errorf("config field %q clashes with controller config", name)
		}
		fields[name] = field
	}
	for name, field := range extra {
		if controller.ControllerOnlyAttribute(name) {
			return nil, errors.Errorf("config field %q clashes with controller config", name)
		}
		if _, ok := fields[name]; ok {
			return nil, errors.Errorf("config field %q clashes with global config", name)
		}
		fields[name] = field
	}
	return fields, nil
}
39291
func (s *Schema) Resolve(name string) common.Type {
	return s.Types[name]
}
483155
func (v *Value_Bytes) Check(schema *Schema) error {
	s := schema.GetBytes()
	if s.MaxLength > 0 && uint32(len(v.Bytes)) > s.MaxLength {
		return fmt.Errorf("value is too large: %d > %d", len(v.Bytes), s.MaxLength)
	}
	return nil
}
62108
func (r *Result) FieldSchemata() map[FieldKey][]*spec.Schema {
	if r.cachedFieldSchemta != nil {
		return r.cachedFieldSchemta
	}

	ret := make(map[FieldKey][]*spec.Schema, len(r.fieldSchemata))
	for _, fs := range r.fieldSchemata {
		key := NewFieldKey(fs.obj, fs.field)
		if fs.schemata.one != nil {
			ret[key] = append(ret[key], fs.schemata.one)
		} else if len(fs.schemata.multiple) > 0 {
			ret[key] = append(ret[key], fs.schemata.multiple...)
		}
	}
	r.cachedFieldSchemta = ret
	return ret
}
970302
func (s Schema) Clone() Schema {
	result := NewSchema(make([]*Column, 0, s.Len()))
	keys := make([]KeyInfo, 0, len(s.Keys))
	for _, col := range s.Columns {
		newCol := *col
		result.Append(&newCol)
	}
	for _, key := range s.Keys {
		keys = append(keys, key.Clone())
	}
	result.SetUniqueKeys(keys)
	return result
}
93646
func (p *Pollster) QuerySchema(schema *jsonschema.Schema) (interface{}, error) {
	if len(schema.Type) == 0 {
		return nil, errors.Errorf("invalid schema, no type specified")
	}
	if len(schema.Type) > 1 {
		return nil, errors.Errorf("don't know how to query for a value with multiple types")
	}
	var v interface{}
	var err error
	if schema.Type[0] == jsonschema.ObjectType {
		v, err = p.queryObjectSchema(schema)
	} else {
		v, err = p.queryOneSchema(schema)
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	return v, nil
}
1135794
func (h *Holder) Schema() []*IndexInfo {
	var a []*IndexInfo
	for _, index := range h.Indexes() {
		di := &IndexInfo{Name: index.Name()}
		for _, field := range index.Fields() {
			fi := &FieldInfo{Name: field.Name(), Options: field.Options()}
			for _, view := range field.views() {
				fi.Views = append(fi.Views, &ViewInfo{Name: view.name})
			}
			sort.Sort(viewInfoSlice(fi.Views))
			di.Fields = append(di.Fields, fi)
		}
		sort.Sort(fieldInfoSlice(di.Fields))
		a = append(a, di)
	}
	sort.Sort(indexInfoSlice(a))
	return a
}
343494
func (r *schemaValidatorType) validateSchema(schema, cfg string) []serror.SnapError {
	schemaLoader := gojsonschema.NewStringLoader(schema)
	testDoc := gojsonschema.NewStringLoader(cfg)
	result, err := gojsonschema.Validate(schemaLoader, testDoc)
	var serrors []serror.SnapError
	// Check for invalid json
	if err != nil {
		serrors = append(serrors, serror.New(err))
		return serrors
	}
	// check if result passes validation
	if result.Valid() {
		return nil
	}
	for _, err := range result.Errors() {
		serr := serror.New(errors.New("Validate schema error"))
		serr.SetFields(map[string]interface{}{
			"value":       err.Value(),
			"context":     err.Context().String("::"),
			"description": err.Description(),
		})
		serrors = append(serrors, serr)
	}
	return serrors
}
638972
func (s *Schema) Add(p Project) {
	for _, val := range s.Projects {
		if reflect.DeepEqual(val, p) {
			return
		}
	}
	s.Projects = append(s.Projects, p)
}
695991
func (l *SchemaList) Extract(v interface{}) error {
	switch val := v.(type) {
	case []interface{}:
		*l = make([]*Schema, len(val))
		var s *Schema
		for i, d := range val {
			m, ok := d.(map[string]interface{})
			if !ok {
				return errors.Wrap(
					errInvalidType("map[string]interface{}", d),
					"failed to extract schema list",
				)
			}
			if err := extractSingleSchema(&s, m); err != nil {
				return errors.Wrap(err, "failed to extract schema list")
			}
			(*l)[i] = s
		}
		return nil
	case map[string]interface{}:
		var s *Schema
		if err := extractSingleSchema(&s, val); err != nil {
			return errors.Wrap(err, "failed to extract schema list")
		}
		*l = []*Schema{s}
		return nil
	default:
		return errors.Wrap(
			errInvalidType("[]*Schema or *Schema", v),
			"failed to extract schema list",
		)
	}
}
69941
func assertRecordSchema(s Schema) *RecordSchema {
	rs, ok := s.(*RecordSchema)
	if !ok {
		rs = &s.(*preparedRecordSchema).RecordSchema
	}
	return rs
}
871556
func (m *SchemaDb) Table(table string) (*schema.Table, error) {

	switch table {
	case "tables":
		return m.tableForTables()
	case "databases":
		return m.tableForDatabases()
	case "session_variables", "global_variables":
		return m.tableForVariables(table)
	case "procedures", "functions":
		return m.tableForProcedures(table)
	case "engines":
		return m.tableForEngines()
	case "indexes", "keys":
		return m.tableForIndexes()
	case "status":
		return m.tableForVariables(table)
	case "columns":
		return m.tableForTable(table)
	default:
		return m.tableForTable(table)
	}
}
207976
func (s *physicalSchemaProducer) Schema() *expression.Schema {
	if s.schema == nil {
		s.schema = expression.NewSchema()
	}
	return s.schema
}
1235867
func (ts *TypeSchema) SwaggerSchema() (*Schema, error) {
	if ts.AllowRef && ts.RefName != "" {
		return &Schema{Ref: fmt.Sprintf("#/definitions/%s", ts.RefName)}, nil
	} else if ts.AllowRef {
		return nil, errors.New("Name is required")
	}

	return ts.Schema.ShallowCopy(), nil
}