// Code generated by xo. DO NOT EDIT.
// PgTruetypmod calls the stored procedure 'information_schema._pg_truetypmod(pg_attribute, pg_type) integer' on db.
18845
func PgTruetypmod(db XODB, v0 pgtypes.PgAttribute, v1 pgtypes.PgType) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT information_schema._pg_truetypmod($1, $2)`

	// run query
	var ret int
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
996101
func PgOpclassByOid(db XODB, oid pgtypes.Oid) (*PgOpclass, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, opcmethod, opcname, opcnamespace, opcowner, opcfamily, opcintype, opcdefault, opckeytype ` +
		`FROM pg_catalog.pg_opclass ` +
		`WHERE oid = $1`

	// run query
	XOLog(sqlstr, oid)
	po := PgOpclass{}

	err = db.QueryRow(sqlstr, oid).Scan(&po.Tableoid, &po.Cmax, &po.Xmax, &po.Cmin, &po.Xmin, &po.Oid, &po.Ctid, &po.Opcmethod, &po.Opcname, &po.Opcnamespace, &po.Opcowner, &po.Opcfamily, &po.Opcintype, &po.Opcdefault, &po.Opckeytype)
	if err != nil {
		return nil, err
	}

	return &po, nil
}
1204540
func PgProcs(db XODB, schema string) ([]*Proc, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`p.proname, ` + // ::varchar AS proc_name
		`pg_get_function_result(p.oid) ` + // ::varchar AS return_type
		`FROM pg_proc p ` +
		`JOIN ONLY pg_namespace n ON p.pronamespace = n.oid ` +
		`WHERE n.nspname = $1`

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

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

		// scan
		err = q.Scan(&p.ProcName, &p.ReturnType)
		if err != nil {
			return nil, err
		}

		res = append(res, &p)
	}

	return res, nil
}
26958
func PgExtensionConfigDump(db XODB, v0 pgtypes.Regclass, v1 string) error {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_extension_config_dump($1, $2)`

	// run query
	XOLog(sqlstr)
	_, err = db.Exec(sqlstr)
	return err
}
284682
func PgOptionsToTable(db XODB, v0 StringSlice) ([]pgtypes.Record, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_options_to_table($1)`

	// run query
	var ret []pgtypes.Record
	XOLog(sqlstr, v0)
	err = db.QueryRow(sqlstr, v0).Scan(&ret)
	if err != nil {
		return nil, err
	}

	return ret, nil
}
335291
func (dal *DjangoAdminLog) DjangoContentType(db XODB) (*DjangoContentType, error) {
	return DjangoContentTypeByID(db, dal.ContentTypeID.Float64)
}
837998
func PgColumnIsUpdatable(db XODB, v0 pgtypes.Regclass, v1 int16, v2 bool) (bool, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_column_is_updatable($1, $2, $3)`

	// run query
	var ret bool
	XOLog(sqlstr, v0, v1, v2)
	err = db.QueryRow(sqlstr, v0, v1, v2).Scan(&ret)
	if err != nil {
		return false, err
	}

	return ret, nil
}
970018
func GinCmpPrefix(db XODB, v0 string, v1 string, v2 int16, v3 pgtypes.Internal) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.gin_cmp_prefix($1, $2, $3, $4)`

	// run query
	var ret int
	XOLog(sqlstr, v0, v1, v2, v3)
	err = db.QueryRow(sqlstr, v0, v1, v2, v3).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
341744
func (mysqlFlavor) sendBinlogDumpCommand(c *Conn, slaveID uint32, startPos Position) error {
	gtidSet, ok := startPos.GTIDSet.(Mysql56GTIDSet)
	if !ok {
		return vterrors.Errorf(vtrpc.Code_INTERNAL, "startPos.GTIDSet is wrong type - expected Mysql56GTIDSet, got: %#v", startPos.GTIDSet)
	}

	// Build the command.
	sidBlock := gtidSet.SIDBlock()
	return c.WriteComBinlogDumpGTID(slaveID, "", 4, 0, sidBlock)
}
102205
func PgTypeByOid(db XODB, oid pgtypes.Oid) (*PgType, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, typname, typnamespace, typowner, typlen, typbyval, typtype, typcategory, typispreferred, typisdefined, typdelim, typrelid, typelem, typarray, typinput, typoutput, typreceive, typsend, typmodin, typmodout, typanalyze, typalign, typstorage, typnotnull, typbasetype, typtypmod, typndims, typcollation, typdefaultbin, typdefault, typacl ` +
		`FROM pg_catalog.pg_type ` +
		`WHERE oid = $1`

	// run query
	XOLog(sqlstr, oid)
	pt := PgType{}

	err = db.QueryRow(sqlstr, oid).Scan(&pt.Tableoid, &pt.Cmax, &pt.Xmax, &pt.Cmin, &pt.Xmin, &pt.Oid, &pt.Ctid, &pt.Typname, &pt.Typnamespace, &pt.Typowner, &pt.Typlen, &pt.Typbyval, &pt.Typtype, &pt.Typcategory, &pt.Typispreferred, &pt.Typisdefined, &pt.Typdelim, &pt.Typrelid, &pt.Typelem, &pt.Typarray, &pt.Typinput, &pt.Typoutput, &pt.Typreceive, &pt.Typsend, &pt.Typmodin, &pt.Typmodout, &pt.Typanalyze, &pt.Typalign, &pt.Typstorage, &pt.Typnotnull, &pt.Typbasetype, &pt.Typtypmod, &pt.Typndims, &pt.Typcollation, &pt.Typdefaultbin, &pt.Typdefault, &pt.Typacl)
	if err != nil {
		return nil, err
	}

	return &pt, nil
}
550880
func (p *Param) BoolTmpVarCode() string {
	const code = `var %s uint32
	if %s {
		%s = 1
	} else {
		%s = 0
	}`
	tmp := p.tmpVar()
	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
}
769199
func PgExtensionUpdatePaths(db XODB, v0 pgtypes.Name) ([]pgtypes.Record, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_extension_update_paths($1)`

	// run query
	var ret []pgtypes.Record
	XOLog(sqlstr, v0)
	err = db.QueryRow(sqlstr, v0).Scan(&ret)
	if err != nil {
		return nil, err
	}

	return ret, nil
}
221236
func Btoidvectorcmp(db XODB, v0 pgtypes.Oidvector, v1 pgtypes.Oidvector) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.btoidvectorcmp($1, $2)`

	// run query
	var ret int
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
225390
func TypeToMySQL(typ querypb.Type) (mysqlType, flags int64) {
	val := typeToMySQL[typ]
	return val.typ, val.flags
}
1114100
func CurrentDatabase(db XODB) (pgtypes.Name, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.current_database()`

	// run query
	var ret pgtypes.Name
	XOLog(sqlstr)
	err = db.QueryRow(sqlstr).Scan(&ret)
	if err != nil {
		return pgtypes.Name{}, err
	}

	return ret, nil
}
535005
func PgEventTriggerByEvtname(db XODB, evtname pgtypes.Name) (*PgEventTrigger, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, evtname, evtevent, evtowner, evtfoid, evtenabled, evttags ` +
		`FROM pg_catalog.pg_event_trigger ` +
		`WHERE evtname = $1`

	// run query
	XOLog(sqlstr, evtname)
	pet := PgEventTrigger{}

	err = db.QueryRow(sqlstr, evtname).Scan(&pet.Tableoid, &pet.Cmax, &pet.Xmax, &pet.Cmin, &pet.Xmin, &pet.Oid, &pet.Ctid, &pet.Evtname, &pet.Evtevent, &pet.Evtowner, &pet.Evtfoid, &pet.Evtenabled, &pet.Evttags)
	if err != nil {
		return nil, err
	}

	return &pet, nil
}
793324
func PgAttrdefByAdrelidAdnum(db XODB, adrelid pgtypes.Oid, adnum int16) (*PgAttrdef, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc ` +
		`FROM pg_catalog.pg_attrdef ` +
		`WHERE adrelid = $1 AND adnum = $2`

	// run query
	XOLog(sqlstr, adrelid, adnum)
	pa := PgAttrdef{}

	err = db.QueryRow(sqlstr, adrelid, adnum).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Adrelid, &pa.Adnum, &pa.Adbin, &pa.Adsrc)
	if err != nil {
		return nil, err
	}

	return &pa, nil
}