// PgExtensionByExtname retrieves a row from 'pg_catalog.pg_extension' as a PgExtension.
//
// Generated from index 'pg_extension_name_index'.
17439
func PgExtensionByExtname(db XODB, extname pgtypes.Name) (*PgExtension, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, extname, extowner, extnamespace, extrelocatable, extversion, extconfig, extcondition ` +
		`FROM pg_catalog.pg_extension ` +
		`WHERE extname = $1`

	// run query
	XOLog(sqlstr, extname)
	pe := PgExtension{}

	err = db.QueryRow(sqlstr, extname).Scan(&pe.Tableoid, &pe.Cmax, &pe.Xmax, &pe.Cmin, &pe.Xmin, &pe.Oid, &pe.Ctid, &pe.Extname, &pe.Extowner, &pe.Extnamespace, &pe.Extrelocatable, &pe.Extversion, &pe.Extconfig, &pe.Extcondition)
	if err != nil {
		return nil, err
	}

	return &pe, nil
}
756318
func PgAttributeByAttrelidAttname(db XODB, attrelid pgtypes.Oid, attname pgtypes.Name) (*PgAttribute, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, ctid, attrelid, attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions ` +
		`FROM pg_catalog.pg_attribute ` +
		`WHERE attrelid = $1 AND attname = $2`

	// run query
	XOLog(sqlstr, attrelid, attname)
	pa := PgAttribute{}

	err = db.QueryRow(sqlstr, attrelid, attname).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Ctid, &pa.Attrelid, &pa.Attname, &pa.Atttypid, &pa.Attstattarget, &pa.Attlen, &pa.Attnum, &pa.Attndims, &pa.Attcacheoff, &pa.Atttypmod, &pa.Attbyval, &pa.Attstorage, &pa.Attalign, &pa.Attnotnull, &pa.Atthasdef, &pa.Attisdropped, &pa.Attislocal, &pa.Attinhcount, &pa.Attcollation, &pa.Attacl, &pa.Attoptions, &pa.Attfdwoptions)
	if err != nil {
		return nil, err
	}

	return &pa, nil
}
1056249
func ExtractIndexName(opts ...interface{}) *opt.IndexNameOption {
	for _, o := range opts {
		if v, ok := o.(*opt.IndexNameOption); ok {
			return v
		}
	}
	return nil
}
1053546
func (s *DescribeThingGroupOutput) SetIndexName(v string) *DescribeThingGroupOutput {
	s.IndexName = &v
	return s
}
756437
func (*Zip) CheckExt(filename string) error {
	if !strings.HasSuffix(filename, ".zip") {
		return fmt.Errorf("filename must have a .zip extension")
	}
	return nil
}
873673
func ContentTypeByExtension(name string) (t string) {
	if t = mime.TypeByExtension(filepath.Ext(name)); len(t) == 0 {
		t = MIMEOctetStream
	}
	return
}
410178
func (s *DescribeIndexInput) SetIndexName(v string) *DescribeIndexInput {
	s.IndexName = &v
	return s
}
1143887
func PgLanguageByLanname(db XODB, lanname pgtypes.Name) (*PgLanguage, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, lanname, lanowner, lanispl, lanpltrusted, lanplcallfoid, laninline, lanvalidator, lanacl ` +
		`FROM pg_catalog.pg_language ` +
		`WHERE lanname = $1`

	// run query
	XOLog(sqlstr, lanname)
	pl := PgLanguage{}

	err = db.QueryRow(sqlstr, lanname).Scan(&pl.Tableoid, &pl.Cmax, &pl.Xmax, &pl.Cmin, &pl.Xmin, &pl.Oid, &pl.Ctid, &pl.Lanname, &pl.Lanowner, &pl.Lanispl, &pl.Lanpltrusted, &pl.Lanplcallfoid, &pl.Laninline, &pl.Lanvalidator, &pl.Lanacl)
	if err != nil {
		return nil, err
	}

	return &pl, nil
}
149854
func PgConstraintsByConnameConnamespace(db XODB, conname pgtypes.Name, connamespace pgtypes.Oid) ([]*PgConstraint, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc ` +
		`FROM pg_catalog.pg_constraint ` +
		`WHERE conname = $1 AND connamespace = $2`

	// run query
	XOLog(sqlstr, conname, connamespace)
	q, err := db.Query(sqlstr, conname, connamespace)
	if err != nil {
		return nil, err
	}
	defer q.Close()

	// load results
	res := []*PgConstraint{}
	for q.Next() {
		pc := PgConstraint{}

		// scan
		err = q.Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Contype, &pc.Condeferrable, &pc.Condeferred, &pc.Convalidated, &pc.Conrelid, &pc.Contypid, &pc.Conindid, &pc.Confrelid, &pc.Confupdtype, &pc.Confdeltype, &pc.Confmatchtype, &pc.Conislocal, &pc.Coninhcount, &pc.Connoinherit, &pc.Conkey, &pc.Confkey, &pc.Conpfeqop, &pc.Conppeqop, &pc.Conffeqop, &pc.Conexclop, &pc.Conbin, &pc.Consrc)
		if err != nil {
			return nil, err
		}

		res = append(res, &pc)
	}

	return res, nil
}
844560
func (e *ExtensionDescriptor) TypeName() (s []string) {
	name := e.GetName()
	if e.parent == nil {
		// top-level extension
		s = make([]string, 1)
	} else {
		pname := e.parent.TypeName()
		s = make([]string, len(pname)+1)
		copy(s, pname)
	}
	s[len(s)-1] = name
	return s
}
1331379
func DeleteExtension(tx Tx, id string) error {
	e := tx.get(tableExtension, id)
	if e == nil {
		return ErrNotExist
	}

	resources, err := FindResources(tx, ByKind(e.(extensionEntry).Annotations.Name))
	if err != nil {
		return err
	}

	if len(resources) != 0 {
		return errors.New("cannot delete extension because objects of this type exist in the data store")
	}

	return tx.delete(tableExtension, id)
}
1231376
func (a *ArgType) BuildIndexFuncName(ixTpl *Index) {
	// build func name
	funcName := ixTpl.Type.Name
	if !ixTpl.Index.IsUnique {
		funcName = inflector.Pluralize(ixTpl.Type.Name)
	}
	funcName = funcName + "By"

	// add param names
	paramNames := []string{}

	ixName := fmtIndexName(ixTpl.Index.IndexName, ixTpl.Type.Table.TableName)
	if a.UseIndexNames && ixName != "" {
		paramNames = append(paramNames, ixName)
	} else {
		for _, f := range ixTpl.Fields {
			paramNames = append(paramNames, f.Name)
		}
	}

	// store resulting name back
	ixTpl.FuncName = funcName + strings.Join(paramNames, "")
}
228531
func extendable(p interface{}) (extendableProto, error) {
	switch p := p.(type) {
	case extendableProto:
		if isNilPtr(p) {
			return nil, fmt.Errorf("proto: nil %T is not extendable", p)
		}
		return p, nil
	case extendableProtoV1:
		if isNilPtr(p) {
			return nil, fmt.Errorf("proto: nil %T is not extendable", p)
		}
		return extensionAdapter{p}, nil
	}
	// Don't allocate a specific error containing %T:
	// this is the hot path for Clone and MarshalText.
	return nil, errNotExtendable
}
626183
func (p *textParser) consumeExtName() (string, error) {
	tok := p.next()
	if tok.err != nil {
		return "", tok.err
	}

	// If extension name or type url is quoted, it's a single token.
	if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] {
		name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0]))
		if err != nil {
			return "", err
		}
		return name, p.consumeToken("]")
	}

	// Consume everything up to "]"
	var parts []string
	for tok.value != "]" {
		parts = append(parts, tok.value)
		tok = p.next()
		if tok.err != nil {
			return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
		}
		if p.done && tok.value != "]" {
			return "", p.errorf("unclosed type_url or extension name")
		}
	}
	return strings.Join(parts, ""), nil
}
120787
func (s *ReplicaGlobalSecondaryIndexSettingsUpdate) SetIndexName(v string) *ReplicaGlobalSecondaryIndexSettingsUpdate {
	s.IndexName = &v
	return s
}
553846
func PgTsTemplateByTmplnameTmplnamespace(db XODB, tmplname pgtypes.Name, tmplnamespace pgtypes.Oid) (*PgTsTemplate, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, tmplname, tmplnamespace, tmplinit, tmpllexize ` +
		`FROM pg_catalog.pg_ts_template ` +
		`WHERE tmplname = $1 AND tmplnamespace = $2`

	// run query
	XOLog(sqlstr, tmplname, tmplnamespace)
	ptt := PgTsTemplate{}

	err = db.QueryRow(sqlstr, tmplname, tmplnamespace).Scan(&ptt.Tableoid, &ptt.Cmax, &ptt.Xmax, &ptt.Cmin, &ptt.Xmin, &ptt.Oid, &ptt.Ctid, &ptt.Tmplname, &ptt.Tmplnamespace, &ptt.Tmplinit, &ptt.Tmpllexize)
	if err != nil {
		return nil, err
	}

	return &ptt, nil
}
845028
func (s *DescribeIndexOutput) SetIndexName(v string) *DescribeIndexOutput {
	s.IndexName = &v
	return s
}