| From: | Anton Ratundalov <a(dot)ratundalov(at)postgrespro(dot)ru> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Using ForeignScan::fs_server to find user mapping |
| Date: | 2026-06-30 12:23:56 |
| Message-ID: | bc626437-e295-4989-8459-df084ad1f49c@postgrespro.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers
In the postgresBeginForeignScan I see rather complex logic just before
GetUserMapping call.
This is all about finding serverid.
/*
* Identify which user to do the remote access as. This should
match what
* ExecCheckPermissions() does.
*/
userid = OidIsValid(fsplan->checkAsUser) ? fsplan->checkAsUser :
GetUserId();
if (fsplan->scan.scanrelid > 0)
rtindex = fsplan->scan.scanrelid;
else
rtindex = bms_next_member(fsplan->fs_base_relids, -1);
rte = exec_rt_fetch(rtindex, estate);
/* Get info about foreign table. */
table = GetForeignTable(rte->relid);
user = GetUserMapping(userid, table->serverid);
Seems like we have the required serverid in ForeignScan::fs_server already.
Why not to use it?
Best regards
Anton Ratundalov
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-06-30 12:27:22 | Re: JSON_VALUE/JSON_TABLE DEFAULT expression ignores RETURNING typmod |
| Previous Message | Ranier Vilela | 2026-06-30 12:23:20 | Refactor function pg_get_multixact_stats (src/backend/utils/adt/multixactfuncs.c) |