// PgShdependsByDbidClassidObjidObjsubid retrieves a row from 'pg_catalog.pg_shdepend' as a PgShdepend.
//
// Generated from index 'pg_shdepend_depender_index'.
356025
func PgShdependsByDbidClassidObjidObjsubid(db XODB, dbid pgtypes.Oid, classid pgtypes.Oid, objid pgtypes.Oid, objsubid int) ([]*PgShdepend, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, ctid, dbid, classid, objid, objsubid, refclassid, refobjid, deptype ` +
		`FROM pg_catalog.pg_shdepend ` +
		`WHERE dbid = $1 AND classid = $2 AND objid = $3 AND objsubid = $4`

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

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

		// scan
		err = q.Scan(&ps.Tableoid, &ps.Cmax, &ps.Xmax, &ps.Cmin, &ps.Xmin, &ps.Ctid, &ps.Dbid, &ps.Classid, &ps.Objid, &ps.Objsubid, &ps.Refclassid, &ps.Refobjid, &ps.Deptype)
		if err != nil {
			return nil, err
		}

		res = append(res, &ps)
	}

	return res, nil
}
1061749
func (api *OmdbApi) MovieByImdbID(id string) (*MovieResult, error) {
	resp, err := api.requestAPI("id", id)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	r := new(MovieResult)
	err = json.NewDecoder(resp.Body).Decode(r)

	if err != nil {
		return nil, err
	}
	if r.Response == "False" {
		return r, errors.New(r.Error)
	}
	return r, nil
}
1195681
func (ods *OnDemandStorer) DeltaObject(
	ot plumbing.ObjectType, hash plumbing.Hash) (
	plumbing.EncodedObject, error) {
	edos, ok := ods.Storer.(storer.DeltaObjectStorer)
	if !ok {
		return nil, errors.New("Not a delta storer")
	}
	o := &onDemandDeltaObject{
		s:           edos,
		hash:        hash,
		objType:     ot,
		size:        -1,
		recentCache: ods.recentCache,
	}
	// Need to see if this is a delta object, which means reading all
	// the data.
	_, err := o.cache()
	_, notDelta := err.(notDeltaError)
	if notDelta {
		return ods.EncodedObject(ot, hash)
	} else if err != nil {
		return nil, err
	}
	return o, nil
}
903440
func (db *PublicRecord) GetEndosByBid(bid *wire.ShaHash) ([]*ombjson.Endorsement, error) {
	rows, err := db.selectEndosByBid.Query(bid.String())
	defer rows.Close()
	if err != nil {
		return []*ombjson.Endorsement{}, err
	}
	return scanEndos(rows)
}
689821
func (ss *SQLSubStore) AddSeqPending(subid, seqno uint64) error {
	var err error
	ss.Lock()
	if !ss.closed {
		if ss.cache != nil {
			if isFull := ss.addSeq(subid, seqno); isFull {
				err = ss.flush()
			}
		} else {
			ls := ss.subLastSent[subid]
			if seqno > ls {
				ss.subLastSent[subid] = seqno
			}
			ss.curRow++
			_, err = ss.sqlStore.preparedStmts[sqlSubAddPending].Exec(subid, ss.curRow, seqno)
			if err != nil {
				err = sqlStmtError(sqlSubAddPending, err)
			}
		}
	}
	ss.Unlock()
	return err
}
1241843
func (s *SeriesSegment) MaxSeriesID() SeriesID {
	var max SeriesID
	s.ForEachEntry(func(flag uint8, id SeriesIDTyped, _ int64, _ []byte) error {
		untypedID := id.SeriesID()
		if flag == SeriesEntryInsertFlag && untypedID.Greater(max) {
			max = untypedID
		}
		return nil
	})
	return max
}
651487
func PgPolicyByOid(db XODB, oid pgtypes.Oid) (*PgPolicy, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, polname, polrelid, polcmd, polroles, polqual, polwithcheck ` +
		`FROM pg_catalog.pg_policy ` +
		`WHERE oid = $1`

	// run query
	XOLog(sqlstr, oid)
	pp := PgPolicy{}

	err = db.QueryRow(sqlstr, oid).Scan(&pp.Tableoid, &pp.Cmax, &pp.Xmax, &pp.Cmin, &pp.Xmin, &pp.Oid, &pp.Ctid, &pp.Polname, &pp.Polrelid, &pp.Polcmd, &pp.Polroles, &pp.Polqual, &pp.Polwithcheck)
	if err != nil {
		return nil, err
	}

	return &pp, nil
}
924058
func (e *TagBlockValueElem) SeriesID(i int) uint64 {
	return binary.BigEndian.Uint64(e.series.data[i*SeriesIDSize:])
}
822368
func PgShseclabelByObjoidClassoidProvider(db XODB, objoid pgtypes.Oid, classoid pgtypes.Oid, provider string) (*PgShseclabel, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, ctid, objoid, classoid, provider, label ` +
		`FROM pg_catalog.pg_shseclabel ` +
		`WHERE objoid = $1 AND classoid = $2 AND provider = $3`

	// run query
	XOLog(sqlstr, objoid, classoid, provider)
	ps := PgShseclabel{}

	err = db.QueryRow(sqlstr, objoid, classoid, provider).Scan(&ps.Tableoid, &ps.Cmax, &ps.Xmax, &ps.Cmin, &ps.Xmin, &ps.Ctid, &ps.Objoid, &ps.Classoid, &ps.Provider, &ps.Label)
	if err != nil {
		return nil, err
	}

	return &ps, nil
}
664368
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
	if len(sigdata) < 4 {
		return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
	}
	for _, method := range abi.Methods {
		if bytes.Equal(method.Id(), sigdata[:4]) {
			return &method, nil
		}
	}
	return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
}
745599
func dbFetchBlockIDByHash(dbTx database.Tx, hash *chainhash.Hash) (uint32, error) {
	hashIndex := dbTx.Metadata().Bucket(idByHashIndexBucketName)
	serializedID := hashIndex.Get(hash[:])
	if serializedID == nil {
		return 0, errNoBlockIDEntry
	}

	return byteOrder.Uint32(serializedID), nil
}
146130
func PgForeignDataWrapperByOid(db XODB, oid pgtypes.Oid) (*PgForeignDataWrapper, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, oid, ctid, fdwname, fdwowner, fdwhandler, fdwvalidator, fdwacl, fdwoptions ` +
		`FROM pg_catalog.pg_foreign_data_wrapper ` +
		`WHERE oid = $1`

	// run query
	XOLog(sqlstr, oid)
	pfdw := PgForeignDataWrapper{}

	err = db.QueryRow(sqlstr, oid).Scan(&pfdw.Tableoid, &pfdw.Cmax, &pfdw.Xmax, &pfdw.Cmin, &pfdw.Xmin, &pfdw.Oid, &pfdw.Ctid, &pfdw.Fdwname, &pfdw.Fdwowner, &pfdw.Fdwhandler, &pfdw.Fdwvalidator, &pfdw.Fdwacl, &pfdw.Fdwoptions)
	if err != nil {
		return nil, err
	}

	return &pfdw, nil
}
337705
func dbFetchBlockHashByID(dbTx database.Tx, id uint32) (*chainhash.Hash, error) {
	var serializedID [4]byte
	byteOrder.PutUint32(serializedID[:], id)
	return dbFetchBlockHashBySerializedID(dbTx, serializedID[:])
}
978495
func (g *GPG) ListPublicKeyIDs(context.Context) ([]string, error) {
	if g.pubring == nil {
		return nil, fmt.Errorf("pubring is not initialized")
	}
	ids := listKeyIDs(g.pubring)
	if g.secring != nil {
		ids = append(ids, listKeyIDs(g.secring)...)
	}
	return ids, nil
}
682016
func (pgb *ChainDB) DbTxByHash(txid string) (*dbtypes.Tx, error) {
	ctx, cancel := context.WithTimeout(pgb.ctx, pgb.queryTimeout)
	defer cancel()
	_, dbTx, err := RetrieveDbTxByHash(ctx, pgb.db, txid)
	return dbTx, pgb.replaceCancelError(err)
}
40540
func (f *SeriesFile) SeriesID(name []byte, tags models.Tags, buf []byte) SeriesID {
	return f.SeriesIDTyped(name, tags, buf).SeriesID()
}
458747
func PgTruetypid(db XODB, v0 pgtypes.PgAttribute, v1 pgtypes.PgType) (pgtypes.Oid, error) {
	var err error

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

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

	return ret, nil
}