PostgreSQL Source Code git master
|
#include "postgres.h"
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include "access/genam.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/session.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
#include "catalog/pg_tablespace.h"
#include "libpq/auth.h"
#include "libpq/libpq-be.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "replication/slot.h"
#include "replication/slotsync.h"
#include "replication/walsender.h"
#include "storage/bufmgr.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "storage/procsignal.h"
#include "storage/sinvaladt.h"
#include "storage/smgr.h"
#include "storage/sync.h"
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/timeout.h"
Go to the source code of this file.
Functions | |
static HeapTuple | GetDatabaseTuple (const char *dbname) |
static HeapTuple | GetDatabaseTupleByOid (Oid dboid) |
static void | PerformAuthentication (Port *port) |
static void | CheckMyDatabase (const char *name, bool am_superuser, bool override_allow_connections) |
static void | ShutdownPostgres (int code, Datum arg) |
static void | StatementTimeoutHandler (void) |
static void | LockTimeoutHandler (void) |
static void | IdleInTransactionSessionTimeoutHandler (void) |
static void | TransactionTimeoutHandler (void) |
static void | IdleSessionTimeoutHandler (void) |
static void | IdleStatsUpdateTimeoutHandler (void) |
static void | ClientCheckTimeoutHandler (void) |
static bool | ThereIsAtLeastOneRole (void) |
static void | process_startup_options (Port *port, bool am_superuser) |
static void | process_settings (Oid databaseid, Oid roleid) |
void | pg_split_opts (char **argv, int *argcp, const char *optstr) |
void | InitializeMaxBackends (void) |
void | InitializeFastPathLocks (void) |
void | BaseInit (void) |
void | InitPostgres (const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname) |
void BaseInit | ( | void | ) |
Definition at line 606 of file postinit.c.
References Assert, DebugFileOpen(), InitBufferManagerAccess(), InitFileAccess(), InitLockManagerAccess(), InitSync(), InitTemporaryFileAccess(), InitXLogInsert(), MyProc, pgstat_initialize(), ReplicationSlotInitialize(), and smgrinit().
Referenced by AutoVacWorkerMain(), AuxiliaryProcessMainCommon(), BackgroundWorkerMain(), BootstrapModeMain(), PostgresMain(), and ReplSlotSyncWorkerMain().
|
static |
Definition at line 313 of file postinit.c.
References ACL_CONNECT, ACLCHECK_OK, AmRegularBackendProcess, CountDBConnections(), database_ctype_is_c, elog, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, FATAL, get_collation_actual_version(), GetDatabaseEncodingName(), GETSTRUCT, GetUserId(), HeapTupleIsValid, init_database_collation(), IsUnderPostmaster, locale, MyDatabaseId, name, NameStr, object_aclcheck(), ObjectIdGetDatum(), pg_perm_setlocale(), PGC_BACKEND, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT, quote_identifier(), ReleaseSysCache(), SearchSysCache1(), SetConfigOption(), SetDatabaseEncoding(), SysCacheGetAttr(), SysCacheGetAttrNotNull(), TextDatumGetCString, and WARNING.
Referenced by InitPostgres().
|
static |
Definition at line 1393 of file postinit.c.
References CheckClientConnectionPending, InterruptPending, MyLatch, and SetLatch().
Referenced by InitPostgres().
|
static |
Definition at line 101 of file postinit.c.
References AccessShareLock, BTEqualStrategyNumber, criticalSharedRelcachesBuilt, CStringGetDatum(), dbname, heap_copytuple(), HeapTupleIsValid, sort-test::key, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by InitPostgres().
Definition at line 144 of file postinit.c.
References AccessShareLock, BTEqualStrategyNumber, criticalSharedRelcachesBuilt, heap_copytuple(), HeapTupleIsValid, sort-test::key, ObjectIdGetDatum(), ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by InitPostgres().
|
static |
Definition at line 1369 of file postinit.c.
References IdleInTransactionSessionTimeoutPending, InterruptPending, MyLatch, and SetLatch().
Referenced by InitPostgres().
|
static |
Definition at line 1377 of file postinit.c.
References IdleSessionTimeoutPending, InterruptPending, MyLatch, and SetLatch().
Referenced by InitPostgres().
|
static |
Definition at line 1385 of file postinit.c.
References IdleStatsUpdateTimeoutPending, InterruptPending, MyLatch, and SetLatch().
Referenced by InitPostgres().
void InitializeFastPathLocks | ( | void | ) |
Definition at line 577 of file postinit.c.
References Assert, FastPathLockGroupsPerBackend, FP_LOCK_GROUPS_PER_BACKEND_MAX, FP_LOCK_SLOTS_PER_GROUP, and max_locks_per_xact.
Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().
void InitializeMaxBackends | ( | void | ) |
Definition at line 545 of file postinit.c.
References Assert, autovacuum_max_workers, ereport, errcode(), errdetail(), errmsg(), ERROR, MAX_BACKENDS, max_wal_senders, max_worker_processes, MaxBackends, MaxConnections, and NUM_SPECIAL_WORKER_PROCS.
Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().
void InitPostgres | ( | const char * | in_dbname, |
Oid | dboid, | ||
const char * | username, | ||
Oid | useroid, | ||
bits32 | flags, | ||
char * | out_dbname | ||
) |
Definition at line 700 of file postinit.c.
References am_db_walsender, am_walsender, AmAutoVacuumLauncherProcess, AmAutoVacuumWorkerProcess, AmBackgroundWorkerProcess, AmLogicalSlotSyncWorkerProcess, AmRegularBackendProcess, Assert, ClientConnectionInfo::auth_method, ClientConnectionInfo::authn_id, before_shmem_exit(), CheckDeadLockAlert(), CheckMyDatabase(), CLIENT_CONNECTION_CHECK_TIMEOUT, ClientCheckTimeoutHandler(), CommitTransactionCommand(), CreateAuxProcessResourceOwner(), CurrentResourceOwner, database_is_invalid_form(), PGPROC::databaseId, dbname, DEADLOCK_TIMEOUT, DEBUG3, elog, EnablePortalManager(), ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg(), FATAL, GetDatabasePath(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetSessionUserId(), GETSTRUCT, GetUserId(), has_privs_of_role(), has_rolreplication(), HaveNFreeProcs(), hba_authname(), HeapTupleIsValid, IDLE_IN_TRANSACTION_SESSION_TIMEOUT, IDLE_SESSION_TIMEOUT, IDLE_STATS_UPDATE_TIMEOUT, IdleInTransactionSessionTimeoutHandler(), IdleSessionTimeoutHandler(), IdleStatsUpdateTimeoutHandler(), INIT_PG_LOAD_SESSION_LIBS, INIT_PG_OVERRIDE_ALLOW_CONNS, INIT_PG_OVERRIDE_ROLE_LOGIN, InitCatalogCache(), initialize_acl(), InitializeClientEncoding(), InitializeSearchPath(), InitializeSession(), InitializeSessionUserId(), InitializeSessionUserIdStandalone(), InitializeSystemUser(), InitPlanCache(), InitProcessPhase2(), InvalidateCatalogSnapshot(), IsBinaryUpgrade, IsBootstrapProcessingMode, IsUnderPostmaster, LOCK_TIMEOUT, LockSharedObject(), LockTimeoutHandler(), MyCancelKey, MyCancelKeyValid, MyClientConnectionInfo, MyDatabaseHasLoginEventTriggers, MyDatabaseId, MyDatabaseTableSpace, MyProc, MyProcPort, NAMEDATALEN, NameStr, namestrcmp(), OidIsValid, PerformAuthentication(), pfree(), pg_usleep(), pgstat_before_server_shutdown(), pgstat_beinit(), pgstat_bestart(), PostAuthDelay, process_session_preload_libraries(), process_settings(), process_startup_options(), ProcSignalInit(), RegisterTimeout(), RelationCacheInitialize(), RelationCacheInitializePhase2(), RelationCacheInitializePhase3(), ReleaseAuxProcessResources(), ReservedConnections, RowExclusiveLock, SetCurrentStatementStartTimestamp(), SetDatabasePath(), SharedInvalBackendInit(), ShutdownPostgres(), ShutdownXLOG(), StartTransactionCommand(), StartupXLOG(), STATEMENT_TIMEOUT, StatementTimeoutHandler(), strlcpy(), superuser(), SuperuserReservedConnections, ThereIsAtLeastOneRole(), TRANSACTION_TIMEOUT, TransactionTimeoutHandler(), username, ValidatePgVersion(), WARNING, XACT_READ_COMMITTED, and XactIsoLevel.
Referenced by AutoVacWorkerMain(), BackgroundWorkerInitializeConnection(), BackgroundWorkerInitializeConnectionByOid(), BootstrapModeMain(), PostgresMain(), and ReplSlotSyncWorkerMain().
|
static |
Definition at line 1351 of file postinit.c.
References kill, and MyProcPid.
Referenced by InitPostgres().
|
static |
Definition at line 190 of file postinit.c.
References _, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_walsender, appendStringInfo(), AuthenticationTimeout, be_gssapi_get_auth(), be_gssapi_get_delegation(), be_gssapi_get_enc(), be_gssapi_get_princ(), be_tls_get_cipher(), be_tls_get_cipher_bits(), be_tls_get_version(), ClientAuthentication(), ClientAuthInProgress, StringInfoData::data, disable_timeout(), enable_timeout_after(), ereport, errmsg(), errmsg_internal(), FATAL, HbaFileName, initStringInfo(), load_hba(), load_ident(), LOG, Log_connections, pfree(), port, PostmasterContext, set_ps_display(), STATEMENT_TIMEOUT, and TopMemoryContext.
Referenced by InitPostgres().
void pg_split_opts | ( | char ** | argv, |
int * | argcp, | ||
const char * | optstr | ||
) |
Definition at line 487 of file postinit.c.
References appendStringInfoChar(), StringInfoData::data, initStringInfo(), pfree(), pstrdup(), and resetStringInfo().
Referenced by process_startup_options().
Definition at line 1278 of file postinit.c.
References AccessShareLock, ApplySetting(), GetCatalogSnapshot(), InvalidOid, IsUnderPostmaster, PGC_S_DATABASE, PGC_S_DATABASE_USER, PGC_S_GLOBAL, PGC_S_USER, RegisterSnapshot(), table_close(), table_open(), and UnregisterSnapshot().
Referenced by InitPostgres().
|
static |
Definition at line 1213 of file postinit.c.
References Assert, av, lfirst, list_head(), lnext(), name, palloc(), pg_split_opts(), PGC_BACKEND, PGC_S_CLIENT, PGC_SU_BACKEND, port, process_postgres_switches(), SetConfigOption(), and value.
Referenced by InitPostgres().
|
static |
Definition at line 1312 of file postinit.c.
References AbortOutOfAnyTransaction(), LockReleaseAll(), and USER_LOCKMETHOD.
Referenced by InitPostgres().
|
static |
Definition at line 1329 of file postinit.c.
References ClientAuthInProgress, kill, MyProcPid, and sig.
Referenced by InitPostgres().
|
static |
Definition at line 1404 of file postinit.c.
References AccessShareLock, ForwardScanDirection, heap_getnext(), table_beginscan_catalog(), table_close(), table_endscan(), and table_open().
Referenced by InitPostgres().
|
static |
Definition at line 1361 of file postinit.c.
References InterruptPending, MyLatch, SetLatch(), and TransactionTimeoutPending.
Referenced by InitPostgres().