mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Wrap calls to SearchSysCache and related functions using macros.
The purpose of this change is to eliminate the need for every caller of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists, GetSysCacheOid, and SearchSysCacheList to know the maximum number of allowable keys for a syscache entry (currently 4). This will make it far easier to increase the maximum number of keys in a future release should we choose to do so, and it makes the code shorter, too. Design and review by Tom Lane.
This commit is contained in:
328
src/backend/utils/cache/lsyscache.c
vendored
328
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.166 2010/01/04 02:44:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.167 2010/02/14 18:42:17 rhaas Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -49,10 +49,9 @@ get_attavgwidth_hook_type get_attavgwidth_hook = NULL;
|
||||
bool
|
||||
op_in_opfamily(Oid opno, Oid opfamily)
|
||||
{
|
||||
return SearchSysCacheExists(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily),
|
||||
0, 0);
|
||||
return SearchSysCacheExists2(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -68,10 +67,9 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
|
||||
Form_pg_amop amop_tup;
|
||||
int result;
|
||||
|
||||
tp = SearchSysCache(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
return 0;
|
||||
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
|
||||
@ -98,10 +96,9 @@ get_op_opfamily_properties(Oid opno, Oid opfamily,
|
||||
HeapTuple tp;
|
||||
Form_pg_amop amop_tup;
|
||||
|
||||
tp = SearchSysCache(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
ObjectIdGetDatum(opfamily));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "operator %u is not a member of opfamily %u",
|
||||
opno, opfamily);
|
||||
@ -127,11 +124,11 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
|
||||
Form_pg_amop amop_tup;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache(AMOPSTRATEGY,
|
||||
ObjectIdGetDatum(opfamily),
|
||||
ObjectIdGetDatum(lefttype),
|
||||
ObjectIdGetDatum(righttype),
|
||||
Int16GetDatum(strategy));
|
||||
tp = SearchSysCache4(AMOPSTRATEGY,
|
||||
ObjectIdGetDatum(opfamily),
|
||||
ObjectIdGetDatum(lefttype),
|
||||
ObjectIdGetDatum(righttype),
|
||||
Int16GetDatum(strategy));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
return InvalidOid;
|
||||
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
|
||||
@ -177,9 +174,7 @@ get_ordering_op_properties(Oid opno,
|
||||
* Search pg_amop to see if the target operator is registered as the "<"
|
||||
* or ">" operator of any btree opfamily.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
{
|
||||
@ -314,9 +309,7 @@ get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
|
||||
* Search pg_amop to see if the target operator is registered as the "="
|
||||
* operator of any btree opfamily.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
{
|
||||
@ -377,9 +370,7 @@ get_mergejoin_opfamilies(Oid opno)
|
||||
* Search pg_amop to see if the target operator is registered as the "="
|
||||
* operator of any btree opfamily.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
{
|
||||
@ -431,9 +422,7 @@ get_compatible_hash_operators(Oid opno,
|
||||
* operator of any hash opfamily. If the operator is registered in
|
||||
* multiple opfamilies, assume we can use any one.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
{
|
||||
@ -533,9 +522,7 @@ get_op_hash_functions(Oid opno,
|
||||
* operator of any hash opfamily. If the operator is registered in
|
||||
* multiple opfamilies, assume we can use any one.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
{
|
||||
@ -620,9 +607,7 @@ get_op_btree_interpretation(Oid opno, List **opfamilies, List **opstrats)
|
||||
/*
|
||||
* Find all the pg_amop entries containing the operator.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
|
||||
|
||||
/*
|
||||
* If we can't find any opfamily containing the op, perhaps it is a <>
|
||||
@ -637,9 +622,8 @@ get_op_btree_interpretation(Oid opno, List **opfamilies, List **opstrats)
|
||||
{
|
||||
op_negated = true;
|
||||
ReleaseSysCacheList(catlist);
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(op_negator),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID,
|
||||
ObjectIdGetDatum(op_negator));
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,9 +684,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
|
||||
/*
|
||||
* We search through all the pg_amop entries for opno1.
|
||||
*/
|
||||
catlist = SearchSysCacheList(AMOPOPID, 1,
|
||||
ObjectIdGetDatum(opno1),
|
||||
0, 0, 0);
|
||||
catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
|
||||
|
||||
result = false;
|
||||
for (i = 0; i < catlist->n_members; i++)
|
||||
@ -744,11 +726,11 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
|
||||
Form_pg_amproc amproc_tup;
|
||||
RegProcedure result;
|
||||
|
||||
tp = SearchSysCache(AMPROCNUM,
|
||||
ObjectIdGetDatum(opfamily),
|
||||
ObjectIdGetDatum(lefttype),
|
||||
ObjectIdGetDatum(righttype),
|
||||
Int16GetDatum(procnum));
|
||||
tp = SearchSysCache4(AMPROCNUM,
|
||||
ObjectIdGetDatum(opfamily),
|
||||
ObjectIdGetDatum(lefttype),
|
||||
ObjectIdGetDatum(righttype),
|
||||
Int16GetDatum(procnum));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
return InvalidOid;
|
||||
amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
|
||||
@ -772,10 +754,9 @@ get_attname(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
@ -845,10 +826,9 @@ get_atttype(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
@ -873,10 +853,9 @@ get_atttypmod(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
@ -906,10 +885,9 @@ get_atttypetypmod(Oid relid, AttrNumber attnum,
|
||||
HeapTuple tp;
|
||||
Form_pg_attribute att_tup;
|
||||
|
||||
tp = SearchSysCache(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
tp = SearchSysCache2(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, relid);
|
||||
@ -936,9 +914,7 @@ get_constraint_name(Oid conoid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(CONSTROID,
|
||||
ObjectIdGetDatum(conoid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
|
||||
@ -966,9 +942,7 @@ get_opclass_family(Oid opclass)
|
||||
Form_pg_opclass cla_tup;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache(CLAOID,
|
||||
ObjectIdGetDatum(opclass),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for opclass %u", opclass);
|
||||
cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
|
||||
@ -990,9 +964,7 @@ get_opclass_input_type(Oid opclass)
|
||||
Form_pg_opclass cla_tup;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache(CLAOID,
|
||||
ObjectIdGetDatum(opclass),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for opclass %u", opclass);
|
||||
cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
|
||||
@ -1015,9 +987,7 @@ get_opcode(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1042,9 +1012,7 @@ get_opname(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1070,9 +1038,7 @@ op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
|
||||
HeapTuple tp;
|
||||
Form_pg_operator optup;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
|
||||
elog(ERROR, "cache lookup failed for operator %u", opno);
|
||||
optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1095,9 +1061,7 @@ op_mergejoinable(Oid opno)
|
||||
HeapTuple tp;
|
||||
bool result = false;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1120,9 +1084,7 @@ op_hashjoinable(Oid opno)
|
||||
HeapTuple tp;
|
||||
bool result = false;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1175,9 +1137,7 @@ get_commutator(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1201,9 +1161,7 @@ get_negator(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1227,9 +1185,7 @@ get_oprrest(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1253,9 +1209,7 @@ get_oprjoin(Oid opno)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
@ -1282,9 +1236,7 @@ get_func_name(Oid funcid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
|
||||
@ -1308,9 +1260,7 @@ get_func_namespace(Oid funcid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
|
||||
@ -1334,9 +1284,7 @@ get_func_rettype(Oid funcid)
|
||||
HeapTuple tp;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1355,9 +1303,7 @@ get_func_nargs(Oid funcid)
|
||||
HeapTuple tp;
|
||||
int result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1380,9 +1326,7 @@ get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
|
||||
Form_pg_proc procstruct;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1408,9 +1352,7 @@ get_func_retset(Oid funcid)
|
||||
HeapTuple tp;
|
||||
bool result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1429,9 +1371,7 @@ func_strict(Oid funcid)
|
||||
HeapTuple tp;
|
||||
bool result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1450,9 +1390,7 @@ func_volatile(Oid funcid)
|
||||
HeapTuple tp;
|
||||
char result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1471,9 +1409,7 @@ get_func_cost(Oid funcid)
|
||||
HeapTuple tp;
|
||||
float4 result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1492,9 +1428,7 @@ get_func_rows(Oid funcid)
|
||||
HeapTuple tp;
|
||||
float4 result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
|
||||
@ -1514,10 +1448,9 @@ get_func_rows(Oid funcid)
|
||||
Oid
|
||||
get_relname_relid(const char *relname, Oid relnamespace)
|
||||
{
|
||||
return GetSysCacheOid(RELNAMENSP,
|
||||
PointerGetDatum(relname),
|
||||
ObjectIdGetDatum(relnamespace),
|
||||
0, 0);
|
||||
return GetSysCacheOid2(RELNAMENSP,
|
||||
PointerGetDatum(relname),
|
||||
ObjectIdGetDatum(relnamespace));
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
@ -1531,9 +1464,7 @@ get_relnatts(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1562,9 +1493,7 @@ get_rel_name(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1588,9 +1517,7 @@ get_rel_namespace(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1617,9 +1544,7 @@ get_rel_type_id(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1643,9 +1568,7 @@ get_rel_relkind(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1672,9 +1595,7 @@ get_rel_tablespace(Oid relid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
@ -1702,9 +1623,7 @@ get_typisdefined(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1728,9 +1647,7 @@ get_typlen(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1755,9 +1672,7 @@ get_typbyval(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1787,9 +1702,7 @@ get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
|
||||
HeapTuple tp;
|
||||
Form_pg_type typtup;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1810,9 +1723,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
|
||||
HeapTuple tp;
|
||||
Form_pg_type typtup;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1905,9 +1816,7 @@ get_type_io_data(Oid typid,
|
||||
return;
|
||||
}
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -1941,9 +1850,7 @@ get_typalign(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1963,9 +1870,7 @@ get_typstorage(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -1998,9 +1903,7 @@ get_typdefault(Oid typid)
|
||||
bool isNull;
|
||||
Node *expr;
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
type = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2091,9 +1994,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod)
|
||||
HeapTuple tup;
|
||||
Form_pg_type typTup;
|
||||
|
||||
tup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typTup = (Form_pg_type) GETSTRUCT(tup);
|
||||
@ -2178,9 +2079,7 @@ get_typtype(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2228,9 +2127,7 @@ get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
|
||||
HeapTuple tp;
|
||||
Form_pg_type typtup;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2250,9 +2147,7 @@ get_typ_typrelid(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2279,9 +2174,7 @@ get_element_type(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2310,9 +2203,7 @@ get_array_type(Oid typid)
|
||||
HeapTuple tp;
|
||||
Oid result = InvalidOid;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
|
||||
@ -2332,9 +2223,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_type pt;
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(type),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", type);
|
||||
pt = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2367,9 +2256,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_type pt;
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(type),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", type);
|
||||
pt = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2402,9 +2289,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_type pt;
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(type),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", type);
|
||||
pt = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2437,9 +2322,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_type pt;
|
||||
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(type),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", type);
|
||||
pt = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2471,9 +2354,7 @@ get_typmodin(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2498,9 +2379,7 @@ get_typmodout(Oid typid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
|
||||
@ -2543,11 +2422,10 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
|
||||
if (stawidth > 0)
|
||||
return stawidth;
|
||||
}
|
||||
tp = SearchSysCache(STATRELATTINH,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
BoolGetDatum(false),
|
||||
0);
|
||||
tp = SearchSysCache3(STATRELATTINH,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
BoolGetDatum(false));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
|
||||
@ -2626,9 +2504,7 @@ get_attstatsslot(HeapTuple statstuple,
|
||||
statarray = DatumGetArrayTypeP(val);
|
||||
|
||||
/* Need to get info about the array element type */
|
||||
typeTuple = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(atttype),
|
||||
0, 0, 0);
|
||||
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(atttype));
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "cache lookup failed for type %u", atttype);
|
||||
typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
@ -2737,9 +2613,7 @@ get_namespace_name(Oid nspid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(NAMESPACEOID,
|
||||
ObjectIdGetDatum(nspid),
|
||||
0, 0, 0);
|
||||
tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
|
||||
@ -2763,9 +2637,7 @@ get_namespace_name(Oid nspid)
|
||||
Oid
|
||||
get_roleid(const char *rolname)
|
||||
{
|
||||
return GetSysCacheOid(AUTHNAME,
|
||||
PointerGetDatum(rolname),
|
||||
0, 0, 0);
|
||||
return GetSysCacheOid1(AUTHNAME, PointerGetDatum(rolname));
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user