Using ForeignScan::fs_server to find user mapping - Mailing list pgsql-hackers

From Anton Ratundalov
Subject Using ForeignScan::fs_server to find user mapping
Date
Msg-id bc626437-e295-4989-8459-df084ad1f49c@postgrespro.ru
Whole thread
List 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





pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Refactor function pg_get_multixact_stats (src/backend/utils/adt/multixactfuncs.c)
Next
From: Amit Langote
Date:
Subject: Re: JSON_VALUE/JSON_TABLE DEFAULT expression ignores RETURNING typmod