MCPcopy Create free account
hub / github.com/apache/cloudberry / InitPostgres

Function InitPostgres

src/backend/utils/init/postinit.c:667–1497  ·  view source on GitHub ↗

-------------------------------- * InitPostgres * Initialize POSTGRES. * * The database can be specified by name, using the in_dbname parameter, or by * OID, using the dboid parameter. In the latter case, the actual database * name can be returned to the caller in out_dbname. If out_dbname isn't * NULL, it must point to a buffer of size NAMEDATALEN. * * Similarly, the username can be p

Source from the content-addressed store, hash-verified

665 * --------------------------------
666 */
667void
668InitPostgres(const char *in_dbname, Oid dboid, const char *username,
669 Oid useroid, char *out_dbname, bool override_allow_connections)
670{
671 bool bootstrap = IsBootstrapProcessingMode();
672 bool am_superuser;
673 char *fullpath;
674 char dbname[NAMEDATALEN];
675
676 elog(DEBUG3, "InitPostgres");
677
678 /*
679 * Add my PGPROC struct to the ProcArray.
680 *
681 * Once I have done this, I am visible to other backends!
682 */
683 InitProcessPhase2();
684
685 /* Initialize SessionState entry */
686 SessionState_Init();
687 /* Initialize memory protection */
688 GPMemoryProtect_Init();
689
690
691
692 /*
693 * Initialize my entry in the shared-invalidation manager's array of
694 * per-backend data.
695 *
696 * Sets up MyBackendId, a unique backend identifier.
697 */
698 MyBackendId = InvalidBackendId;
699
700 SharedInvalBackendInit(false);
701
702 if (MyBackendId > MaxBackends || MyBackendId <= 0)
703 elog(FATAL, "bad backend ID: %d", MyBackendId);
704
705 /* Now that we have a BackendId, we can participate in ProcSignal */
706 ProcSignalInit(MyBackendId);
707
708 /*
709 * Also set up timeout handlers needed for backend operation. We need
710 * these in every case except bootstrap.
711 */
712 if (!bootstrap)
713 {
714 RegisterTimeout(DEADLOCK_TIMEOUT, CheckDeadLockAlert);
715 RegisterTimeout(STATEMENT_TIMEOUT, StatementTimeoutHandler);
716 RegisterTimeout(LOCK_TIMEOUT, LockTimeoutHandler);
717 RegisterTimeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT,
718 IdleInTransactionSessionTimeoutHandler);
719 RegisterTimeout(GANG_TIMEOUT, IdleGangTimeoutHandler);
720 RegisterTimeout(IDLE_SESSION_TIMEOUT, IdleSessionTimeoutHandler);
721 RegisterTimeout(GP_PARALLEL_RETRIEVE_CURSOR_CHECK_TIMEOUT, GpParallelRetrieveCursorCheckTimeoutHandler);
722 RegisterTimeout(CLIENT_CONNECTION_CHECK_TIMEOUT, ClientCheckTimeoutHandler);
723 }
724

Callers 8

PostgresMainFunction · 0.85
LoginMonitorLauncherMainFunction · 0.85
LoginMonitorWorkerMainFunction · 0.85
AutoVacLauncherMainFunction · 0.85
AutoVacWorkerMainFunction · 0.85
BootstrapModeMainFunction · 0.85

Calls 15

InitProcessPhase2Function · 0.85
SessionState_InitFunction · 0.85
GPMemoryProtect_InitFunction · 0.85
SharedInvalBackendInitFunction · 0.85
ProcSignalInitFunction · 0.85
RegisterTimeoutFunction · 0.85
InitBufferPoolBackendFunction · 0.85
RecoveryInProgressFunction · 0.85
StartupXLOGFunction · 0.85
on_shmem_exitFunction · 0.85

Tested by

no test coverage detected