Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e5f4fc

Browse files
committed
postgres_fdw: Save foreign server OID in connection cache entry.
The foreign server OID stored in the connection cache entry is used asa lookup key to directly get the server name.Previously since the connection cache entry did not have the server OID,postgres_fdw had to get the server OID at first from user mapping beforegetting the server name. So if the corresponding user mapping was dropped,postgres_fdw could raise the error "cache lookup failed for user mapping"while looking up user mapping and fail to get the server name even thoughthe server had not been dropped yet.Author: Bharath RupireddyReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/CALj2ACVRZPUB7ZwqLn-6DY8C_UmPs6084gSpHA92YBv++1AJXA@mail.gmail.com
1 parent8e396a7 commit5e5f4fc

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

‎contrib/postgres_fdw/connection.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ typedef struct ConnCacheEntry
5757
boolhave_error;/* have any subxacts aborted in this xact? */
5858
boolchanging_xact_state;/* xact state change in process */
5959
boolinvalidated;/* true if reconnect is pending */
60+
Oidserverid;/* foreign server OID used to get server name */
6061
uint32server_hashvalue;/* hash value of foreign server OID */
6162
uint32mapping_hashvalue;/* hash value of user mapping OID */
6263
}ConnCacheEntry;
@@ -273,6 +274,7 @@ make_new_connection(ConnCacheEntry *entry, UserMapping *user)
273274
entry->have_error= false;
274275
entry->changing_xact_state= false;
275276
entry->invalidated= false;
277+
entry->serverid=server->serverid;
276278
entry->server_hashvalue=
277279
GetSysCacheHashValue1(FOREIGNSERVEROID,
278280
ObjectIdGetDatum(server->serverid));
@@ -1138,8 +1140,6 @@ pgfdw_inval_callback(Datum arg, int cacheid, uint32 hashvalue)
11381140
staticvoid
11391141
pgfdw_reject_incomplete_xact_state_change(ConnCacheEntry*entry)
11401142
{
1141-
HeapTupletup;
1142-
Form_pg_user_mappingumform;
11431143
ForeignServer*server;
11441144

11451145
/* nothing to do for inactive entries and entries of sane state */
@@ -1150,13 +1150,7 @@ pgfdw_reject_incomplete_xact_state_change(ConnCacheEntry *entry)
11501150
disconnect_pg_server(entry);
11511151

11521152
/* find server name to be shown in the message below */
1153-
tup=SearchSysCache1(USERMAPPINGOID,
1154-
ObjectIdGetDatum(entry->key));
1155-
if (!HeapTupleIsValid(tup))
1156-
elog(ERROR,"cache lookup failed for user mapping %u",entry->key);
1157-
umform= (Form_pg_user_mapping)GETSTRUCT(tup);
1158-
server=GetForeignServer(umform->umserver);
1159-
ReleaseSysCache(tup);
1153+
server=GetForeignServer(entry->serverid);
11601154

11611155
ereport(ERROR,
11621156
(errcode(ERRCODE_CONNECTION_EXCEPTION),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp