mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-05 19:09:58 +08:00
Remove GetUserMappingId() and GetUserMappingById().
These functions were added in commitsfbe5a3fb7
anda104a017f
, but commit45639a052
removed their only callers. Put the related code in foreign.c back to the way it was in 9.5, to avoid pointless cross-version diffs. Etsuro Fujita Patch: <d674a3f1-6b63-519c-ef3f-f3188ed6a178@lab.ntt.co.jp>
This commit is contained in:
parent
d70d119151
commit
13bf801a25
@ -1323,20 +1323,6 @@ GetForeignTable(Oid relid);
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
UserMapping *
|
|
||||||
GetUserMappingById(Oid umid);
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
This function returns the <structname>UserMapping</structname> object for
|
|
||||||
the given user mapping OID. The OID of a user mapping for a foreign scan
|
|
||||||
is available in the <structname>RelOptInfo</structname>.
|
|
||||||
If there is no mapping for the OID, this function will throw an error.
|
|
||||||
A <structname>UserMapping</structname> object contains properties of the
|
|
||||||
user mapping (see <filename>foreign/foreign.h</filename> for details).
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<programlisting>
|
|
||||||
List *
|
List *
|
||||||
GetForeignColumnOptions(Oid relid, AttrNumber attnum);
|
GetForeignColumnOptions(Oid relid, AttrNumber attnum);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
extern Datum pg_options_to_table(PG_FUNCTION_ARGS);
|
extern Datum pg_options_to_table(PG_FUNCTION_ARGS);
|
||||||
extern Datum postgresql_fdw_validator(PG_FUNCTION_ARGS);
|
extern Datum postgresql_fdw_validator(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
static HeapTuple find_user_mapping(Oid userid, Oid serverid);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetForeignDataWrapper - look up the foreign-data wrapper by OID.
|
* GetForeignDataWrapper - look up the foreign-data wrapper by OID.
|
||||||
@ -161,54 +159,6 @@ GetForeignServerByName(const char *srvname, bool missing_ok)
|
|||||||
return GetForeignServer(serverid);
|
return GetForeignServer(serverid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* GetUserMappingById - look up the user mapping by its OID.
|
|
||||||
*/
|
|
||||||
UserMapping *
|
|
||||||
GetUserMappingById(Oid umid)
|
|
||||||
{
|
|
||||||
Datum datum;
|
|
||||||
HeapTuple tp;
|
|
||||||
bool isnull;
|
|
||||||
UserMapping *um;
|
|
||||||
|
|
||||||
tp = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(umid));
|
|
||||||
if (!HeapTupleIsValid(tp))
|
|
||||||
elog(ERROR, "cache lookup failed for user mapping %u", umid);
|
|
||||||
|
|
||||||
um = (UserMapping *) palloc(sizeof(UserMapping));
|
|
||||||
um->umid = umid;
|
|
||||||
|
|
||||||
/* Extract the umuser */
|
|
||||||
datum = SysCacheGetAttr(USERMAPPINGOID,
|
|
||||||
tp,
|
|
||||||
Anum_pg_user_mapping_umuser,
|
|
||||||
&isnull);
|
|
||||||
Assert(!isnull);
|
|
||||||
um->userid = DatumGetObjectId(datum);
|
|
||||||
|
|
||||||
/* Extract the umserver */
|
|
||||||
datum = SysCacheGetAttr(USERMAPPINGOID,
|
|
||||||
tp,
|
|
||||||
Anum_pg_user_mapping_umserver,
|
|
||||||
&isnull);
|
|
||||||
Assert(!isnull);
|
|
||||||
um->serverid = DatumGetObjectId(datum);
|
|
||||||
|
|
||||||
/* Extract the umoptions */
|
|
||||||
datum = SysCacheGetAttr(USERMAPPINGOID,
|
|
||||||
tp,
|
|
||||||
Anum_pg_user_mapping_umoptions,
|
|
||||||
&isnull);
|
|
||||||
if (isnull)
|
|
||||||
um->options = NIL;
|
|
||||||
else
|
|
||||||
um->options = untransformRelOptions(datum);
|
|
||||||
|
|
||||||
ReleaseSysCache(tp);
|
|
||||||
|
|
||||||
return um;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetUserMapping - look up the user mapping.
|
* GetUserMapping - look up the user mapping.
|
||||||
@ -224,7 +174,23 @@ GetUserMapping(Oid userid, Oid serverid)
|
|||||||
bool isnull;
|
bool isnull;
|
||||||
UserMapping *um;
|
UserMapping *um;
|
||||||
|
|
||||||
tp = find_user_mapping(userid, serverid);
|
tp = SearchSysCache2(USERMAPPINGUSERSERVER,
|
||||||
|
ObjectIdGetDatum(userid),
|
||||||
|
ObjectIdGetDatum(serverid));
|
||||||
|
|
||||||
|
if (!HeapTupleIsValid(tp))
|
||||||
|
{
|
||||||
|
/* Not found for the specific user -- try PUBLIC */
|
||||||
|
tp = SearchSysCache2(USERMAPPINGUSERSERVER,
|
||||||
|
ObjectIdGetDatum(InvalidOid),
|
||||||
|
ObjectIdGetDatum(serverid));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!HeapTupleIsValid(tp))
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
|
errmsg("user mapping not found for \"%s\"",
|
||||||
|
MappingUserName(userid))));
|
||||||
|
|
||||||
um = (UserMapping *) palloc(sizeof(UserMapping));
|
um = (UserMapping *) palloc(sizeof(UserMapping));
|
||||||
um->umid = HeapTupleGetOid(tp);
|
um->umid = HeapTupleGetOid(tp);
|
||||||
@ -246,60 +212,6 @@ GetUserMapping(Oid userid, Oid serverid)
|
|||||||
return um;
|
return um;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* GetUserMappingId - look up the user mapping, and return its OID
|
|
||||||
*
|
|
||||||
* If no mapping is found for the supplied user, we also look for
|
|
||||||
* PUBLIC mappings (userid == InvalidOid).
|
|
||||||
*/
|
|
||||||
Oid
|
|
||||||
GetUserMappingId(Oid userid, Oid serverid)
|
|
||||||
{
|
|
||||||
HeapTuple tp;
|
|
||||||
Oid umid;
|
|
||||||
|
|
||||||
tp = find_user_mapping(userid, serverid);
|
|
||||||
|
|
||||||
/* Extract the Oid */
|
|
||||||
umid = HeapTupleGetOid(tp);
|
|
||||||
|
|
||||||
ReleaseSysCache(tp);
|
|
||||||
|
|
||||||
return umid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* find_user_mapping - Guts of GetUserMapping family.
|
|
||||||
*
|
|
||||||
* If no mapping is found for the supplied user, we also look for
|
|
||||||
* PUBLIC mappings (userid == InvalidOid).
|
|
||||||
*/
|
|
||||||
static HeapTuple
|
|
||||||
find_user_mapping(Oid userid, Oid serverid)
|
|
||||||
{
|
|
||||||
HeapTuple tp;
|
|
||||||
|
|
||||||
tp = SearchSysCache2(USERMAPPINGUSERSERVER,
|
|
||||||
ObjectIdGetDatum(userid),
|
|
||||||
ObjectIdGetDatum(serverid));
|
|
||||||
|
|
||||||
if (HeapTupleIsValid(tp))
|
|
||||||
return tp;
|
|
||||||
|
|
||||||
/* Not found for the specific user -- try PUBLIC */
|
|
||||||
tp = SearchSysCache2(USERMAPPINGUSERSERVER,
|
|
||||||
ObjectIdGetDatum(InvalidOid),
|
|
||||||
ObjectIdGetDatum(serverid));
|
|
||||||
|
|
||||||
if (!HeapTupleIsValid(tp))
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
|
||||||
errmsg("user mapping not found for \"%s\"",
|
|
||||||
MappingUserName(userid))));
|
|
||||||
|
|
||||||
return tp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetForeignTable - look up the foreign table definition by relation oid.
|
* GetForeignTable - look up the foreign table definition by relation oid.
|
||||||
|
@ -72,8 +72,6 @@ typedef struct ForeignTable
|
|||||||
extern ForeignServer *GetForeignServer(Oid serverid);
|
extern ForeignServer *GetForeignServer(Oid serverid);
|
||||||
extern ForeignServer *GetForeignServerByName(const char *name, bool missing_ok);
|
extern ForeignServer *GetForeignServerByName(const char *name, bool missing_ok);
|
||||||
extern UserMapping *GetUserMapping(Oid userid, Oid serverid);
|
extern UserMapping *GetUserMapping(Oid userid, Oid serverid);
|
||||||
extern Oid GetUserMappingId(Oid userid, Oid serverid);
|
|
||||||
extern UserMapping *GetUserMappingById(Oid umid);
|
|
||||||
extern ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid);
|
extern ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid);
|
||||||
extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *name,
|
extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *name,
|
||||||
bool missing_ok);
|
bool missing_ok);
|
||||||
|
Loading…
Reference in New Issue
Block a user