diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-02-14 18:42:19 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-02-14 18:42:19 +0000 |
commit | e26c539e9f326ea843c0ed005af093b56b55cd4d (patch) | |
tree | 4f3830d394229b747cbceeab3cdbbfccccec74d1 /src/backend/utils/adt | |
parent | 1012492bc0bfb322d59db17e17735d17d634e264 (diff) | |
download | postgresql-e26c539e9f326ea843c0ed005af093b56b55cd4d.tar.gz postgresql-e26c539e9f326ea843c0ed005af093b56b55cd4d.zip |
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.
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/acl.c | 120 | ||||
-rw-r--r-- | src/backend/utils/adt/dbsize.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/enum.c | 36 | ||||
-rw-r--r-- | src/backend/utils/adt/format_type.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/regproc.c | 34 | ||||
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 70 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 36 | ||||
-rw-r--r-- | src/backend/utils/adt/xml.c | 10 |
9 files changed, 102 insertions, 238 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 52e49999003..8457fc5e480 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.155 2010/01/12 02:39:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.156 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -599,9 +599,7 @@ aclitemout(PG_FUNCTION_ARGS) if (aip->ai_grantee != ACL_ID_PUBLIC) { - htup = SearchSysCache(AUTHOID, - ObjectIdGetDatum(aip->ai_grantee), - 0, 0, 0); + htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee)); if (HeapTupleIsValid(htup)) { putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname)); @@ -629,9 +627,7 @@ aclitemout(PG_FUNCTION_ARGS) *p++ = '/'; *p = '\0'; - htup = SearchSysCache(AUTHOID, - ObjectIdGetDatum(aip->ai_grantor), - 0, 0, 0); + htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor)); if (HeapTupleIsValid(htup)) { putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname)); @@ -1846,9 +1842,7 @@ has_table_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_table_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); aclresult = pg_class_aclcheck(tableoid, roleid, mode); @@ -1874,9 +1868,7 @@ has_table_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_table_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); aclresult = pg_class_aclcheck(tableoid, roleid, mode); @@ -1923,9 +1915,7 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_table_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); aclresult = pg_class_aclcheck(tableoid, roleid, mode); @@ -2278,9 +2268,7 @@ has_any_column_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_column_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); /* First check at table level, then examine each column if needed */ @@ -2310,9 +2298,7 @@ has_any_column_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_column_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); /* First check at table level, then examine each column if needed */ @@ -2367,9 +2353,7 @@ has_any_column_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_column_priv_string(priv_type_text); - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) PG_RETURN_NULL(); /* First check at table level, then examine each column if needed */ @@ -2417,9 +2401,7 @@ column_privilege_check(Oid tableoid, AttrNumber attnum, * here and there. So if we see the row in the syscache, so will * pg_class_aclcheck. */ - if (!SearchSysCacheExists(RELOID, - ObjectIdGetDatum(tableoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid))) return -1; aclresult = pg_class_aclcheck(tableoid, roleid, mode); @@ -2432,10 +2414,9 @@ column_privilege_check(Oid tableoid, AttrNumber attnum, * check for dropped attribute first, and we rely on the syscache not to * notice a concurrent drop before pg_attribute_aclcheck fetches the row. */ - attTuple = SearchSysCache(ATTNUM, - ObjectIdGetDatum(tableoid), - Int16GetDatum(attnum), - 0, 0); + attTuple = SearchSysCache2(ATTNUM, + ObjectIdGetDatum(tableoid), + Int16GetDatum(attnum)); if (!HeapTupleIsValid(attTuple)) return -1; attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple); @@ -2893,9 +2874,7 @@ has_database_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_database_priv_string(priv_type_text); - if (!SearchSysCacheExists(DATABASEOID, - ObjectIdGetDatum(databaseoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(DATABASEOID, ObjectIdGetDatum(databaseoid))) PG_RETURN_NULL(); aclresult = pg_database_aclcheck(databaseoid, roleid, mode); @@ -2921,9 +2900,7 @@ has_database_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_database_priv_string(priv_type_text); - if (!SearchSysCacheExists(DATABASEOID, - ObjectIdGetDatum(databaseoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(DATABASEOID, ObjectIdGetDatum(databaseoid))) PG_RETURN_NULL(); aclresult = pg_database_aclcheck(databaseoid, roleid, mode); @@ -2970,9 +2947,7 @@ has_database_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_database_priv_string(priv_type_text); - if (!SearchSysCacheExists(DATABASEOID, - ObjectIdGetDatum(databaseoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(DATABASEOID, ObjectIdGetDatum(databaseoid))) PG_RETURN_NULL(); aclresult = pg_database_aclcheck(databaseoid, roleid, mode); @@ -3286,9 +3261,7 @@ has_function_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_function_priv_string(priv_type_text); - if (!SearchSysCacheExists(PROCOID, - ObjectIdGetDatum(functionoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(PROCOID, ObjectIdGetDatum(functionoid))) PG_RETURN_NULL(); aclresult = pg_proc_aclcheck(functionoid, roleid, mode); @@ -3314,9 +3287,7 @@ has_function_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_function_priv_string(priv_type_text); - if (!SearchSysCacheExists(PROCOID, - ObjectIdGetDatum(functionoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(PROCOID, ObjectIdGetDatum(functionoid))) PG_RETURN_NULL(); aclresult = pg_proc_aclcheck(functionoid, roleid, mode); @@ -3363,9 +3334,7 @@ has_function_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_function_priv_string(priv_type_text); - if (!SearchSysCacheExists(PROCOID, - ObjectIdGetDatum(functionoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(PROCOID, ObjectIdGetDatum(functionoid))) PG_RETURN_NULL(); aclresult = pg_proc_aclcheck(functionoid, roleid, mode); @@ -3492,9 +3461,7 @@ has_language_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_language_priv_string(priv_type_text); - if (!SearchSysCacheExists(LANGOID, - ObjectIdGetDatum(languageoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(LANGOID, ObjectIdGetDatum(languageoid))) PG_RETURN_NULL(); aclresult = pg_language_aclcheck(languageoid, roleid, mode); @@ -3520,9 +3487,7 @@ has_language_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_language_priv_string(priv_type_text); - if (!SearchSysCacheExists(LANGOID, - ObjectIdGetDatum(languageoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(LANGOID, ObjectIdGetDatum(languageoid))) PG_RETURN_NULL(); aclresult = pg_language_aclcheck(languageoid, roleid, mode); @@ -3569,9 +3534,7 @@ has_language_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_language_priv_string(priv_type_text); - if (!SearchSysCacheExists(LANGOID, - ObjectIdGetDatum(languageoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(LANGOID, ObjectIdGetDatum(languageoid))) PG_RETURN_NULL(); aclresult = pg_language_aclcheck(languageoid, roleid, mode); @@ -3592,9 +3555,7 @@ convert_language_name(text *languagename) char *langname = text_to_cstring(languagename); Oid oid; - oid = GetSysCacheOid(LANGNAME, - CStringGetDatum(langname), - 0, 0, 0); + oid = GetSysCacheOid1(LANGNAME, CStringGetDatum(langname)); if (!OidIsValid(oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), @@ -3698,9 +3659,7 @@ has_schema_privilege_name_id(PG_FUNCTION_ARGS) roleid = get_roleid_checked(NameStr(*username)); mode = convert_schema_priv_string(priv_type_text); - if (!SearchSysCacheExists(NAMESPACEOID, - ObjectIdGetDatum(schemaoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(schemaoid))) PG_RETURN_NULL(); aclresult = pg_namespace_aclcheck(schemaoid, roleid, mode); @@ -3726,9 +3685,7 @@ has_schema_privilege_id(PG_FUNCTION_ARGS) roleid = GetUserId(); mode = convert_schema_priv_string(priv_type_text); - if (!SearchSysCacheExists(NAMESPACEOID, - ObjectIdGetDatum(schemaoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(schemaoid))) PG_RETURN_NULL(); aclresult = pg_namespace_aclcheck(schemaoid, roleid, mode); @@ -3775,9 +3732,7 @@ has_schema_privilege_id_id(PG_FUNCTION_ARGS) mode = convert_schema_priv_string(priv_type_text); - if (!SearchSysCacheExists(NAMESPACEOID, - ObjectIdGetDatum(schemaoid), - 0, 0, 0)) + if (!SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(schemaoid))) PG_RETURN_NULL(); aclresult = pg_namespace_aclcheck(schemaoid, roleid, mode); @@ -3798,9 +3753,7 @@ convert_schema_name(text *schemaname) char *nspname = text_to_cstring(schemaname); Oid oid; - oid = GetSysCacheOid(NAMESPACENAME, - CStringGetDatum(nspname), - 0, 0, 0); + oid = GetSysCacheOid1(NAMESPACENAME, CStringGetDatum(nspname)); if (!OidIsValid(oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_SCHEMA), @@ -4443,9 +4396,7 @@ has_rolinherit(Oid roleid) bool result = false; HeapTuple utup; - utup = SearchSysCache(AUTHOID, - ObjectIdGetDatum(roleid), - 0, 0, 0); + utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(utup)) { result = ((Form_pg_authid) GETSTRUCT(utup))->rolinherit; @@ -4505,9 +4456,8 @@ roles_has_privs_of(Oid roleid) continue; /* Find roles that memberid is directly a member of */ - memlist = SearchSysCacheList(AUTHMEMMEMROLE, 1, - ObjectIdGetDatum(memberid), - 0, 0, 0); + memlist = SearchSysCacheList1(AUTHMEMMEMROLE, + ObjectIdGetDatum(memberid)); for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; @@ -4585,9 +4535,8 @@ roles_is_member_of(Oid roleid) int i; /* Find roles that memberid is directly a member of */ - memlist = SearchSysCacheList(AUTHMEMMEMROLE, 1, - ObjectIdGetDatum(memberid), - 0, 0, 0); + memlist = SearchSysCacheList1(AUTHMEMMEMROLE, + ObjectIdGetDatum(memberid)); for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; @@ -4744,9 +4693,8 @@ is_admin_of_role(Oid member, Oid role) int i; /* Find roles that memberid is directly a member of */ - memlist = SearchSysCacheList(AUTHMEMMEMROLE, 1, - ObjectIdGetDatum(memberid), - 0, 0, 0); + memlist = SearchSysCacheList1(AUTHMEMMEMROLE, + ObjectIdGetDatum(memberid)); for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index d894e8906c8..2bb2427c060 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.29 2010/02/07 20:48:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.30 2010/02/14 18:42:16 rhaas Exp $ * */ @@ -531,9 +531,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS) HeapTuple tuple; Form_pg_class relform; - tuple = SearchSysCache(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); relform = (Form_pg_class) GETSTRUCT(tuple); @@ -580,9 +578,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS) RelFileNode rnode; char *path; - tuple = SearchSysCache(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); relform = (Form_pg_class) GETSTRUCT(tuple); diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index 307a8de3214..ebee928f17c 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.9 2010/01/02 16:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.10 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -45,10 +45,9 @@ enum_in(PG_FUNCTION_ARGS) format_type_be(enumtypoid), name))); - tup = SearchSysCache(ENUMTYPOIDNAME, - ObjectIdGetDatum(enumtypoid), - CStringGetDatum(name), - 0, 0); + tup = SearchSysCache2(ENUMTYPOIDNAME, + ObjectIdGetDatum(enumtypoid), + CStringGetDatum(name)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), @@ -75,9 +74,7 @@ enum_out(PG_FUNCTION_ARGS) HeapTuple tup; Form_pg_enum en; - tup = SearchSysCache(ENUMOID, - ObjectIdGetDatum(enumval), - 0, 0, 0); + tup = SearchSysCache1(ENUMOID, ObjectIdGetDatum(enumval)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), @@ -113,10 +110,9 @@ enum_recv(PG_FUNCTION_ARGS) format_type_be(enumtypoid), name))); - tup = SearchSysCache(ENUMTYPOIDNAME, - ObjectIdGetDatum(enumtypoid), - CStringGetDatum(name), - 0, 0); + tup = SearchSysCache2(ENUMTYPOIDNAME, + ObjectIdGetDatum(enumtypoid), + CStringGetDatum(name)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), @@ -141,9 +137,7 @@ enum_send(PG_FUNCTION_ARGS) HeapTuple tup; Form_pg_enum en; - tup = SearchSysCache(ENUMOID, - ObjectIdGetDatum(enumval), - 0, 0, 0); + tup = SearchSysCache1(ENUMOID, ObjectIdGetDatum(enumval)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), @@ -269,9 +263,7 @@ enum_first(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("could not determine actual enum type"))); - list = SearchSysCacheList(ENUMTYPOIDNAME, 1, - ObjectIdGetDatum(enumtypoid), - 0, 0, 0); + list = SearchSysCacheList1(ENUMTYPOIDNAME, ObjectIdGetDatum(enumtypoid)); num = list->n_members; for (i = 0; i < num; i++) { @@ -310,9 +302,7 @@ enum_last(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("could not determine actual enum type"))); - list = SearchSysCacheList(ENUMTYPOIDNAME, 1, - ObjectIdGetDatum(enumtypoid), - 0, 0, 0); + list = SearchSysCacheList1(ENUMTYPOIDNAME, ObjectIdGetDatum(enumtypoid)); num = list->n_members; for (i = 0; i < num; i++) { @@ -393,9 +383,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper) j; Datum *elems; - list = SearchSysCacheList(ENUMTYPOIDNAME, 1, - ObjectIdGetDatum(enumtypoid), - 0, 0, 0); + list = SearchSysCacheList1(ENUMTYPOIDNAME, ObjectIdGetDatum(enumtypoid)); total = list->n_members; elems = (Datum *) palloc(total * sizeof(Datum)); diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index 4ba4636a168..bdb1d628149 100644 --- a/src/backend/utils/adt/format_type.c +++ b/src/backend/utils/adt/format_type.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.52 2010/01/02 16:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.53 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -123,9 +123,7 @@ format_type_internal(Oid type_oid, int32 typemod, if (type_oid == InvalidOid && allow_invalid) return pstrdup("-"); - tuple = SearchSysCache(TYPEOID, - ObjectIdGetDatum(type_oid), - 0, 0, 0); + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid)); if (!HeapTupleIsValid(tuple)) { if (allow_invalid) @@ -151,9 +149,7 @@ format_type_internal(Oid type_oid, int32 typemod, { /* Switch our attention to the array element type */ ReleaseSysCache(tuple); - tuple = SearchSysCache(TYPEOID, - ObjectIdGetDatum(array_base_type), - 0, 0, 0); + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(array_base_type)); if (!HeapTupleIsValid(tuple)) { if (allow_invalid) diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index d32fff2731e..b050d02a067 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.112 2010/01/02 16:57:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.113 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -164,9 +164,7 @@ regprocout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(proid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(proid)); if (HeapTupleIsValid(proctup)) { @@ -307,9 +305,7 @@ format_procedure(Oid procedure_oid) char *result; HeapTuple proctup; - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(procedure_oid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid)); if (HeapTupleIsValid(proctup)) { @@ -513,9 +509,7 @@ regoperout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - opertup = SearchSysCache(OPEROID, - ObjectIdGetDatum(oprid), - 0, 0, 0); + opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid)); if (HeapTupleIsValid(opertup)) { @@ -663,9 +657,7 @@ format_operator(Oid operator_oid) char *result; HeapTuple opertup; - opertup = SearchSysCache(OPEROID, - ObjectIdGetDatum(operator_oid), - 0, 0, 0); + opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid)); if (HeapTupleIsValid(opertup)) { @@ -852,9 +844,7 @@ regclassout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - classtup = SearchSysCache(RELOID, - ObjectIdGetDatum(classid), - 0, 0, 0); + classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classid)); if (HeapTupleIsValid(classtup)) { @@ -1015,9 +1005,7 @@ regtypeout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - typetup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(typid), - 0, 0, 0); + typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(typetup)) { @@ -1129,9 +1117,7 @@ regconfigout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - cfgtup = SearchSysCache(TSCONFIGOID, - ObjectIdGetDatum(cfgid), - 0, 0, 0); + cfgtup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgid)); if (HeapTupleIsValid(cfgtup)) { @@ -1241,9 +1227,7 @@ regdictionaryout(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(result); } - dicttup = SearchSysCache(TSDICTOID, - ObjectIdGetDatum(dictid), - 0, 0, 0); + dicttup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictid)); if (HeapTupleIsValid(dicttup)) { diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index ecd7b56a26a..2d0ab44b7de 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -15,7 +15,7 @@ * * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.117 2010/01/02 16:57:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.118 2010/02/14 18:42:16 rhaas Exp $ * * ---------- */ @@ -2901,9 +2901,7 @@ ri_GenerateQual(StringInfo buf, char *oprname; char *nspname; - opertup = SearchSysCache(OPEROID, - ObjectIdGetDatum(opoid), - 0, 0, 0); + opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid)); if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", opoid); operform = (Form_pg_operator) GETSTRUCT(opertup); @@ -2940,9 +2938,7 @@ ri_add_cast_to(StringInfo buf, Oid typid) char *typname; char *nspname; - typetup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(typid), - 0, 0, 0); + typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup failed for type %u", typid); typform = (Form_pg_type) GETSTRUCT(typetup); @@ -3071,9 +3067,7 @@ ri_FetchConstraintInfo(RI_ConstraintInfo *riinfo, errhint("Remove this referential integrity trigger and its mates, then do ALTER TABLE ADD CONSTRAINT."))); /* OK, fetch the tuple */ - tup = SearchSysCache(CONSTROID, - ObjectIdGetDatum(constraintOid), - 0, 0, 0); + tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for constraint %u", constraintOid); conForm = (Form_pg_constraint) GETSTRUCT(tup); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 202d68f589d..b2127a3129a 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.321 2010/02/12 17:33:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.322 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -774,9 +774,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, /* * Fetch the pg_index tuple by the Oid of the index */ - ht_idx = SearchSysCache(INDEXRELID, - ObjectIdGetDatum(indexrelid), - 0, 0, 0); + ht_idx = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexrelid)); if (!HeapTupleIsValid(ht_idx)) elog(ERROR, "cache lookup failed for index %u", indexrelid); idxrec = (Form_pg_index) GETSTRUCT(ht_idx); @@ -797,9 +795,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, /* * Fetch the pg_class tuple of the index relation */ - ht_idxrel = SearchSysCache(RELOID, - ObjectIdGetDatum(indexrelid), - 0, 0, 0); + ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexrelid)); if (!HeapTupleIsValid(ht_idxrel)) elog(ERROR, "cache lookup failed for relation %u", indexrelid); idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel); @@ -807,9 +803,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, /* * Fetch the pg_am tuple of the index' access method */ - ht_am = SearchSysCache(AMOID, - ObjectIdGetDatum(idxrelrec->relam), - 0, 0, 0); + ht_am = SearchSysCache1(AMOID, ObjectIdGetDatum(idxrelrec->relam)); if (!HeapTupleIsValid(ht_am)) elog(ERROR, "cache lookup failed for access method %u", idxrelrec->relam); @@ -1048,9 +1042,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, Form_pg_constraint conForm; StringInfoData buf; - tup = SearchSysCache(CONSTROID, - ObjectIdGetDatum(constraintId), - 0, 0, 0); + tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintId)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for constraint %u", constraintId); conForm = (Form_pg_constraint) GETSTRUCT(tup); @@ -1480,9 +1472,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS) /* * Get the pg_authid entry and print the result */ - roletup = SearchSysCache(AUTHOID, - ObjectIdGetDatum(roleid), - 0, 0, 0); + roletup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(roletup)) { role_rec = (Form_pg_authid) GETSTRUCT(roletup); @@ -1581,9 +1571,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) char *result; /* Get the sequence's pg_class entry */ - classtup = SearchSysCache(RELOID, - ObjectIdGetDatum(sequenceId), - 0, 0, 0); + classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(sequenceId)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for relation %u", sequenceId); classtuple = (Form_pg_class) GETSTRUCT(classtup); @@ -1633,9 +1621,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) initStringInfo(&buf); /* Look up the function */ - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(funcid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); proc = (Form_pg_proc) GETSTRUCT(proctup); @@ -1647,9 +1633,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) errmsg("\"%s\" is an aggregate function", name))); /* Need its pg_language tuple for the language name */ - langtup = SearchSysCache(LANGOID, - ObjectIdGetDatum(proc->prolang), - 0, 0, 0); + langtup = SearchSysCache1(LANGOID, ObjectIdGetDatum(proc->prolang)); if (!HeapTupleIsValid(langtup)) elog(ERROR, "cache lookup failed for language %u", proc->prolang); lang = (Form_pg_language) GETSTRUCT(langtup); @@ -1806,9 +1790,7 @@ pg_get_function_arguments(PG_FUNCTION_ARGS) initStringInfo(&buf); - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(funcid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); @@ -1834,9 +1816,7 @@ pg_get_function_identity_arguments(PG_FUNCTION_ARGS) initStringInfo(&buf); - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(funcid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); @@ -1861,9 +1841,7 @@ pg_get_function_result(PG_FUNCTION_ARGS) initStringInfo(&buf); - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(funcid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); @@ -5342,9 +5320,7 @@ get_oper_expr(OpExpr *expr, deparse_context *context) HeapTuple tp; Form_pg_operator optup; - tp = SearchSysCache(OPEROID, - ObjectIdGetDatum(opno), - 0, 0, 0); + tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for operator %u", opno); optup = (Form_pg_operator) GETSTRUCT(tp); @@ -6273,9 +6249,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype, char *opcname; char *nspname; - ht_opc = SearchSysCache(CLAOID, - ObjectIdGetDatum(opclass), - 0, 0, 0); + ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(ht_opc)) elog(ERROR, "cache lookup failed for opclass %u", opclass); opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc); @@ -6512,9 +6486,7 @@ generate_relation_name(Oid relid, List *namespaces) char *nspname; char *result; - tp = SearchSysCache(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for relation %u", relid); reltup = (Form_pg_class) GETSTRUCT(tp); @@ -6582,9 +6554,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, int p_nvargs; Oid *p_true_typeids; - proctup = SearchSysCache(PROCOID, - ObjectIdGetDatum(funcid), - 0, 0, 0); + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); procform = (Form_pg_proc) GETSTRUCT(proctup); @@ -6650,9 +6620,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2) initStringInfo(&buf); - opertup = SearchSysCache(OPEROID, - ObjectIdGetDatum(operid), - 0, 0, 0); + opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operid)); if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", operid); operform = (Form_pg_operator) GETSTRUCT(opertup); @@ -6730,9 +6698,7 @@ flatten_reloptions(Oid relid) Datum reloptions; bool isnull; - tuple = SearchSysCache(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 4bd302eab51..b83cd45d7c7 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.268 2010/01/05 21:53:59 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.269 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -4117,11 +4117,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, } else if (rte->rtekind == RTE_RELATION) { - vardata->statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(rte->relid), - Int16GetDatum(var->varattno), - BoolGetDatum(rte->inh), - 0); + vardata->statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(rte->relid), + Int16GetDatum(var->varattno), + BoolGetDatum(rte->inh)); vardata->freefunc = ReleaseSysCache; } else @@ -4258,11 +4257,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, else if (index->indpred == NIL) { vardata->statsTuple = - SearchSysCache(STATRELATTINH, + SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(index->indexoid), - Int16GetDatum(pos + 1), - BoolGetDatum(false), - 0); + Int16GetDatum(pos + 1), + BoolGetDatum(false)); vardata->freefunc = ReleaseSysCache; } if (vardata->statsTuple) @@ -6116,11 +6114,10 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(relid), - Int16GetDatum(colnum), - BoolGetDatum(rte->inh), - 0); + vardata.statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(relid), + Int16GetDatum(colnum), + BoolGetDatum(rte->inh)); vardata.freefunc = ReleaseSysCache; } } @@ -6143,11 +6140,10 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(relid), - Int16GetDatum(colnum), - BoolGetDatum(false), - 0); + vardata.statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(relid), + Int16GetDatum(colnum), + BoolGetDatum(false)); vardata.freefunc = ReleaseSysCache; } } diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 504a35e94c4..b32d03f90f7 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.95 2010/01/02 16:57:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.96 2010/02/14 18:42:17 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -2612,9 +2612,7 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls, HeapTuple tuple; Form_pg_class reltuple; - tuple = SearchSysCache(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); reltuple = (Form_pg_class) GETSTRUCT(tuple); @@ -2912,9 +2910,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod) HeapTuple tuple; Form_pg_type typtuple; - tuple = SearchSysCache(TYPEOID, - ObjectIdGetDatum(typeoid), - 0, 0, 0); + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", typeoid); typtuple = (Form_pg_type) GETSTRUCT(tuple); |