PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
miscinit.c File Reference
#include "postgres.h"
#include <sys/param.h>
#include <signal.h>
#include <time.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "access/htup_details.h"
#include "catalog/pg_authid.h"
#include "libpq/libpq.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/pg_shmem.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Include dependency graph for miscinit.c:

Go to the source code of this file.

Macros

#define DIRECTORY_LOCK_FILE   "postmaster.pid"
 

Functions

void SetDatabasePath (const char *path)
 
void SetDataDir (const char *dir)
 
void ChangeToDataDir (void)
 
void InitPostmasterChild (void)
 
void InitStandaloneProcess (const char *argv0)
 
void SwitchToSharedLatch (void)
 
void SwitchBackToLocalLatch (void)
 
Oid GetUserId (void)
 
Oid GetOuterUserId (void)
 
static void SetOuterUserId (Oid userid)
 
Oid GetSessionUserId (void)
 
static void SetSessionUserId (Oid userid, bool is_superuser)
 
Oid GetAuthenticatedUserId (void)
 
void GetUserIdAndSecContext (Oid *userid, int *sec_context)
 
void SetUserIdAndSecContext (Oid userid, int sec_context)
 
bool InLocalUserIdChange (void)
 
bool InSecurityRestrictedOperation (void)
 
bool InNoForceRLSOperation (void)
 
void GetUserIdAndContext (Oid *userid, bool *sec_def_context)
 
void SetUserIdAndContext (Oid userid, bool sec_def_context)
 
bool has_rolreplication (Oid roleid)
 
void InitializeSessionUserId (const char *rolename, Oid roleid)
 
void InitializeSessionUserIdStandalone (void)
 
void SetSessionAuthorization (Oid userid, bool is_superuser)
 
Oid GetCurrentRoleId (void)
 
void SetCurrentRoleId (Oid roleid, bool is_superuser)
 
char * GetUserNameFromId (Oid roleid, bool noerr)
 
static void UnlinkLockFiles (int status, Datum arg)
 
static void CreateLockFile (const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
 
void CreateDataDirLockFile (bool amPostmaster)
 
void CreateSocketLockFile (const char *socketfile, bool amPostmaster, const char *socketDir)
 
void TouchSocketLockFiles (void)
 
void AddToDataDirLockFile (int target_line, const char *str)
 
bool RecheckDataDirLockFile (void)
 
void ValidatePgVersion (const char *path)
 
static void load_libraries (const char *libraries, const char *gucname, bool restricted)
 
void process_shared_preload_libraries (void)
 
void process_session_preload_libraries (void)
 
void pg_bindtextdomain (const char *domain)
 

Variables

ProcessingMode Mode = InitProcessing
 
static Listlock_files = NIL
 
static Latch LocalLatchData
 
bool IgnoreSystemIndexes = false
 
static Oid AuthenticatedUserId = InvalidOid
 
static Oid SessionUserId = InvalidOid
 
static Oid OuterUserId = InvalidOid
 
static Oid CurrentUserId = InvalidOid
 
static bool AuthenticatedUserIsSuperuser = false
 
static bool SessionUserIsSuperuser = false
 
static int SecurityRestrictionContext = 0
 
static bool SetRoleIsActive = false
 
char * session_preload_libraries_string = NULL
 
char * shared_preload_libraries_string = NULL
 
char * local_preload_libraries_string = NULL
 
bool process_shared_preload_libraries_in_progress = false
 

Macro Definition Documentation

#define DIRECTORY_LOCK_FILE   "postmaster.pid"

Function Documentation

void AddToDataDirLockFile ( int  target_line,
const char *  str 
)

Definition at line 1156 of file miscinit.c.

References close, DIRECTORY_LOCK_FILE, elog, ereport, errcode_for_file_access(), errmsg(), fd(), LOG, NULL, PG_BINARY, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), read, snprintf(), WAIT_EVENT_LOCK_FILE_ADDTODATADIR_READ, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_SYNC, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE, and write.

Referenced by InternalIpcMemoryCreate(), and PostmasterMain().

1157 {
1158  int fd;
1159  int len;
1160  int lineno;
1161  char *srcptr;
1162  char *destptr;
1163  char srcbuffer[BLCKSZ];
1164  char destbuffer[BLCKSZ];
1165 
1166  fd = open(DIRECTORY_LOCK_FILE, O_RDWR | PG_BINARY, 0);
1167  if (fd < 0)
1168  {
1169  ereport(LOG,
1171  errmsg("could not open file \"%s\": %m",
1173  return;
1174  }
1176  len = read(fd, srcbuffer, sizeof(srcbuffer) - 1);
1178  if (len < 0)
1179  {
1180  ereport(LOG,
1182  errmsg("could not read from file \"%s\": %m",
1184  close(fd);
1185  return;
1186  }
1187  srcbuffer[len] = '\0';
1188 
1189  /*
1190  * Advance over lines we are not supposed to rewrite, then copy them to
1191  * destbuffer.
1192  */
1193  srcptr = srcbuffer;
1194  for (lineno = 1; lineno < target_line; lineno++)
1195  {
1196  if ((srcptr = strchr(srcptr, '\n')) == NULL)
1197  {
1198  elog(LOG, "incomplete data in \"%s\": found only %d newlines while trying to add line %d",
1199  DIRECTORY_LOCK_FILE, lineno - 1, target_line);
1200  close(fd);
1201  return;
1202  }
1203  srcptr++;
1204  }
1205  memcpy(destbuffer, srcbuffer, srcptr - srcbuffer);
1206  destptr = destbuffer + (srcptr - srcbuffer);
1207 
1208  /*
1209  * Write or rewrite the target line.
1210  */
1211  snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s\n", str);
1212  destptr += strlen(destptr);
1213 
1214  /*
1215  * If there are more lines in the old file, append them to destbuffer.
1216  */
1217  if ((srcptr = strchr(srcptr, '\n')) != NULL)
1218  {
1219  srcptr++;
1220  snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s",
1221  srcptr);
1222  }
1223 
1224  /*
1225  * And rewrite the data. Since we write in a single kernel call, this
1226  * update should appear atomic to onlookers.
1227  */
1228  len = strlen(destbuffer);
1229  errno = 0;
1231  if (lseek(fd, (off_t) 0, SEEK_SET) != 0 ||
1232  (int) write(fd, destbuffer, len) != len)
1233  {
1235  /* if write didn't set errno, assume problem is no disk space */
1236  if (errno == 0)
1237  errno = ENOSPC;
1238  ereport(LOG,
1240  errmsg("could not write to file \"%s\": %m",
1242  close(fd);
1243  return;
1244  }
1247  if (pg_fsync(fd) != 0)
1248  {
1249  ereport(LOG,
1251  errmsg("could not write to file \"%s\": %m",
1253  }
1255  if (close(fd) != 0)
1256  {
1257  ereport(LOG,
1259  errmsg("could not write to file \"%s\": %m",
1261  }
1262 }
#define write(a, b, c)
Definition: win32.h:14
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:54
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
#define LOG
Definition: elog.h:26
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1038
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:229
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1208
int errmsg(const char *fmt,...)
Definition: elog.c:797
int pg_fsync(int fd)
Definition: fd.c:333
#define elog
Definition: elog.h:219
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
void ChangeToDataDir ( void  )

Definition at line 115 of file miscinit.c.

References AssertState, DataDir, ereport, errcode_for_file_access(), errmsg(), and FATAL.

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

116 {
118 
119  if (chdir(DataDir) < 0)
120  ereport(FATAL,
122  errmsg("could not change directory to \"%s\": %m",
123  DataDir)));
124 }
#define AssertState(condition)
Definition: c.h:678
#define FATAL
Definition: elog.h:52
int errcode_for_file_access(void)
Definition: elog.c:598
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
char * DataDir
Definition: globals.c:59
void CreateDataDirLockFile ( bool  amPostmaster)

Definition at line 1080 of file miscinit.c.

References CreateLockFile(), DataDir, and DIRECTORY_LOCK_FILE.

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

1081 {
1082  CreateLockFile(DIRECTORY_LOCK_FILE, amPostmaster, "", true, DataDir);
1083 }
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:54
static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
Definition: miscinit.c:768
char * DataDir
Definition: globals.c:59
static void CreateLockFile ( const char *  filename,
bool  amPostmaster,
const char *  socketDir,
bool  isDDLock,
const char *  refName 
)
static

Definition at line 768 of file miscinit.c.

References buffer, close, DataDir, elog, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), FATAL, fd(), lcons(), LOCK_FILE_LINE_SHMEM_KEY, MAXPGPATH, MyStartTime, NIL, NULL, on_proc_exit(), pg_fsync(), PGSharedMemoryIsInUse(), pgstat_report_wait_end(), pgstat_report_wait_start(), PostPortNumber, pstrdup(), read, snprintf(), strlcat(), unlink(), UnlinkLockFiles(), WAIT_EVENT_LOCK_FILE_CREATE_READ, WAIT_EVENT_LOCK_FILE_CREATE_SYNC, WAIT_EVENT_LOCK_FILE_CREATE_WRITE, and write.

Referenced by CreateDataDirLockFile(), and CreateSocketLockFile().

771 {
772  int fd;
773  char buffer[MAXPGPATH * 2 + 256];
774  int ntries;
775  int len;
776  int encoded_pid;
777  pid_t other_pid;
778  pid_t my_pid,
779  my_p_pid,
780  my_gp_pid;
781  const char *envvar;
782 
783  /*
784  * If the PID in the lockfile is our own PID or our parent's or
785  * grandparent's PID, then the file must be stale (probably left over from
786  * a previous system boot cycle). We need to check this because of the
787  * likelihood that a reboot will assign exactly the same PID as we had in
788  * the previous reboot, or one that's only one or two counts larger and
789  * hence the lockfile's PID now refers to an ancestor shell process. We
790  * allow pg_ctl to pass down its parent shell PID (our grandparent PID)
791  * via the environment variable PG_GRANDPARENT_PID; this is so that
792  * launching the postmaster via pg_ctl can be just as reliable as
793  * launching it directly. There is no provision for detecting
794  * further-removed ancestor processes, but if the init script is written
795  * carefully then all but the immediate parent shell will be root-owned
796  * processes and so the kill test will fail with EPERM. Note that we
797  * cannot get a false negative this way, because an existing postmaster
798  * would surely never launch a competing postmaster or pg_ctl process
799  * directly.
800  */
801  my_pid = getpid();
802 
803 #ifndef WIN32
804  my_p_pid = getppid();
805 #else
806 
807  /*
808  * Windows hasn't got getppid(), but doesn't need it since it's not using
809  * real kill() either...
810  */
811  my_p_pid = 0;
812 #endif
813 
814  envvar = getenv("PG_GRANDPARENT_PID");
815  if (envvar)
816  my_gp_pid = atoi(envvar);
817  else
818  my_gp_pid = 0;
819 
820  /*
821  * We need a loop here because of race conditions. But don't loop forever
822  * (for example, a non-writable $PGDATA directory might cause a failure
823  * that won't go away). 100 tries seems like plenty.
824  */
825  for (ntries = 0;; ntries++)
826  {
827  /*
828  * Try to create the lock file --- O_EXCL makes this atomic.
829  *
830  * Think not to make the file protection weaker than 0600. See
831  * comments below.
832  */
833  fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
834  if (fd >= 0)
835  break; /* Success; exit the retry loop */
836 
837  /*
838  * Couldn't create the pid file. Probably it already exists.
839  */
840  if ((errno != EEXIST && errno != EACCES) || ntries > 100)
841  ereport(FATAL,
843  errmsg("could not create lock file \"%s\": %m",
844  filename)));
845 
846  /*
847  * Read the file to get the old owner's PID. Note race condition
848  * here: file might have been deleted since we tried to create it.
849  */
850  fd = open(filename, O_RDONLY, 0600);
851  if (fd < 0)
852  {
853  if (errno == ENOENT)
854  continue; /* race condition; try again */
855  ereport(FATAL,
857  errmsg("could not open lock file \"%s\": %m",
858  filename)));
859  }
861  if ((len = read(fd, buffer, sizeof(buffer) - 1)) < 0)
862  ereport(FATAL,
864  errmsg("could not read lock file \"%s\": %m",
865  filename)));
867  close(fd);
868 
869  if (len == 0)
870  {
871  ereport(FATAL,
872  (errcode(ERRCODE_LOCK_FILE_EXISTS),
873  errmsg("lock file \"%s\" is empty", filename),
874  errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
875  }
876 
877  buffer[len] = '\0';
878  encoded_pid = atoi(buffer);
879 
880  /* if pid < 0, the pid is for postgres, not postmaster */
881  other_pid = (pid_t) (encoded_pid < 0 ? -encoded_pid : encoded_pid);
882 
883  if (other_pid <= 0)
884  elog(FATAL, "bogus data in lock file \"%s\": \"%s\"",
885  filename, buffer);
886 
887  /*
888  * Check to see if the other process still exists
889  *
890  * Per discussion above, my_pid, my_p_pid, and my_gp_pid can be
891  * ignored as false matches.
892  *
893  * Normally kill() will fail with ESRCH if the given PID doesn't
894  * exist.
895  *
896  * We can treat the EPERM-error case as okay because that error
897  * implies that the existing process has a different userid than we
898  * do, which means it cannot be a competing postmaster. A postmaster
899  * cannot successfully attach to a data directory owned by a userid
900  * other than its own. (This is now checked directly in
901  * checkDataDir(), but has been true for a long time because of the
902  * restriction that the data directory isn't group- or
903  * world-accessible.) Also, since we create the lockfiles mode 600,
904  * we'd have failed above if the lockfile belonged to another userid
905  * --- which means that whatever process kill() is reporting about
906  * isn't the one that made the lockfile. (NOTE: this last
907  * consideration is the only one that keeps us from blowing away a
908  * Unix socket file belonging to an instance of Postgres being run by
909  * someone else, at least on machines where /tmp hasn't got a
910  * stickybit.)
911  */
912  if (other_pid != my_pid && other_pid != my_p_pid &&
913  other_pid != my_gp_pid)
914  {
915  if (kill(other_pid, 0) == 0 ||
916  (errno != ESRCH && errno != EPERM))
917  {
918  /* lockfile belongs to a live process */
919  ereport(FATAL,
920  (errcode(ERRCODE_LOCK_FILE_EXISTS),
921  errmsg("lock file \"%s\" already exists",
922  filename),
923  isDDLock ?
924  (encoded_pid < 0 ?
925  errhint("Is another postgres (PID %d) running in data directory \"%s\"?",
926  (int) other_pid, refName) :
927  errhint("Is another postmaster (PID %d) running in data directory \"%s\"?",
928  (int) other_pid, refName)) :
929  (encoded_pid < 0 ?
930  errhint("Is another postgres (PID %d) using socket file \"%s\"?",
931  (int) other_pid, refName) :
932  errhint("Is another postmaster (PID %d) using socket file \"%s\"?",
933  (int) other_pid, refName))));
934  }
935  }
936 
937  /*
938  * No, the creating process did not exist. However, it could be that
939  * the postmaster crashed (or more likely was kill -9'd by a clueless
940  * admin) but has left orphan backends behind. Check for this by
941  * looking to see if there is an associated shmem segment that is
942  * still in use.
943  *
944  * Note: because postmaster.pid is written in multiple steps, we might
945  * not find the shmem ID values in it; we can't treat that as an
946  * error.
947  */
948  if (isDDLock)
949  {
950  char *ptr = buffer;
951  unsigned long id1,
952  id2;
953  int lineno;
954 
955  for (lineno = 1; lineno < LOCK_FILE_LINE_SHMEM_KEY; lineno++)
956  {
957  if ((ptr = strchr(ptr, '\n')) == NULL)
958  break;
959  ptr++;
960  }
961 
962  if (ptr != NULL &&
963  sscanf(ptr, "%lu %lu", &id1, &id2) == 2)
964  {
965  if (PGSharedMemoryIsInUse(id1, id2))
966  ereport(FATAL,
967  (errcode(ERRCODE_LOCK_FILE_EXISTS),
968  errmsg("pre-existing shared memory block "
969  "(key %lu, ID %lu) is still in use",
970  id1, id2),
971  errhint("If you're sure there are no old "
972  "server processes still running, remove "
973  "the shared memory block "
974  "or just delete the file \"%s\".",
975  filename)));
976  }
977  }
978 
979  /*
980  * Looks like nobody's home. Unlink the file and try again to create
981  * it. Need a loop because of possible race condition against other
982  * would-be creators.
983  */
984  if (unlink(filename) < 0)
985  ereport(FATAL,
987  errmsg("could not remove old lock file \"%s\": %m",
988  filename),
989  errhint("The file seems accidentally left over, but "
990  "it could not be removed. Please remove the file "
991  "by hand and try again.")));
992  }
993 
994  /*
995  * Successfully created the file, now fill it. See comment in miscadmin.h
996  * about the contents. Note that we write the same first five lines into
997  * both datadir and socket lockfiles; although more stuff may get added to
998  * the datadir lockfile later.
999  */
1000  snprintf(buffer, sizeof(buffer), "%d\n%s\n%ld\n%d\n%s\n",
1001  amPostmaster ? (int) my_pid : -((int) my_pid),
1002  DataDir,
1003  (long) MyStartTime,
1005  socketDir);
1006 
1007  /*
1008  * In a standalone backend, the next line (LOCK_FILE_LINE_LISTEN_ADDR)
1009  * will never receive data, so fill it in as empty now.
1010  */
1011  if (isDDLock && !amPostmaster)
1012  strlcat(buffer, "\n", sizeof(buffer));
1013 
1014  errno = 0;
1016  if (write(fd, buffer, strlen(buffer)) != strlen(buffer))
1017  {
1018  int save_errno = errno;
1019 
1020  close(fd);
1021  unlink(filename);
1022  /* if write didn't set errno, assume problem is no disk space */
1023  errno = save_errno ? save_errno : ENOSPC;
1024  ereport(FATAL,
1026  errmsg("could not write lock file \"%s\": %m", filename)));
1027  }
1029 
1031  if (pg_fsync(fd) != 0)
1032  {
1033  int save_errno = errno;
1034 
1035  close(fd);
1036  unlink(filename);
1037  errno = save_errno;
1038  ereport(FATAL,
1040  errmsg("could not write lock file \"%s\": %m", filename)));
1041  }
1043  if (close(fd) != 0)
1044  {
1045  int save_errno = errno;
1046 
1047  unlink(filename);
1048  errno = save_errno;
1049  ereport(FATAL,
1051  errmsg("could not write lock file \"%s\": %m", filename)));
1052  }
1053 
1054  /*
1055  * Arrange to unlink the lock file(s) at proc_exit. If this is the first
1056  * one, set up the on_proc_exit function to do it; then add this lock file
1057  * to the list of files to unlink.
1058  */
1059  if (lock_files == NIL)
1061 
1062  /*
1063  * Use lcons so that the lock files are unlinked in reverse order of
1064  * creation; this is critical!
1065  */
1067 }
#define NIL
Definition: pg_list.h:69
int errhint(const char *fmt,...)
Definition: elog.c:987
#define write(a, b, c)
Definition: win32.h:14
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:292
static List * lock_files
Definition: miscinit.c:59
char * pstrdup(const char *in)
Definition: mcxt.c:1077
pg_time_t MyStartTime
Definition: globals.c:39
int errcode(int sqlerrcode)
Definition: elog.c:575
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static int fd(const char *x, int i)
Definition: preproc-init.c:105
int PostPortNumber
Definition: postmaster.c:194
#define FATAL
Definition: elog.h:52
#define MAXPGPATH
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
int unlink(const char *filename)
#define ereport(elevel, rest)
Definition: elog.h:122
#define LOCK_FILE_LINE_SHMEM_KEY
Definition: miscadmin.h:452
List * lcons(void *datum, List *list)
Definition: list.c:259
#define NULL
Definition: c.h:229
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:207
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1208
bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
Definition: sysv_shmem.c:288
static void UnlinkLockFiles(int status, Datum arg)
Definition: miscinit.c:733
static char * filename
Definition: pg_dumpall.c:87
int errmsg(const char *fmt,...)
Definition: elog.c:797
char * DataDir
Definition: globals.c:59
int pg_fsync(int fd)
Definition: fd.c:333
#define elog
Definition: elog.h:219
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
size_t strlcat(char *dst, const char *src, size_t siz)
Definition: strlcat.c:33
void CreateSocketLockFile ( const char *  socketfile,
bool  amPostmaster,
const char *  socketDir 
)

Definition at line 1089 of file miscinit.c.

References CreateLockFile(), MAXPGPATH, and snprintf().

1091 {
1092  char lockfile[MAXPGPATH];
1093 
1094  snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
1095  CreateLockFile(lockfile, amPostmaster, socketDir, false, socketfile);
1096 }
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
Definition: miscinit.c:768
#define MAXPGPATH
Oid GetAuthenticatedUserId ( void  )

Definition at line 342 of file miscinit.c.

References AssertState, AuthenticatedUserId, and OidIsValid.

Referenced by InitializeParallelDSM().

343 {
345  return AuthenticatedUserId;
346 }
#define AssertState(condition)
Definition: c.h:678
#define OidIsValid(objectId)
Definition: c.h:538
static Oid AuthenticatedUserId
Definition: miscinit.c:155
Oid GetCurrentRoleId ( void  )

Definition at line 635 of file miscinit.c.

References InvalidOid, OuterUserId, and SetRoleIsActive.

Referenced by show_role().

636 {
637  if (SetRoleIsActive)
638  return OuterUserId;
639  else
640  return InvalidOid;
641 }
static Oid OuterUserId
Definition: miscinit.c:157
#define InvalidOid
Definition: postgres_ext.h:36
static bool SetRoleIsActive
Definition: miscinit.c:167
Oid GetOuterUserId ( void  )

Definition at line 294 of file miscinit.c.

References AssertState, OidIsValid, and OuterUserId.

Referenced by DropRole(), and RenameRole().

295 {
297  return OuterUserId;
298 }
#define AssertState(condition)
Definition: c.h:678
static Oid OuterUserId
Definition: miscinit.c:157
#define OidIsValid(objectId)
Definition: c.h:538
Oid GetSessionUserId ( void  )

Definition at line 317 of file miscinit.c.

References AssertState, OidIsValid, and SessionUserId.

Referenced by check_role(), DropRole(), get_rolespec_oid(), get_rolespec_tuple(), InitPostgres(), is_admin_of_role(), pgstat_bestart(), RenameRole(), and session_user().

318 {
320  return SessionUserId;
321 }
#define AssertState(condition)
Definition: c.h:678
static Oid SessionUserId
Definition: miscinit.c:156
#define OidIsValid(objectId)
Definition: c.h:538
Oid GetUserId ( void  )

Definition at line 283 of file miscinit.c.

References AssertState, CurrentUserId, and OidIsValid.

Referenced by AddRoleMems(), AggregateCreate(), AlterCollation(), AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseSet(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterOpFamilyAdd(), AlterPublication(), AlterPublicationOwner_internal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner_internal(), AlterSequence(), AlterSubscription(), AlterSubscriptionOwner_internal(), AlterTableMoveAll(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTSDictionary(), AlterTypeNamespace_oid(), AlterTypeOwner(), analyze_rel(), ATExecAddColumn(), ATExecChangeOwner(), ATPrepAlterColumnType(), ATPrepSetStatistics(), ATPrepSetTableSpace(), ATSimplePermissions(), be_lo_unlink(), binary_upgrade_create_empty_extension(), brin_desummarize_range(), brin_summarize_range(), BuildCachedPlan(), BuildDescForRelation(), BuildIndexValueDescription(), calculate_database_size(), calculate_tablespace_size(), call_pltcl_start_proc(), check_enable_rls(), check_permissions(), check_temp_tablespaces(), CheckCachedPlan(), checkDomainOwner(), checkEnumOwner(), checkFkeyPermissions(), CheckFunctionValidatorAccess(), CheckMyDatabase(), cluster_rel(), CommentObject(), compile_plperl_function(), compile_pltcl_function(), CompleteCachedPlan(), compute_return_type(), CreateCast(), CreateConversionCommand(), createdb(), CreateEventTrigger(), CreateExtensionInternal(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateFunction(), CreateOpFamily(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), current_user(), currtid_byrelname(), currtid_byreloid(), currval_oid(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineQueryRewrite(), DefineRange(), DefineRelation(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), DelRoleMems(), do_setval(), dropdb(), DropOwnedObjects(), DropRole(), DropSubscription(), DropTableSpace(), EnableDisableRule(), ExecAlterDefaultPrivilegesStmt(), ExecAlterExtensionContentsStmt(), ExecAlterExtensionStmt(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecCheckRTEPerms(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExecSecLabelStmt(), ExecuteDoStmt(), ExecuteTruncate(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), FinishPreparedTransaction(), get_connect_string(), get_other_operator(), get_rel_from_relname(), get_rolespec_oid(), get_rolespec_tuple(), get_row_security_policies(), get_tables_to_cluster(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionByNum(), GetConfigOptionResetString(), gin_clean_pending_list(), GrantRole(), HandleFunctionRequest(), has_any_column_privilege_id(), has_any_column_privilege_name(), has_column_privilege_id_attnum(), has_column_privilege_id_name(), has_column_privilege_name_attnum(), has_column_privilege_name_name(), has_database_privilege_id(), has_database_privilege_name(), has_foreign_data_wrapper_privilege_id(), has_foreign_data_wrapper_privilege_name(), has_function_privilege_id(), has_function_privilege_name(), has_language_privilege_id(), has_language_privilege_name(), has_schema_privilege_id(), has_schema_privilege_name(), has_sequence_privilege_id(), has_sequence_privilege_name(), has_server_privilege_id(), has_server_privilege_name(), has_table_privilege_id(), has_table_privilege_name(), has_tablespace_privilege_id(), has_tablespace_privilege_name(), has_type_privilege_id(), has_type_privilege_name(), have_createdb_privilege(), have_createrole_privilege(), ImportForeignSchema(), init_sexpr(), InitializeSearchPath(), InitPostgres(), InitTempTableNamespace(), inline_function(), inline_set_returning_function(), insert_username(), interpret_function_parameter_list(), inv_create(), LargeObjectCreate(), lastval(), lo_get_fragment_internal(), lo_read(), lo_truncate_internal(), lo_write(), LockTableAclCheck(), lookup_agg_function(), LookupCreationNamespace(), LookupExplicitNamespace(), MergeAttributes(), movedb(), nextval_internal(), OperatorCreate(), OperatorShellMake(), pg_has_role_id(), pg_has_role_name(), pg_import_system_collations(), pg_prewarm(), pg_sequence_last_value(), pg_sequence_parameters(), pg_signal_backend(), pg_stat_get_activity(), pg_stat_get_backend_activity(), pg_stat_get_backend_activity_start(), pg_stat_get_backend_client_addr(), pg_stat_get_backend_client_port(), pg_stat_get_backend_start(), pg_stat_get_backend_wait_event(), pg_stat_get_backend_wait_event_type(), pg_stat_get_backend_xact_start(), pg_stat_get_progress_info(), pg_stat_get_wal_receiver(), pg_stat_statements_internal(), pgrowlocks(), pgss_store(), pgstat_get_backend_current_activity(), pltcl_fetch_interp(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), postgresGetForeignRelSize(), postgresImportForeignSchema(), PrepareTempTablespaces(), PrepareTransaction(), PublicationAddTables(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReassignOwnedObjects(), recomputeNamespacePath(), ReindexMultipleTables(), RemoveObjects(), RemoveRoleFromObjectPolicy(), renameatt_check(), RenameDatabase(), RenameSchema(), RenameTableSpace(), RenameType(), RevalidateCachedQuery(), RI_Initial_Check(), ri_ReportViolation(), select_perl_context(), set_foreign_rel_properties(), superuser(), timetravel(), transformTableLikeClause(), truncate_check_rel(), user_mapping_ddl_aclcheck(), vacuum_rel(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

284 {
286  return CurrentUserId;
287 }
#define AssertState(condition)
Definition: c.h:678
#define OidIsValid(objectId)
Definition: c.h:538
static Oid CurrentUserId
Definition: miscinit.c:158
void GetUserIdAndContext ( Oid userid,
bool sec_def_context 
)

Definition at line 437 of file miscinit.c.

References CurrentUserId, and InLocalUserIdChange().

438 {
439  *userid = CurrentUserId;
440  *sec_def_context = InLocalUserIdChange();
441 }
bool InLocalUserIdChange(void)
Definition: miscinit.c:406
static Oid CurrentUserId
Definition: miscinit.c:158
void GetUserIdAndSecContext ( Oid userid,
int *  sec_context 
)
char* GetUserNameFromId ( Oid  roleid,
bool  noerr 
)

Definition at line 691 of file miscinit.c.

References AUTHOID, ereport, errcode(), errmsg(), ERROR, GETSTRUCT, HeapTupleIsValid, NameStr, NULL, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), result, and SearchSysCache1.

Referenced by check_is_member_of_role(), current_user(), getObjectDescription(), getObjectIdentityParts(), insert_username(), regroleout(), RemoveRoleFromObjectPolicy(), session_user(), and timetravel().

692 {
693  HeapTuple tuple;
694  char *result;
695 
696  tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
697  if (!HeapTupleIsValid(tuple))
698  {
699  if (!noerr)
700  ereport(ERROR,
701  (errcode(ERRCODE_UNDEFINED_OBJECT),
702  errmsg("invalid role OID: %u", roleid)));
703  result = NULL;
704  }
705  else
706  {
707  result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
708  ReleaseSysCache(tuple);
709  }
710  return result;
711 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
int errcode(int sqlerrcode)
Definition: elog.c:575
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define NameStr(name)
Definition: c.h:499
bool has_rolreplication ( Oid  roleid)

Definition at line 464 of file miscinit.c.

References AUTHOID, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), result, and SearchSysCache1.

Referenced by check_permissions(), and InitPostgres().

465 {
466  bool result = false;
467  HeapTuple utup;
468 
469  utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
470  if (HeapTupleIsValid(utup))
471  {
472  result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
473  ReleaseSysCache(utup);
474  }
475  return result;
476 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
void InitializeSessionUserId ( const char *  rolename,
Oid  roleid 
)

Definition at line 482 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, AUTHNAME, AUTHOID, CountUserBackends(), ereport, errcode(), errmsg(), FATAL, GETSTRUCT, HeapTupleGetOid, HeapTupleIsValid, IsBootstrapProcessingMode, IsUnderPostmaster, MyProc, NameStr, NULL, ObjectIdGetDatum, OidIsValid, PGC_BACKEND, PGC_INTERNAL, PGC_S_OVERRIDE, PointerGetDatum, ReleaseSysCache(), PGPROC::roleId, SearchSysCache1, SetConfigOption(), and SetSessionUserId().

Referenced by InitPostgres().

483 {
484  HeapTuple roleTup;
485  Form_pg_authid rform;
486  char *rname;
487 
488  /*
489  * Don't do scans if we're bootstrapping, none of the system catalogs
490  * exist yet, and they should be owned by postgres anyway.
491  */
493 
494  /* call only once */
496 
497  if (rolename != NULL)
498  {
499  roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(rolename));
500  if (!HeapTupleIsValid(roleTup))
501  ereport(FATAL,
502  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
503  errmsg("role \"%s\" does not exist", rolename)));
504  }
505  else
506  {
507  roleTup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
508  if (!HeapTupleIsValid(roleTup))
509  ereport(FATAL,
510  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
511  errmsg("role with OID %u does not exist", roleid)));
512  }
513 
514  rform = (Form_pg_authid) GETSTRUCT(roleTup);
515  roleid = HeapTupleGetOid(roleTup);
516  rname = NameStr(rform->rolname);
517 
518  AuthenticatedUserId = roleid;
519  AuthenticatedUserIsSuperuser = rform->rolsuper;
520 
521  /* This sets OuterUserId/CurrentUserId too */
523 
524  /* Also mark our PGPROC entry with the authenticated user id */
525  /* (We assume this is an atomic store so no lock is needed) */
526  MyProc->roleId = roleid;
527 
528  /*
529  * These next checks are not enforced when in standalone mode, so that
530  * there is a way to recover from sillinesses like "UPDATE pg_authid SET
531  * rolcanlogin = false;".
532  */
533  if (IsUnderPostmaster)
534  {
535  /*
536  * Is role allowed to login at all?
537  */
538  if (!rform->rolcanlogin)
539  ereport(FATAL,
540  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
541  errmsg("role \"%s\" is not permitted to log in",
542  rname)));
543 
544  /*
545  * Check connection limit for this role.
546  *
547  * There is a race condition here --- we create our PGPROC before
548  * checking for other PGPROCs. If two backends did this at about the
549  * same time, they might both think they were over the limit, while
550  * ideally one should succeed and one fail. Getting that to work
551  * exactly seems more trouble than it is worth, however; instead we
552  * just document that the connection limit is approximate.
553  */
554  if (rform->rolconnlimit >= 0 &&
556  CountUserBackends(roleid) > rform->rolconnlimit)
557  ereport(FATAL,
558  (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
559  errmsg("too many connections for role \"%s\"",
560  rname)));
561  }
562 
563  /* Record username and superuser status as GUC settings too */
564  SetConfigOption("session_authorization", rname,
566  SetConfigOption("is_superuser",
567  AuthenticatedUserIsSuperuser ? "on" : "off",
569 
570  ReleaseSysCache(roleTup);
571 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define AssertState(condition)
Definition: c.h:678
PGPROC * MyProc
Definition: proc.c:67
#define PointerGetDatum(X)
Definition: postgres.h:562
Oid roleId
Definition: proc.h:114
int errcode(int sqlerrcode)
Definition: elog.c:575
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define FATAL
Definition: elog.h:52
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6676
bool IsUnderPostmaster
Definition: globals.c:100
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:161
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
int CountUserBackends(Oid roleid)
Definition: procarray.c:2836
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define NameStr(name)
Definition: c.h:499
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:325
static Oid AuthenticatedUserId
Definition: miscinit.c:155
void InitializeSessionUserIdStandalone ( void  )

Definition at line 578 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, BOOTSTRAP_SUPERUSERID, IsAutoVacuumWorkerProcess(), IsBackgroundWorker, IsUnderPostmaster, OidIsValid, and SetSessionUserId().

Referenced by InitPostgres().

579 {
580  /*
581  * This function should only be called in single-user mode, in autovacuum
582  * workers, and in background workers.
583  */
585 
586  /* call only once */
588 
591 
593 }
#define AssertState(condition)
Definition: c.h:678
#define OidIsValid(objectId)
Definition: c.h:538
bool IsBackgroundWorker
Definition: globals.c:102
bool IsUnderPostmaster
Definition: globals.c:100
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:161
bool IsAutoVacuumWorkerProcess(void)
Definition: autovacuum.c:3360
#define BOOTSTRAP_SUPERUSERID
Definition: pg_authid.h:108
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:325
static Oid AuthenticatedUserId
Definition: miscinit.c:155
void InitPostmasterChild ( void  )

Definition at line 175 of file miscinit.c.

References elog, FATAL, InitializeLatchSupport(), InitLatch(), IsUnderPostmaster, LocalLatchData, MyLatch, MyProcPid, MyStartTime, NULL, and on_exit_reset().

Referenced by BackendStartup(), do_start_bgworker(), pgarch_start(), pgstat_start(), StartAutoVacLauncher(), StartAutoVacWorker(), StartChildProcess(), and SysLogger_Start().

176 {
177  IsUnderPostmaster = true; /* we are a postmaster subprocess now */
178 
179  MyProcPid = getpid(); /* reset MyProcPid */
180 
181  MyStartTime = time(NULL); /* set our start time in case we call elog */
182 
183  /*
184  * make sure stderr is in binary mode before anything can possibly be
185  * written to it, in case it's actually the syslogger pipe, so the pipe
186  * chunking protocol isn't disturbed. Non-logpipe data gets translated on
187  * redirection (e.g. via pg_ctl -l) anyway.
188  */
189 #ifdef WIN32
190  _setmode(fileno(stderr), _O_BINARY);
191 #endif
192 
193  /* We don't want the postmaster's proc_exit() handlers */
194  on_exit_reset();
195 
196  /* Initialize process-local latch support */
200 
201  /*
202  * If possible, make this process a group leader, so that the postmaster
203  * can signal any child processes too. Not all processes will have
204  * children, but for consistency we make all postmaster child processes do
205  * this.
206  */
207 #ifdef HAVE_SETSID
208  if (setsid() < 0)
209  elog(FATAL, "setsid() failed: %m");
210 #endif
211 }
int MyProcPid
Definition: globals.c:38
pg_time_t MyStartTime
Definition: globals.c:39
void on_exit_reset(void)
Definition: ipc.c:396
static Latch LocalLatchData
Definition: miscinit.c:61
#define FATAL
Definition: elog.h:52
bool IsUnderPostmaster
Definition: globals.c:100
void InitializeLatchSupport(void)
Definition: latch.c:147
#define NULL
Definition: c.h:229
void InitLatch(volatile Latch *latch)
Definition: latch.c:220
struct Latch * MyLatch
Definition: globals.c:51
#define elog
Definition: elog.h:219
void InitStandaloneProcess ( const char *  argv0)

Definition at line 219 of file miscinit.c.

References Assert, elog, FATAL, find_my_exec(), get_pkglib_path(), InitializeLatchSupport(), InitLatch(), IsPostmasterEnvironment, LocalLatchData, my_exec_path, MyLatch, MyProcPid, MyStartTime, NULL, and pkglib_path.

Referenced by AuxiliaryProcessMain(), and PostgresMain().

220 {
222 
223  MyProcPid = getpid(); /* reset MyProcPid */
224 
225  MyStartTime = time(NULL); /* set our start time in case we call elog */
226 
227  /* Initialize process-local latch support */
231 
232  /* Compute paths, no postmaster to inherit from */
233  if (my_exec_path[0] == '\0')
234  {
235  if (find_my_exec(argv0, my_exec_path) < 0)
236  elog(FATAL, "%s: could not locate my own executable path",
237  argv0);
238  }
239 
240  if (pkglib_path[0] == '\0')
242 }
bool IsPostmasterEnvironment
Definition: globals.c:99
static char * argv0
Definition: pg_ctl.c:89
int MyProcPid
Definition: globals.c:38
pg_time_t MyStartTime
Definition: globals.c:39
void get_pkglib_path(const char *my_exec_path, char *ret_path)
Definition: path.c:758
static Latch LocalLatchData
Definition: miscinit.c:61
#define FATAL
Definition: elog.h:52
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:119
char my_exec_path[MAXPGPATH]
Definition: globals.c:63
void InitializeLatchSupport(void)
Definition: latch.c:147
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
void InitLatch(volatile Latch *latch)
Definition: latch.c:220
struct Latch * MyLatch
Definition: globals.c:51
#define elog
Definition: elog.h:219
char pkglib_path[MAXPGPATH]
Definition: globals.c:64
bool InLocalUserIdChange ( void  )

Definition at line 406 of file miscinit.c.

References SECURITY_LOCAL_USERID_CHANGE, and SecurityRestrictionContext.

Referenced by GetUserIdAndContext(), is_admin_of_role(), and set_config_option().

407 {
409 }
static int SecurityRestrictionContext
Definition: miscinit.c:164
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:291
bool InNoForceRLSOperation ( void  )

Definition at line 424 of file miscinit.c.

References SECURITY_NOFORCE_RLS, and SecurityRestrictionContext.

Referenced by check_enable_rls().

425 {
427 }
static int SecurityRestrictionContext
Definition: miscinit.c:164
#define SECURITY_NOFORCE_RLS
Definition: miscadmin.h:293
bool InSecurityRestrictedOperation ( void  )

Definition at line 415 of file miscinit.c.

References SECURITY_RESTRICTED_OPERATION, and SecurityRestrictionContext.

Referenced by CheckRestrictedOperation(), DefineRelation(), is_admin_of_role(), set_config_option(), and SetUserIdAndContext().

416 {
418 }
#define SECURITY_RESTRICTED_OPERATION
Definition: miscadmin.h:292
static int SecurityRestrictionContext
Definition: miscinit.c:164
static void load_libraries ( const char *  libraries,
const char *  gucname,
bool  restricted 
)
static

Definition at line 1426 of file miscinit.c.

References canonicalize_path(), DEBUG1, ereport, errcode(), errmsg(), filename, first_dir_separator(), lfirst, list_free(), load_file(), LOG, NULL, pfree(), psprintf(), pstrdup(), and SplitIdentifierString().

Referenced by process_session_preload_libraries(), and process_shared_preload_libraries().

1427 {
1428  char *rawstring;
1429  List *elemlist;
1430  ListCell *l;
1431 
1432  if (libraries == NULL || libraries[0] == '\0')
1433  return; /* nothing to do */
1434 
1435  /* Need a modifiable copy of string */
1436  rawstring = pstrdup(libraries);
1437 
1438  /* Parse string into list of identifiers */
1439  if (!SplitIdentifierString(rawstring, ',', &elemlist))
1440  {
1441  /* syntax error in list */
1442  pfree(rawstring);
1443  list_free(elemlist);
1444  ereport(LOG,
1445  (errcode(ERRCODE_SYNTAX_ERROR),
1446  errmsg("invalid list syntax in parameter \"%s\"",
1447  gucname)));
1448  return;
1449  }
1450 
1451  foreach(l, elemlist)
1452  {
1453  char *tok = (char *) lfirst(l);
1454  char *filename;
1455 
1456  filename = pstrdup(tok);
1457  canonicalize_path(filename);
1458  /* If restricting, insert $libdir/plugins if not mentioned already */
1459  if (restricted && first_dir_separator(filename) == NULL)
1460  {
1461  char *expanded;
1462 
1463  expanded = psprintf("$libdir/plugins/%s", filename);
1464  pfree(filename);
1465  filename = expanded;
1466  }
1467  load_file(filename, restricted);
1468  ereport(DEBUG1,
1469  (errmsg("loaded library \"%s\"", filename)));
1470  pfree(filename);
1471  }
1472 
1473  pfree(rawstring);
1474  list_free(elemlist);
1475 }
#define DEBUG1
Definition: elog.h:25
char * pstrdup(const char *in)
Definition: mcxt.c:1077
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
void canonicalize_path(char *path)
Definition: path.c:254
int errcode(int sqlerrcode)
Definition: elog.c:575
#define LOG
Definition: elog.h:26
void pfree(void *pointer)
Definition: mcxt.c:950
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3240
#define ereport(elevel, rest)
Definition: elog.h:122
char * first_dir_separator(const char *filename)
Definition: path.c:103
#define NULL
Definition: c.h:229
#define lfirst(lc)
Definition: pg_list.h:106
void load_file(const char *filename, bool restricted)
Definition: dfmgr.c:137
static char * filename
Definition: pg_dumpall.c:87
int errmsg(const char *fmt,...)
Definition: elog.c:797
void list_free(List *list)
Definition: list.c:1133
Definition: pg_list.h:45
void pg_bindtextdomain ( const char *  domain)

Definition at line 1505 of file miscinit.c.

References get_locale_path(), MAXPGPATH, and my_exec_path.

Referenced by _PG_init().

1506 {
1507 #ifdef ENABLE_NLS
1508  if (my_exec_path[0] != '\0')
1509  {
1510  char locale_path[MAXPGPATH];
1511 
1512  get_locale_path(my_exec_path, locale_path);
1513  bindtextdomain(domain, locale_path);
1514  pg_bind_textdomain_codeset(domain);
1515  }
1516 #endif
1517 }
#define MAXPGPATH
char my_exec_path[MAXPGPATH]
Definition: globals.c:63
void get_locale_path(const char *my_exec_path, char *ret_path)
Definition: path.c:767
void process_session_preload_libraries ( void  )

Definition at line 1494 of file miscinit.c.

References load_libraries(), local_preload_libraries_string, and session_preload_libraries_string.

Referenced by PostgresMain().

1495 {
1497  "session_preload_libraries",
1498  false);
1500  "local_preload_libraries",
1501  true);
1502 }
static void load_libraries(const char *libraries, const char *gucname, bool restricted)
Definition: miscinit.c:1426
char * local_preload_libraries_string
Definition: miscinit.c:1414
char * session_preload_libraries_string
Definition: miscinit.c:1412
void process_shared_preload_libraries ( void  )

Definition at line 1481 of file miscinit.c.

References load_libraries(), process_shared_preload_libraries_in_progress, and shared_preload_libraries_string.

Referenced by PostmasterMain().

1482 {
1485  "shared_preload_libraries",
1486  false);
1488 }
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1417
char * shared_preload_libraries_string
Definition: miscinit.c:1413
static void load_libraries(const char *libraries, const char *gucname, bool restricted)
Definition: miscinit.c:1426
bool RecheckDataDirLockFile ( void  )

Definition at line 1277 of file miscinit.c.

References buffer, close, DIRECTORY_LOCK_FILE, ereport, errcode_for_file_access(), errmsg(), fd(), LOG, PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), read, and WAIT_EVENT_LOCK_FILE_RECHECKDATADIR_READ.

Referenced by ServerLoop().

1278 {
1279  int fd;
1280  int len;
1281  long file_pid;
1282  char buffer[BLCKSZ];
1283 
1284  fd = open(DIRECTORY_LOCK_FILE, O_RDWR | PG_BINARY, 0);
1285  if (fd < 0)
1286  {
1287  /*
1288  * There are many foreseeable false-positive error conditions. For
1289  * safety, fail only on enumerated clearly-something-is-wrong
1290  * conditions.
1291  */
1292  switch (errno)
1293  {
1294  case ENOENT:
1295  case ENOTDIR:
1296  /* disaster */
1297  ereport(LOG,
1299  errmsg("could not open file \"%s\": %m",
1301  return false;
1302  default:
1303  /* non-fatal, at least for now */
1304  ereport(LOG,
1306  errmsg("could not open file \"%s\": %m; continuing anyway",
1308  return true;
1309  }
1310  }
1312  len = read(fd, buffer, sizeof(buffer) - 1);
1314  if (len < 0)
1315  {
1316  ereport(LOG,
1318  errmsg("could not read from file \"%s\": %m",
1320  close(fd);
1321  return true; /* treat read failure as nonfatal */
1322  }
1323  buffer[len] = '\0';
1324  close(fd);
1325  file_pid = atol(buffer);
1326  if (file_pid == getpid())
1327  return true; /* all is well */
1328 
1329  /* Trouble: someone's overwritten the lock file */
1330  ereport(LOG,
1331  (errmsg("lock file \"%s\" contains wrong PID: %ld instead of %ld",
1332  DIRECTORY_LOCK_FILE, file_pid, (long) getpid())));
1333  return false;
1334 }
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:54
#define LOG
Definition: elog.h:26
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1038
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
#define ereport(elevel, rest)
Definition: elog.h:122
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:207
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1208
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
void SetCurrentRoleId ( Oid  roleid,
bool  is_superuser 
)

Definition at line 656 of file miscinit.c.

References OidIsValid, PGC_INTERNAL, PGC_S_OVERRIDE, SessionUserId, SessionUserIsSuperuser, SetConfigOption(), SetOuterUserId(), and SetRoleIsActive.

Referenced by assign_role().

657 {
658  /*
659  * Get correct info if it's SET ROLE NONE
660  *
661  * If SessionUserId hasn't been set yet, just do nothing --- the eventual
662  * SetSessionUserId call will fix everything. This is needed since we
663  * will get called during GUC initialization.
664  */
665  if (!OidIsValid(roleid))
666  {
668  return;
669 
670  roleid = SessionUserId;
672 
673  SetRoleIsActive = false;
674  }
675  else
676  SetRoleIsActive = true;
677 
678  SetOuterUserId(roleid);
679 
680  SetConfigOption("is_superuser",
681  is_superuser ? "on" : "off",
683 }
static Oid SessionUserId
Definition: miscinit.c:156
static void SetOuterUserId(Oid userid)
Definition: miscinit.c:302
#define OidIsValid(objectId)
Definition: c.h:538
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6676
static bool SetRoleIsActive
Definition: miscinit.c:167
static bool SessionUserIsSuperuser
Definition: miscinit.c:162
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3657
void SetDatabasePath ( const char *  path)

Definition at line 82 of file miscinit.c.

References Assert, DatabasePath, MemoryContextStrdup(), and TopMemoryContext.

Referenced by InitPostgres().

83 {
84  /* This should happen only once per process */
87 }
MemoryContext TopMemoryContext
Definition: mcxt.c:43
char * DatabasePath
Definition: globals.c:84
#define Assert(condition)
Definition: c.h:675
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1064
void SetDataDir ( const char *  dir)

Definition at line 94 of file miscinit.c.

References AssertArg, DataDir, free, and make_absolute_path().

Referenced by SelectConfigFiles().

95 {
96  char *new;
97 
98  AssertArg(dir);
99 
100  /* If presented path is relative, convert to absolute */
101  new = make_absolute_path(dir);
102 
103  if (DataDir)
104  free(DataDir);
105  DataDir = new;
106 }
char * make_absolute_path(const char *path)
Definition: path.c:608
#define AssertArg(condition)
Definition: c.h:677
#define free(a)
Definition: header.h:65
char * DataDir
Definition: globals.c:59
static void SetOuterUserId ( Oid  userid)
static

Definition at line 302 of file miscinit.c.

References AssertArg, AssertState, CurrentUserId, OidIsValid, OuterUserId, and SecurityRestrictionContext.

Referenced by SetCurrentRoleId().

303 {
305  AssertArg(OidIsValid(userid));
306  OuterUserId = userid;
307 
308  /* We force the effective user ID to match, too */
309  CurrentUserId = userid;
310 }
#define AssertState(condition)
Definition: c.h:678
static Oid OuterUserId
Definition: miscinit.c:157
#define OidIsValid(objectId)
Definition: c.h:538
static int SecurityRestrictionContext
Definition: miscinit.c:164
#define AssertArg(condition)
Definition: c.h:677
static Oid CurrentUserId
Definition: miscinit.c:158
void SetSessionAuthorization ( Oid  userid,
bool  is_superuser 
)

Definition at line 610 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, ereport, errcode(), errmsg(), ERROR, OidIsValid, PGC_INTERNAL, PGC_S_OVERRIDE, SetConfigOption(), and SetSessionUserId().

Referenced by assign_session_authorization().

611 {
612  /* Must have authenticated already, else can't make permission check */
614 
615  if (userid != AuthenticatedUserId &&
617  ereport(ERROR,
618  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
619  errmsg("permission denied to set session authorization")));
620 
622 
623  SetConfigOption("is_superuser",
624  is_superuser ? "on" : "off",
626 }
#define AssertState(condition)
Definition: c.h:678
int errcode(int sqlerrcode)
Definition: elog.c:575
#define OidIsValid(objectId)
Definition: c.h:538
#define ERROR
Definition: elog.h:43
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6676
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:161
#define ereport(elevel, rest)
Definition: elog.h:122
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3657
int errmsg(const char *fmt,...)
Definition: elog.c:797
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:325
static Oid AuthenticatedUserId
Definition: miscinit.c:155
static void SetSessionUserId ( Oid  userid,
bool  is_superuser 
)
static

Definition at line 325 of file miscinit.c.

References AssertArg, AssertState, CurrentUserId, is_superuser(), OidIsValid, OuterUserId, SecurityRestrictionContext, SessionUserId, SessionUserIsSuperuser, and SetRoleIsActive.

Referenced by InitializeSessionUserId(), InitializeSessionUserIdStandalone(), and SetSessionAuthorization().

326 {
328  AssertArg(OidIsValid(userid));
329  SessionUserId = userid;
331  SetRoleIsActive = false;
332 
333  /* We force the effective user IDs to match, too */
334  OuterUserId = userid;
335  CurrentUserId = userid;
336 }
#define AssertState(condition)
Definition: c.h:678
static Oid SessionUserId
Definition: miscinit.c:156
static Oid OuterUserId
Definition: miscinit.c:157
#define OidIsValid(objectId)
Definition: c.h:538
static int SecurityRestrictionContext
Definition: miscinit.c:164
#define AssertArg(condition)
Definition: c.h:677
static bool SetRoleIsActive
Definition: miscinit.c:167
static bool SessionUserIsSuperuser
Definition: miscinit.c:162
static Oid CurrentUserId
Definition: miscinit.c:158
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3657
void SetUserIdAndContext ( Oid  userid,
bool  sec_def_context 
)

Definition at line 444 of file miscinit.c.

References CurrentUserId, ereport, errcode(), errmsg(), ERROR, InSecurityRestrictedOperation(), SECURITY_LOCAL_USERID_CHANGE, and SecurityRestrictionContext.

445 {
446  /* We throw the same error SET ROLE would. */
448  ereport(ERROR,
449  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
450  errmsg("cannot set parameter \"%s\" within security-restricted operation",
451  "role")));
452  CurrentUserId = userid;
453  if (sec_def_context)
455  else
457 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
static int SecurityRestrictionContext
Definition: miscinit.c:164
#define ereport(elevel, rest)
Definition: elog.h:122
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:291
static Oid CurrentUserId
Definition: miscinit.c:158
bool InSecurityRestrictedOperation(void)
Definition: miscinit.c:415
int errmsg(const char *fmt,...)
Definition: elog.c:797
void SetUserIdAndSecContext ( Oid  userid,
int  sec_context 
)
void SwitchBackToLocalLatch ( void  )

Definition at line 264 of file miscinit.c.

References Assert, FeBeWaitSet, LocalLatchData, ModifyWaitEvent(), MyLatch, MyProc, NULL, PGPROC::procLatch, SetLatch(), and WL_LATCH_SET.

Referenced by AuxiliaryProcKill(), and ProcKill().

265 {
268 
270 
271  if (FeBeWaitSet)
273 
274  SetLatch(MyLatch);
275 }
PGPROC * MyProc
Definition: proc.c:67
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
Definition: latch.c:735
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:167
Latch procLatch
Definition: proc.h:103
static Latch LocalLatchData
Definition: miscinit.c:61
void SetLatch(volatile Latch *latch)
Definition: latch.c:415
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
struct Latch * MyLatch
Definition: globals.c:51
#define WL_LATCH_SET
Definition: latch.h:124
void SwitchToSharedLatch ( void  )

Definition at line 245 of file miscinit.c.

References Assert, FeBeWaitSet, ModifyWaitEvent(), MyLatch, MyProc, NULL, PGPROC::procLatch, SetLatch(), and WL_LATCH_SET.

Referenced by InitAuxiliaryProcess(), and InitProcess().

246 {
248  Assert(MyProc != NULL);
249 
251 
252  if (FeBeWaitSet)
254 
255  /*
256  * Set the shared latch as the local one might have been set. This
257  * shouldn't normally be necessary as code is supposed to check the
258  * condition before waiting for the latch, but a bit care can't hurt.
259  */
260  SetLatch(MyLatch);
261 }
PGPROC * MyProc
Definition: proc.c:67
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
Definition: latch.c:735
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:167
Latch procLatch
Definition: proc.h:103
static Latch LocalLatchData
Definition: miscinit.c:61
void SetLatch(volatile Latch *latch)
Definition: latch.c:415
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
struct Latch * MyLatch
Definition: globals.c:51
#define WL_LATCH_SET
Definition: latch.h:124
void TouchSocketLockFiles ( void  )

Definition at line 1107 of file miscinit.c.

References buffer, close, DIRECTORY_LOCK_FILE, fd(), lfirst, NULL, PG_BINARY, and read.

Referenced by ServerLoop().

1108 {
1109  ListCell *l;
1110 
1111  foreach(l, lock_files)
1112  {
1113  char *socketLockFile = (char *) lfirst(l);
1114 
1115  /* No need to touch the data directory lock file, we trust */
1116  if (strcmp(socketLockFile, DIRECTORY_LOCK_FILE) == 0)
1117  continue;
1118 
1119  /*
1120  * utime() is POSIX standard, utimes() is a common alternative; if we
1121  * have neither, fall back to actually reading the file (which only
1122  * sets the access time not mod time, but that should be enough in
1123  * most cases). In all paths, we ignore errors.
1124  */
1125 #ifdef HAVE_UTIME
1126  utime(socketLockFile, NULL);
1127 #else /* !HAVE_UTIME */
1128 #ifdef HAVE_UTIMES
1129  utimes(socketLockFile, NULL);
1130 #else /* !HAVE_UTIMES */
1131  int fd;
1132  char buffer[1];
1133 
1134  fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0);
1135  if (fd >= 0)
1136  {
1137  read(fd, buffer, sizeof(buffer));
1138  close(fd);
1139  }
1140 #endif /* HAVE_UTIMES */
1141 #endif /* HAVE_UTIME */
1142  }
1143 }
static List * lock_files
Definition: miscinit.c:59
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:54
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1038
#define NULL
Definition: c.h:229
#define lfirst(lc)
Definition: pg_list.h:106
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:207
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
static void UnlinkLockFiles ( int  status,
Datum  arg 
)
static

Definition at line 733 of file miscinit.c.

References ereport, errmsg(), IsPostmasterEnvironment, lfirst, LOG, NIL, NOTICE, and unlink().

Referenced by CreateLockFile().

734 {
735  ListCell *l;
736 
737  foreach(l, lock_files)
738  {
739  char *curfile = (char *) lfirst(l);
740 
741  unlink(curfile);
742  /* Should we complain if the unlink fails? */
743  }
744  /* Since we're about to exit, no need to reclaim storage */
745  lock_files = NIL;
746 
747  /*
748  * Lock file removal should always be the last externally visible action
749  * of a postmaster or standalone backend, while we won't come here at all
750  * when exiting postmaster child processes. Therefore, this is a good
751  * place to log completion of shutdown. We could alternatively teach
752  * proc_exit() to do it, but that seems uglier. In a standalone backend,
753  * use NOTICE elevel to be less chatty.
754  */
756  (errmsg("database system is shut down")));
757 }
#define NIL
Definition: pg_list.h:69
bool IsPostmasterEnvironment
Definition: globals.c:99
static List * lock_files
Definition: miscinit.c:59
#define LOG
Definition: elog.h:26
int unlink(const char *filename)
#define ereport(elevel, rest)
Definition: elog.h:122
#define NOTICE
Definition: elog.h:37
#define lfirst(lc)
Definition: pg_list.h:106
int errmsg(const char *fmt,...)
Definition: elog.c:797
void ValidatePgVersion ( const char *  path)

Definition at line 1349 of file miscinit.c.

References AllocateFile(), ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg(), FATAL, FreeFile(), MAXPGPATH, and snprintf().

Referenced by AuxiliaryProcessMain(), checkDataDir(), InitPostgres(), and PostgresMain().

1350 {
1351  char full_path[MAXPGPATH];
1352  FILE *file;
1353  int ret;
1354  long file_major;
1355  long my_major;
1356  char *endptr;
1357  char file_version_string[64];
1358  const char *my_version_string = PG_VERSION;
1359 
1360  my_major = strtol(my_version_string, &endptr, 10);
1361 
1362  snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);
1363 
1364  file = AllocateFile(full_path, "r");
1365  if (!file)
1366  {
1367  if (errno == ENOENT)
1368  ereport(FATAL,
1369  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1370  errmsg("\"%s\" is not a valid data directory",
1371  path),
1372  errdetail("File \"%s\" is missing.", full_path)));
1373  else
1374  ereport(FATAL,
1376  errmsg("could not open file \"%s\": %m", full_path)));
1377  }
1378 
1379  file_version_string[0] = '\0';
1380  ret = fscanf(file, "%63s", file_version_string);
1381  file_major = strtol(file_version_string, &endptr, 10);
1382 
1383  if (ret != 1 || endptr == file_version_string)
1384  ereport(FATAL,
1385  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1386  errmsg("\"%s\" is not a valid data directory",
1387  path),
1388  errdetail("File \"%s\" does not contain valid data.",
1389  full_path),
1390  errhint("You might need to initdb.")));
1391 
1392  FreeFile(file);
1393 
1394  if (my_major != file_major)
1395  ereport(FATAL,
1396  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1397  errmsg("database files are incompatible with server"),
1398  errdetail("The data directory was initialized by PostgreSQL version %s, "
1399  "which is not compatible with this version %s.",
1400  file_version_string, my_version_string)));
1401 }
int errhint(const char *fmt,...)
Definition: elog.c:987
int errcode(int sqlerrcode)
Definition: elog.c:575
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
#define FATAL
Definition: elog.h:52
#define MAXPGPATH
int errdetail(const char *fmt,...)
Definition: elog.c:873
int errcode_for_file_access(void)
Definition: elog.c:598
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2094
#define ereport(elevel, rest)
Definition: elog.h:122
int FreeFile(FILE *file)
Definition: fd.c:2277
int errmsg(const char *fmt,...)
Definition: elog.c:797

Variable Documentation

bool AuthenticatedUserIsSuperuser = false
static
bool IgnoreSystemIndexes = false
char* local_preload_libraries_string = NULL

Definition at line 1414 of file miscinit.c.

Referenced by process_session_preload_libraries().

Latch LocalLatchData
static

Definition at line 61 of file miscinit.c.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and SwitchBackToLocalLatch().

List* lock_files = NIL
static

Definition at line 59 of file miscinit.c.

Definition at line 56 of file miscinit.c.

Oid OuterUserId = InvalidOid
static

Definition at line 157 of file miscinit.c.

Referenced by GetCurrentRoleId(), GetOuterUserId(), SetOuterUserId(), and SetSessionUserId().

bool process_shared_preload_libraries_in_progress = false
char* session_preload_libraries_string = NULL

Definition at line 1412 of file miscinit.c.

Referenced by process_session_preload_libraries().

Oid SessionUserId = InvalidOid
static

Definition at line 156 of file miscinit.c.

Referenced by GetSessionUserId(), SetCurrentRoleId(), and SetSessionUserId().

bool SessionUserIsSuperuser = false
static

Definition at line 162 of file miscinit.c.

Referenced by SetCurrentRoleId(), and SetSessionUserId().

bool SetRoleIsActive = false
static

Definition at line 167 of file miscinit.c.

Referenced by GetCurrentRoleId(), SetCurrentRoleId(), and SetSessionUserId().

char* shared_preload_libraries_string = NULL

Definition at line 1413 of file miscinit.c.

Referenced by process_shared_preload_libraries().