Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Typedefs | Enumerations | Functions | Variables

miscadmin.h File Reference

#include "pgtime.h"
Include dependency graph for miscadmin.h:

Go to the source code of this file.

Defines

#define PG_BACKEND_VERSIONSTR   "postgres (PostgreSQL) " PG_VERSION "\n"
#define CHECK_FOR_INTERRUPTS()
#define HOLD_INTERRUPTS()   (InterruptHoldoffCount++)
#define RESUME_INTERRUPTS()
#define START_CRIT_SECTION()   (CritSectionCount++)
#define END_CRIT_SECTION()
#define USE_POSTGRES_DATES   0
#define USE_ISO_DATES   1
#define USE_SQL_DATES   2
#define USE_GERMAN_DATES   3
#define USE_XSD_DATES   4
#define DATEORDER_YMD   0
#define DATEORDER_DMY   1
#define DATEORDER_MDY   2
#define INTSTYLE_POSTGRES   0
#define INTSTYLE_POSTGRES_VERBOSE   1
#define INTSTYLE_SQL_STANDARD   2
#define INTSTYLE_ISO_8601   3
#define MAXTZLEN   10
#define SECURITY_LOCAL_USERID_CHANGE   0x0001
#define SECURITY_RESTRICTED_OPERATION   0x0002
#define IsBootstrapProcessingMode()   (Mode == BootstrapProcessing)
#define IsInitProcessingMode()   (Mode == InitProcessing)
#define IsNormalProcessingMode()   (Mode == NormalProcessing)
#define GetProcessingMode()   Mode
#define SetProcessingMode(mode)
#define AmBootstrapProcess()   (MyAuxProcType == BootstrapProcess)
#define AmStartupProcess()   (MyAuxProcType == StartupProcess)
#define AmBackgroundWriterProcess()   (MyAuxProcType == BgWriterProcess)
#define AmCheckpointerProcess()   (MyAuxProcType == CheckpointerProcess)
#define AmWalWriterProcess()   (MyAuxProcType == WalWriterProcess)
#define AmWalReceiverProcess()   (MyAuxProcType == WalReceiverProcess)
#define LOCK_FILE_LINE_PID   1
#define LOCK_FILE_LINE_DATA_DIR   2
#define LOCK_FILE_LINE_START_TIME   3
#define LOCK_FILE_LINE_PORT   4
#define LOCK_FILE_LINE_SOCKET_DIR   5
#define LOCK_FILE_LINE_LISTEN_ADDR   6
#define LOCK_FILE_LINE_SHMEM_KEY   7

Typedefs

typedef char * pg_stack_base_t
typedef enum ProcessingMode ProcessingMode

Enumerations

enum  ProcessingMode { BootstrapProcessing, InitProcessing, NormalProcessing }
enum  AuxProcType {
  NotAnAuxProcess = -1, CheckerProcess = 0, BootstrapProcess, StartupProcess,
  BgWriterProcess, CheckpointerProcess, WalWriterProcess, WalReceiverProcess,
  NUM_AUXPROCTYPES
}

Functions

void ProcessInterrupts (void)
pg_stack_base_t set_stack_base (void)
void restore_stack_base (pg_stack_base_t base)
void check_stack_depth (void)
void PreventCommandIfReadOnly (const char *cmdname)
void PreventCommandDuringRecovery (const char *cmdname)
int trace_recovery (int trace_level)
void SetDatabasePath (const char *path)
char * GetUserNameFromId (Oid roleid)
Oid GetUserId (void)
Oid GetOuterUserId (void)
Oid GetSessionUserId (void)
void GetUserIdAndSecContext (Oid *userid, int *sec_context)
void SetUserIdAndSecContext (Oid userid, int sec_context)
bool InLocalUserIdChange (void)
bool InSecurityRestrictedOperation (void)
void GetUserIdAndContext (Oid *userid, bool *sec_def_context)
void SetUserIdAndContext (Oid userid, bool sec_def_context)
void InitializeSessionUserId (const char *rolename)
void InitializeSessionUserIdStandalone (void)
void SetSessionAuthorization (Oid userid, bool is_superuser)
Oid GetCurrentRoleId (void)
void SetCurrentRoleId (Oid roleid, bool is_superuser)
void SetDataDir (const char *dir)
void ChangeToDataDir (void)
char * make_absolute_path (const char *path)
bool superuser (void)
bool superuser_arg (Oid roleid)
void pg_split_opts (char **argv, int *argcp, char *optstr)
void InitializeMaxBackends (void)
void InitPostgres (const char *in_dbname, Oid dboid, const char *username, char *out_dbname)
void BaseInit (void)
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)
void ValidatePgVersion (const char *path)
void process_shared_preload_libraries (void)
void process_local_preload_libraries (void)
void pg_bindtextdomain (const char *domain)
bool has_rolreplication (Oid roleid)
bool BackupInProgress (void)
void CancelBackup (void)

Variables

PGDLLIMPORT volatile bool InterruptPending
volatile bool QueryCancelPending
volatile bool ProcDiePending
volatile bool ClientConnectionLost
volatile bool ImmediateInterruptOK
PGDLLIMPORT volatile uint32 InterruptHoldoffCount
PGDLLIMPORT volatile uint32 CritSectionCount
pid_t PostmasterPid
bool IsPostmasterEnvironment
PGDLLIMPORT bool IsUnderPostmaster
bool IsBackgroundWorker
bool IsBinaryUpgrade
bool ExitOnAnyError
PGDLLIMPORT char * DataDir
PGDLLIMPORT int NBuffers
int MaxBackends
int MaxConnections
PGDLLIMPORT int MyProcPid
PGDLLIMPORT pg_time_t MyStartTime
PGDLLIMPORT struct PortMyProcPort
long MyCancelKey
int MyPMChildSlot
char OutputFileName []
PGDLLIMPORT char my_exec_path []
char pkglib_path []
PGDLLIMPORT Oid MyDatabaseId
PGDLLIMPORT Oid MyDatabaseTableSpace
int DateStyle
int DateOrder
int IntervalStyle
bool HasCTZSet
int CTimeZone
bool enableFsync
bool allowSystemTableMods
PGDLLIMPORT int work_mem
PGDLLIMPORT int maintenance_work_mem
int VacuumCostPageHit
int VacuumCostPageMiss
int VacuumCostPageDirty
int VacuumCostLimit
int VacuumCostDelay
int VacuumPageHit
int VacuumPageMiss
int VacuumPageDirty
int VacuumCostBalance
bool VacuumCostActive
int trace_recovery_messages
char * DatabasePath
ProcessingMode Mode
AuxProcType MyAuxProcType
bool IgnoreSystemIndexes
PGDLLIMPORT bool process_shared_preload_libraries_in_progress
char * shared_preload_libraries_string
char * local_preload_libraries_string

Define Documentation

#define AmBackgroundWriterProcess (  )     (MyAuxProcType == BgWriterProcess)

Definition at line 384 of file miscadmin.h.

Referenced by ForwardFsyncRequest().

#define AmBootstrapProcess (  )     (MyAuxProcType == BootstrapProcess)

Definition at line 382 of file miscadmin.h.

#define AmCheckpointerProcess (  )     (MyAuxProcType == CheckpointerProcess)
#define AmStartupProcess (  )     (MyAuxProcType == StartupProcess)

Definition at line 383 of file miscadmin.h.

Referenced by mdinit().

#define AmWalReceiverProcess (  )     (MyAuxProcType == WalReceiverProcess)

Definition at line 387 of file miscadmin.h.

Referenced by get_sync_bit().

#define AmWalWriterProcess (  )     (MyAuxProcType == WalWriterProcess)

Definition at line 386 of file miscadmin.h.

#define CHECK_FOR_INTERRUPTS (  ) 
Value:
do { \
    if (InterruptPending) \
        ProcessInterrupts(); \
} while(0)

Definition at line 90 of file miscadmin.h.

Referenced by _bt_buildadd(), _bt_steppage(), _bt_walk_left(), _hash_metapinit(), _hash_readnext(), _hash_readprev(), add_path(), analyze_rel(), ATRewriteTable(), backend_read_statsfile(), btree_xlog_delete_get_latestRemovedXid(), calculate_database_size(), calculate_relation_size(), calculate_tablespace_size(), ClientAuthentication(), cluster_rel(), copy_file(), copy_heap_data(), copy_relation_data(), copydir(), CopyFrom(), CopyTo(), count_nondeletable_pages(), CountOtherDBBackends(), db_dir_size(), do_autovacuum(), do_pg_stop_backup(), errfinish(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), exec_stmt(), exec_stmts(), ExecHashJoin(), ExecMakeTableFunctionResult(), ExecProcNode(), ExecScan(), fsm_vacuum_page(), GetNewOidWithIndex(), GetNewRelFileNode(), getNextNearest(), ginbuild(), ginBuildCallback(), gingetbitmap(), ginInsertCleanup(), gistgetbitmap(), gistgettuple(), gistProcessItup(), HandleCatchupInterrupt(), HandleFunctionRequest(), HandleNotifyInterrupt(), heap_lock_updated_tuple_rec(), heapgetpage(), IndexBuildHeapScan(), IndexCheckExclusion(), lazy_truncate_heap(), make_bounded_heap(), md5_crypt_verify(), MultiExecBitmapIndexScan(), MultiExecProcNode(), numeric_fac(), pg_sleep(), PGSemaphoreLock(), pgstat_collect_oids(), pgstat_get_backend_current_activity(), pgstat_heap(), pgstat_index(), pgstat_read_current_status(), pgstat_vacuum_stat(), pgstatindex(), plperl_spi_prepare(), PortalRunMulti(), postgresAcquireSampleRowsFunc(), predicate_implied_by_simple_clause(), predicate_refuted_by_simple_clause(), prepare_for_client_read(), ProcessWalRcvInterrupts(), puttuple_common(), refresh_matview_datafill(), replace_text(), replace_text_regexp(), RequestCheckpoint(), sendDir(), spgdoinsert(), spgWalk(), storeQueryResult(), text_to_array_internal(), tuplesort_heap_insert(), tuplesort_heap_siftup(), vacuum_delay_point(), vacuum_rel(), validate_index_heapscan(), and WalSndLoop().

#define DATEORDER_DMY   1
#define DATEORDER_MDY   2

Definition at line 200 of file miscadmin.h.

Referenced by check_datestyle(), and setup_config().

#define DATEORDER_YMD   0

Definition at line 198 of file miscadmin.h.

Referenced by check_datestyle(), DecodeNumber(), and setup_config().

#define END_CRIT_SECTION (  ) 
#define GetProcessingMode (  )     Mode

Definition at line 349 of file miscadmin.h.

#define HOLD_INTERRUPTS (  )     (InterruptHoldoffCount++)
#define INTSTYLE_ISO_8601   3

Definition at line 215 of file miscadmin.h.

Referenced by EncodeInterval().

#define INTSTYLE_POSTGRES   0

Definition at line 212 of file miscadmin.h.

Referenced by EncodeInterval(), and set_transmission_modes().

#define INTSTYLE_POSTGRES_VERBOSE   1

Definition at line 213 of file miscadmin.h.

Referenced by EncodeInterval().

#define INTSTYLE_SQL_STANDARD   2

Definition at line 214 of file miscadmin.h.

Referenced by DecodeInterval(), and EncodeInterval().

#define IsBootstrapProcessingMode (  )     (Mode == BootstrapProcessing)
#define IsInitProcessingMode (  )     (Mode == InitProcessing)

Definition at line 346 of file miscadmin.h.

Referenced by BackgroundWorkerInitializeConnection().

#define IsNormalProcessingMode (  )     (Mode == NormalProcessing)

Definition at line 347 of file miscadmin.h.

Referenced by heap_create_with_catalog(), index_constraint_create(), and index_create().

#define LOCK_FILE_LINE_DATA_DIR   2

Definition at line 426 of file miscadmin.h.

#define LOCK_FILE_LINE_LISTEN_ADDR   6

Definition at line 430 of file miscadmin.h.

Referenced by PostmasterMain(), and test_postmaster_connection().

#define LOCK_FILE_LINE_PID   1

Definition at line 425 of file miscadmin.h.

Referenced by test_postmaster_connection().

#define LOCK_FILE_LINE_PORT   4

Definition at line 428 of file miscadmin.h.

Referenced by get_sock_dir(), and test_postmaster_connection().

#define LOCK_FILE_LINE_SHMEM_KEY   7

Definition at line 431 of file miscadmin.h.

Referenced by InternalIpcMemoryCreate().

#define LOCK_FILE_LINE_SOCKET_DIR   5

Definition at line 429 of file miscadmin.h.

Referenced by get_sock_dir(), PostmasterMain(), and test_postmaster_connection().

#define LOCK_FILE_LINE_START_TIME   3

Definition at line 427 of file miscadmin.h.

Referenced by test_postmaster_connection().

#define MAXTZLEN   10

Definition at line 228 of file miscadmin.h.

Referenced by abstime2tm(), and EncodeDateTime().

#define PG_BACKEND_VERSIONSTR   "postgres (PostgreSQL) " PG_VERSION "\n"

Definition at line 29 of file miscadmin.h.

Referenced by adjust_data_dir(), do_start(), getInstallationPaths(), and setup_bin_paths().

#define RESUME_INTERRUPTS (  ) 
#define SECURITY_LOCAL_USERID_CHANGE   0x0001
#define SECURITY_RESTRICTED_OPERATION   0x0002
#define SetProcessingMode (   mode  ) 
#define START_CRIT_SECTION (  )     (CritSectionCount++)
#define USE_GERMAN_DATES   3

Definition at line 194 of file miscadmin.h.

Referenced by check_datestyle(), EncodeDateOnly(), and EncodeDateTime().

#define USE_ISO_DATES   1
#define USE_POSTGRES_DATES   0

Definition at line 191 of file miscadmin.h.

Referenced by check_datestyle(), EncodeDateOnly(), and EncodeDateTime().

#define USE_SQL_DATES   2

Definition at line 193 of file miscadmin.h.

Referenced by check_datestyle(), EncodeDateOnly(), and EncodeDateTime().

#define USE_XSD_DATES   4

Typedef Documentation

typedef char* pg_stack_base_t

Definition at line 258 of file miscadmin.h.


Enumeration Type Documentation

Enumerator:
NotAnAuxProcess 
CheckerProcess 
BootstrapProcess 
StartupProcess 
BgWriterProcess 
CheckpointerProcess 
WalWriterProcess 
WalReceiverProcess 
NUM_AUXPROCTYPES 

Definition at line 366 of file miscadmin.h.

{
    NotAnAuxProcess = -1,
    CheckerProcess = 0,
    BootstrapProcess,
    StartupProcess,
    BgWriterProcess,
    CheckpointerProcess,
    WalWriterProcess,
    WalReceiverProcess,

    NUM_AUXPROCTYPES            /* Must be last! */
} AuxProcType;

Enumerator:
BootstrapProcessing 
InitProcessing 
NormalProcessing 

Definition at line 336 of file miscadmin.h.

{
    BootstrapProcessing,        /* bootstrap creation of template database */
    InitProcessing,             /* initializing system */
    NormalProcessing            /* normal processing */
} ProcessingMode;


Function Documentation

void AddToDataDirLockFile ( int  target_line,
const char *  str 
)
bool BackupInProgress ( void   ) 

Definition at line 9284 of file xlog.c.

References BACKUP_LABEL_FILE.

Referenced by pg_is_in_backup(), and PostmasterStateMachine().

{
    struct stat stat_buf;

    return (stat(BACKUP_LABEL_FILE, &stat_buf) == 0);
}

void BaseInit ( void   ) 

Definition at line 460 of file postinit.c.

References DebugFileOpen(), InitBufferPoolAccess(), InitCommunication(), InitFileAccess(), and smgrinit().

Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), AuxiliaryProcessMain(), do_start_bgworker(), and PostgresMain().

{
    /*
     * Attach to shared memory and semaphores, and initialize our
     * input/output/debugging file descriptors.
     */
    InitCommunication();
    DebugFileOpen();

    /* Do local initialization of file, storage and buffer managers */
    InitFileAccess();
    smgrinit();
    InitBufferPoolAccess();
}

void CancelBackup ( void   ) 

Definition at line 9299 of file xlog.c.

References BACKUP_LABEL_FILE, BACKUP_LABEL_OLD, ereport, errcode_for_file_access(), errdetail(), errmsg(), LOG, unlink(), and WARNING.

Referenced by PostmasterStateMachine().

{
    struct stat stat_buf;

    /* if the file is not there, return */
    if (stat(BACKUP_LABEL_FILE, &stat_buf) < 0)
        return;

    /* remove leftover file from previously canceled backup if it exists */
    unlink(BACKUP_LABEL_OLD);

    if (rename(BACKUP_LABEL_FILE, BACKUP_LABEL_OLD) == 0)
    {
        ereport(LOG,
                (errmsg("online backup mode canceled"),
                 errdetail("\"%s\" was renamed to \"%s\".",
                           BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
    }
    else
    {
        ereport(WARNING,
                (errcode_for_file_access(),
                 errmsg("online backup mode was not canceled"),
                 errdetail("Could not rename \"%s\" to \"%s\": %m.",
                           BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
    }
}

void ChangeToDataDir ( void   ) 

Definition at line 109 of file miscinit.c.

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

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

{
    AssertState(DataDir);

    if (chdir(DataDir) < 0)
        ereport(FATAL,
                (errcode_for_file_access(),
                 errmsg("could not change directory to \"%s\": %m",
                        DataDir)));
}

void check_stack_depth ( void   ) 

Definition at line 3051 of file postgres.c.

References ereport, errcode(), errhint(), errmsg(), ERROR, max_stack_depth, max_stack_depth_bytes, NULL, and stack_base_ptr.

Referenced by addone(), clean_fakeval_intree(), clean_NOT_intree(), cntsize(), contains_required_value(), copyObject(), Cover(), dofindsubquery(), EventTriggerInvoke(), ExecInitExpr(), ExecMakeFunctionResult(), ExecMakeFunctionResultNoSets(), execute(), expression_tree_mutator(), expression_tree_walker(), fillQT(), findoprnd_recurse(), freetree(), infix(), inline_set_returning_function(), JumbleExpr(), makepol(), plainnode(), plperl_hash_from_tuple(), plperl_sv_to_datum(), QT2QTN(), QTNBinary(), QTNClearFlags(), QTNCopy(), QTNFree(), QTNodeCompare(), QTNSort(), QTNTernary(), raw_expression_tree_walker(), split_array(), transformExprRecurse(), transformSetOperationTree(), TS_execute(), tsquery_opr_selec(), and tsquery_requires_match().

{
    char        stack_top_loc;
    long        stack_depth;

    /*
     * Compute distance from reference point to my local variables
     */
    stack_depth = (long) (stack_base_ptr - &stack_top_loc);

    /*
     * Take abs value, since stacks grow up on some machines, down on others
     */
    if (stack_depth < 0)
        stack_depth = -stack_depth;

    /*
     * Trouble?
     *
     * The test on stack_base_ptr prevents us from erroring out if called
     * during process setup or in a non-backend process.  Logically it should
     * be done first, but putting it here avoids wasting cycles during normal
     * cases.
     */
    if (stack_depth > max_stack_depth_bytes &&
        stack_base_ptr != NULL)
    {
        ereport(ERROR,
                (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
                 errmsg("stack depth limit exceeded"),
                 errhint("Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
              "after ensuring the platform's stack depth limit is adequate.",
                         max_stack_depth)));
    }

    /*
     * On IA64 there is a separate "register" stack that requires its own
     * independent check.  For this, we have to measure the change in the
     * "BSP" pointer from PostgresMain to here.  Logic is just as above,
     * except that we know IA64's register stack grows up.
     *
     * Note we assume that the same max_stack_depth applies to both stacks.
     */
#if defined(__ia64__) || defined(__ia64)
    stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);

    if (stack_depth > max_stack_depth_bytes &&
        register_stack_base_ptr != NULL)
    {
        ereport(ERROR,
                (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
                 errmsg("stack depth limit exceeded"),
                 errhint("Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
              "after ensuring the platform's stack depth limit is adequate.",
                         max_stack_depth)));
    }
#endif   /* IA64 */
}

void CreateDataDirLockFile ( bool  amPostmaster  ) 

Definition at line 972 of file miscinit.c.

References CreateLockFile(), DataDir, and DIRECTORY_LOCK_FILE.

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

{
    CreateLockFile(DIRECTORY_LOCK_FILE, amPostmaster, "", true, DataDir);
}

void CreateSocketLockFile ( const char *  socketfile,
bool  amPostmaster,
const char *  socketDir 
)

Definition at line 981 of file miscinit.c.

References CreateLockFile(), and snprintf().

{
    char        lockfile[MAXPGPATH];

    snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
    CreateLockFile(lockfile, amPostmaster, socketDir, false, socketfile);
}

Oid GetCurrentRoleId ( void   ) 

Definition at line 555 of file miscinit.c.

References OuterUserId, and SetRoleIsActive.

Referenced by show_role().

{
    if (SetRoleIsActive)
        return OuterUserId;
    else
        return InvalidOid;
}

Oid GetOuterUserId ( void   ) 

Definition at line 252 of file miscinit.c.

References AssertState, OidIsValid, and OuterUserId.

Referenced by DropRole(), and RenameRole().

Oid GetSessionUserId ( void   ) 
Oid GetUserId ( void   ) 

Definition at line 241 of file miscinit.c.

References AssertState, CurrentUserId, and OidIsValid.

Referenced by AddRoleMems(), AggregateCreate(), AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseSet(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOpFamilyAdd(), AlterRole(), AlterRoleSet(), AlterSchemaOwner_internal(), AlterSequence(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTSDictionary(), AlterTypeNamespace_oid(), AlterTypeOwner(), analyze_rel(), ATExecAddColumn(), ATExecChangeOwner(), ATPrepAlterColumnType(), ATPrepSetStatistics(), ATPrepSetTableSpace(), ATSimplePermissions(), BuildDescForRelation(), calculate_database_size(), calculate_tablespace_size(), check_temp_tablespaces(), checkDomainOwner(), checkEnumOwner(), checkFkeyPermissions(), CheckMyDatabase(), CheckRelationOwnership(), cluster_rel(), CommentObject(), compile_plperl_function(), compile_pltcl_function(), compute_return_type(), create_empty_extension(), CreateCast(), CreateConversionCommand(), createdb(), CreateEventTrigger(), CreateExtension(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateFunction(), CreateOpFamily(), CreateProceduralLanguage(), CreateRole(), CreateTableSpace(), 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_pg_start_backup(), do_pg_stop_backup(), do_setval(), dropdb(), DropOwnedObjects(), DropRole(), DropTableSpace(), EnableDisableRule(), examine_parameter_list(), ExecAlterDefaultPrivilegesStmt(), ExecAlterExtensionContentsStmt(), ExecAlterExtensionStmt(), ExecCheckRTEPerms(), ExecEvalArrayCoerceExpr(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecInitWindowAgg(), ExecSecLabelStmt(), ExecuteDoStmt(), ExecuteTruncate(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), FinishPreparedTransaction(), get_connect_string(), get_other_operator(), get_rel_from_relname(), get_tables_to_cluster(), GetUserOidFromMapping(), 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(), init_fcache(), InitializeSearchPath(), InitPostgres(), InitTempTableNamespace(), inline_function(), inline_set_returning_function(), insert_username(), inv_create(), LargeObjectCreate(), lastval(), lo_read(), lo_truncate_internal(), lo_unlink(), lo_write(), LockTableAclCheck(), lookup_agg_function(), LookupCreationNamespace(), LookupExplicitNamespace(), MergeAttributes(), movedb(), nextval_internal(), OperatorCreate(), OperatorShellMake(), pg_has_role_id(), pg_has_role_name(), 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_waiting(), pg_stat_get_backend_xact_start(), pg_stat_statements(), pgrowlocks(), pgss_store(), pgstat_get_backend_current_activity(), pltcl_fetch_interp(), postgresBeginForeignModify(), postgresBeginForeignScan(), postgresGetForeignRelSize(), PrepareTempTablespaces(), PrepareTransaction(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReassignOwnedObjects(), recomputeNamespacePath(), ReindexDatabase(), RemoveObjects(), renameatt_check(), RenameDatabase(), RenameSchema(), RenameTableSpace(), RenameType(), select_perl_context(), superuser(), timetravel(), transformTableLikeClause(), truncate_check_rel(), user_mapping_ddl_aclcheck(), and vacuum_rel().

void GetUserIdAndContext ( Oid userid,
bool sec_def_context 
)

Definition at line 369 of file miscinit.c.

References CurrentUserId, and InLocalUserIdChange().

{
    *userid = CurrentUserId;
    *sec_def_context = InLocalUserIdChange();
}

void GetUserIdAndSecContext ( Oid userid,
int *  sec_context 
)
char* GetUserNameFromId ( Oid  roleid  ) 

Definition at line 610 of file miscinit.c.

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

Referenced by check_is_member_of_role(), current_user(), getObjectDescription(), getObjectIdentity(), insert_username(), session_user(), and timetravel().

{
    HeapTuple   tuple;
    char       *result;

    tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
    if (!HeapTupleIsValid(tuple))
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("invalid role OID: %u", roleid)));

    result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));

    ReleaseSysCache(tuple);
    return result;
}

bool has_rolreplication ( Oid  roleid  ) 

Definition at line 396 of file miscinit.c.

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

Referenced by do_pg_start_backup(), do_pg_stop_backup(), and InitPostgres().

{
    bool        result = false;
    HeapTuple   utup;

    utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
    if (HeapTupleIsValid(utup))
    {
        result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
        ReleaseSysCache(utup);
    }
    return result;
}

void InitializeMaxBackends ( void   ) 

Definition at line 438 of file postinit.c.

References Assert, autovacuum_max_workers, elog, ERROR, GetNumShmemAttachedBgworkers(), MAX_BACKENDS, MaxBackends, and MaxConnections.

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

{
    Assert(MaxBackends == 0);

    /* the extra unit accounts for the autovacuum launcher */
    MaxBackends = MaxConnections + autovacuum_max_workers + 1 +
        GetNumShmemAttachedBgworkers();

    /* internal error because the values were all checked previously */
    if (MaxBackends > MAX_BACKENDS)
        elog(ERROR, "too many backends configured");
}

void InitializeSessionUserId ( const char *  rolename  ) 

Definition at line 414 of file miscinit.c.

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

Referenced by InitPostgres().

{
    HeapTuple   roleTup;
    Form_pg_authid rform;
    Oid         roleid;

    /*
     * Don't do scans if we're bootstrapping, none of the system catalogs
     * exist yet, and they should be owned by postgres anyway.
     */
    AssertState(!IsBootstrapProcessingMode());

    /* call only once */
    AssertState(!OidIsValid(AuthenticatedUserId));

    roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(rolename));
    if (!HeapTupleIsValid(roleTup))
        ereport(FATAL,
                (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
                 errmsg("role \"%s\" does not exist", rolename)));

    rform = (Form_pg_authid) GETSTRUCT(roleTup);
    roleid = HeapTupleGetOid(roleTup);

    AuthenticatedUserId = roleid;
    AuthenticatedUserIsSuperuser = rform->rolsuper;

    /* This sets OuterUserId/CurrentUserId too */
    SetSessionUserId(roleid, AuthenticatedUserIsSuperuser);

    /* Also mark our PGPROC entry with the authenticated user id */
    /* (We assume this is an atomic store so no lock is needed) */
    MyProc->roleId = roleid;

    /*
     * These next checks are not enforced when in standalone mode, so that
     * there is a way to recover from sillinesses like "UPDATE pg_authid SET
     * rolcanlogin = false;".
     */
    if (IsUnderPostmaster)
    {
        /*
         * Is role allowed to login at all?
         */
        if (!rform->rolcanlogin)
            ereport(FATAL,
                    (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
                     errmsg("role \"%s\" is not permitted to log in",
                            rolename)));

        /*
         * Check connection limit for this role.
         *
         * There is a race condition here --- we create our PGPROC before
         * checking for other PGPROCs.  If two backends did this at about the
         * same time, they might both think they were over the limit, while
         * ideally one should succeed and one fail.  Getting that to work
         * exactly seems more trouble than it is worth, however; instead we
         * just document that the connection limit is approximate.
         */
        if (rform->rolconnlimit >= 0 &&
            !AuthenticatedUserIsSuperuser &&
            CountUserBackends(roleid) > rform->rolconnlimit)
            ereport(FATAL,
                    (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
                     errmsg("too many connections for role \"%s\"",
                            rolename)));
    }

    /* Record username and superuser status as GUC settings too */
    SetConfigOption("session_authorization", rolename,
                    PGC_BACKEND, PGC_S_OVERRIDE);
    SetConfigOption("is_superuser",
                    AuthenticatedUserIsSuperuser ? "on" : "off",
                    PGC_INTERNAL, PGC_S_OVERRIDE);

    ReleaseSysCache(roleTup);
}

void InitializeSessionUserIdStandalone ( void   ) 

Definition at line 498 of file miscinit.c.

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

Referenced by InitPostgres().

{
    /*
     * This function should only be called in single-user mode, in
     * autovacuum workers, and in background workers.
     */
    AssertState(!IsUnderPostmaster || IsAutoVacuumWorkerProcess() || IsBackgroundWorker);

    /* call only once */
    AssertState(!OidIsValid(AuthenticatedUserId));

    AuthenticatedUserId = BOOTSTRAP_SUPERUSERID;
    AuthenticatedUserIsSuperuser = true;

    SetSessionUserId(BOOTSTRAP_SUPERUSERID, true);
}

void InitPostgres ( const char *  in_dbname,
Oid  dboid,
const char *  username,
char *  out_dbname 
)

Definition at line 498 of file postinit.c.

References am_walsender, Assert, CAC_WAITBACKUP, Port::canAcceptConnections, CheckDeadLock(), CheckMyDatabase(), CommitTransactionCommand(), PGPROC::databaseId, DatabaseRelationId, DEADLOCK_TIMEOUT, DEBUG3, elog, EnablePortalManager(), ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg(), FATAL, GetDatabasePath(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetSessionUserId(), GETSTRUCT, GetTransactionSnapshot(), GetUserId(), has_rolreplication(), HaveNFreeProcs(), HeapTupleGetOid, HeapTupleIsValid, InitBufferPoolBackend(), InitCatalogCache(), initialize_acl(), InitializeClientEncoding(), InitializeSearchPath(), InitializeSessionUserId(), InitializeSessionUserIdStandalone(), InitPlanCache(), InitProcessPhase2(), IsAutoVacuumLauncherProcess(), IsAutoVacuumWorkerProcess(), IsBackgroundWorker, IsBinaryUpgrade, IsBootstrapProcessingMode, IsUnderPostmaster, LOCK_TIMEOUT, LockSharedObject(), LockTimeoutHandler(), MaxBackends, MyBackendId, MyDatabaseId, MyDatabaseTableSpace, MyProc, MyProcPort, NameStr, NULL, on_shmem_exit(), PerformAuthentication(), pg_usleep(), pgstat_bestart(), pgstat_initialize(), PostAuthDelay, process_settings(), process_startup_options(), ProcSignalInit(), RecoveryInProgress(), RegisterTimeout(), RelationCacheInitialize(), RelationCacheInitializePhase2(), RelationCacheInitializePhase3(), ReservedBackends, RowExclusiveLock, SetCurrentStatementStartTimestamp(), SetDatabasePath(), SharedInvalBackendInit(), ShutdownPostgres(), ShutdownXLOG(), StartTransactionCommand(), StartupXLOG(), STATEMENT_TIMEOUT, StatementTimeoutHandler(), strlcpy(), superuser(), ThereIsAtLeastOneRole(), ValidatePgVersion(), WARNING, and XactIsoLevel.

Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWorkerInitializeConnection(), BootstrapModeMain(), and PostgresMain().

{
    bool        bootstrap = IsBootstrapProcessingMode();
    bool        am_superuser;
    char       *fullpath;
    char        dbname[NAMEDATALEN];

    elog(DEBUG3, "InitPostgres");

    /*
     * Add my PGPROC struct to the ProcArray.
     *
     * Once I have done this, I am visible to other backends!
     */
    InitProcessPhase2();

    /*
     * Initialize my entry in the shared-invalidation manager's array of
     * per-backend data.
     *
     * Sets up MyBackendId, a unique backend identifier.
     */
    MyBackendId = InvalidBackendId;

    SharedInvalBackendInit(false);

    if (MyBackendId > MaxBackends || MyBackendId <= 0)
        elog(FATAL, "bad backend ID: %d", MyBackendId);

    /* Now that we have a BackendId, we can participate in ProcSignal */
    ProcSignalInit(MyBackendId);

    /*
     * Also set up timeout handlers needed for backend operation.  We need
     * these in every case except bootstrap.
     */
    if (!bootstrap)
    {
        RegisterTimeout(DEADLOCK_TIMEOUT, CheckDeadLock);
        RegisterTimeout(STATEMENT_TIMEOUT, StatementTimeoutHandler);
        RegisterTimeout(LOCK_TIMEOUT, LockTimeoutHandler);
    }

    /*
     * bufmgr needs another initialization call too
     */
    InitBufferPoolBackend();

    /*
     * Initialize local process's access to XLOG.
     */
    if (IsUnderPostmaster)
    {
        /*
         * The postmaster already started the XLOG machinery, but we need to
         * call InitXLOGAccess(), if the system isn't in hot-standby mode.
         * This is handled by calling RecoveryInProgress and ignoring the
         * result.
         */
        (void) RecoveryInProgress();
    }
    else
    {
        /*
         * We are either a bootstrap process or a standalone backend. Either
         * way, start up the XLOG machinery, and register to have it closed
         * down at exit.
         */
        StartupXLOG();
        on_shmem_exit(ShutdownXLOG, 0);
    }

    /*
     * Initialize the relation cache and the system catalog caches.  Note that
     * no catalog access happens here; we only set up the hashtable structure.
     * We must do this before starting a transaction because transaction abort
     * would try to touch these hashtables.
     */
    RelationCacheInitialize();
    InitCatalogCache();
    InitPlanCache();

    /* Initialize portal manager */
    EnablePortalManager();

    /* Initialize stats collection --- must happen before first xact */
    if (!bootstrap)
        pgstat_initialize();

    /*
     * Load relcache entries for the shared system catalogs.  This must create
     * at least entries for pg_database and catalogs used for authentication.
     */
    RelationCacheInitializePhase2();

    /*
     * Set up process-exit callback to do pre-shutdown cleanup.  This has to
     * be after we've initialized all the low-level modules like the buffer
     * manager, because during shutdown this has to run before the low-level
     * modules start to close down.  On the other hand, we want it in place
     * before we begin our first transaction --- if we fail during the
     * initialization transaction, as is entirely possible, we need the
     * AbortTransaction call to clean up.
     */
    on_shmem_exit(ShutdownPostgres, 0);

    /* The autovacuum launcher is done here */
    if (IsAutoVacuumLauncherProcess())
        return;

    /*
     * Start a new transaction here before first access to db, and get a
     * snapshot.  We don't have a use for the snapshot itself, but we're
     * interested in the secondary effect that it sets RecentGlobalXmin. (This
     * is critical for anything that reads heap pages, because HOT may decide
     * to prune them even if the process doesn't attempt to modify any
     * tuples.)
     */
    if (!bootstrap)
    {
        /* statement_timestamp must be set for timeouts to work correctly */
        SetCurrentStatementStartTimestamp();
        StartTransactionCommand();

        /*
         * transaction_isolation will have been set to the default by the
         * above.  If the default is "serializable", and we are in hot
         * standby, we will fail if we don't change it to something lower.
         * Fortunately, "read committed" is plenty good enough.
         */
        XactIsoLevel = XACT_READ_COMMITTED;

        (void) GetTransactionSnapshot();
    }

    /*
     * Perform client authentication if necessary, then figure out our
     * postgres user ID, and see if we are a superuser.
     *
     * In standalone mode and in autovacuum worker processes, we use a fixed
     * ID, otherwise we figure it out from the authenticated user name.
     */
    if (bootstrap || IsAutoVacuumWorkerProcess())
    {
        InitializeSessionUserIdStandalone();
        am_superuser = true;
    }
    else if (!IsUnderPostmaster)
    {
        InitializeSessionUserIdStandalone();
        am_superuser = true;
        if (!ThereIsAtLeastOneRole())
            ereport(WARNING,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("no roles are defined in this database system"),
                     errhint("You should immediately run CREATE USER \"%s\" SUPERUSER;.",
                             username)));
    }
    else if (IsBackgroundWorker)
    {
        if (username == NULL)
        {
            InitializeSessionUserIdStandalone();
            am_superuser = true;
        }
        else
        {
            InitializeSessionUserId(username);
            am_superuser = superuser();
        }
    }
    else
    {
        /* normal multiuser case */
        Assert(MyProcPort != NULL);
        PerformAuthentication(MyProcPort);
        InitializeSessionUserId(username);
        am_superuser = superuser();
    }

    /*
     * If we're trying to shut down, only superusers can connect, and new
     * replication connections are not allowed.
     */
    if ((!am_superuser || am_walsender) &&
        MyProcPort != NULL &&
        MyProcPort->canAcceptConnections == CAC_WAITBACKUP)
    {
        if (am_walsender)
            ereport(FATAL,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                     errmsg("new replication connections are not allowed during database shutdown")));
        else
            ereport(FATAL,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
            errmsg("must be superuser to connect during database shutdown")));
    }

    /*
     * Binary upgrades only allowed super-user connections
     */
    if (IsBinaryUpgrade && !am_superuser)
    {
        ereport(FATAL,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
             errmsg("must be superuser to connect in binary upgrade mode")));
    }

    /*
     * The last few connections slots are reserved for superusers. Although
     * replication connections currently require superuser privileges, we
     * don't allow them to consume the reserved slots, which are intended for
     * interactive use.
     */
    if ((!am_superuser || am_walsender) &&
        ReservedBackends > 0 &&
        !HaveNFreeProcs(ReservedBackends))
        ereport(FATAL,
                (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
                 errmsg("remaining connection slots are reserved for non-replication superuser connections")));

    /*
     * If walsender, we don't want to connect to any particular database. Just
     * finish the backend startup by processing any options from the startup
     * packet, and we're done.
     */
    if (am_walsender)
    {
        Assert(!bootstrap);

        if (!superuser() && !has_rolreplication(GetUserId()))
            ereport(FATAL,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                     errmsg("must be superuser or replication role to start walsender")));

        /* process any options passed in the startup packet */
        if (MyProcPort != NULL)
            process_startup_options(MyProcPort, am_superuser);

        /* Apply PostAuthDelay as soon as we've read all options */
        if (PostAuthDelay > 0)
            pg_usleep(PostAuthDelay * 1000000L);

        /* initialize client encoding */
        InitializeClientEncoding();

        /* report this backend in the PgBackendStatus array */
        pgstat_bestart();

        /* close the transaction we started above */
        CommitTransactionCommand();

        return;
    }

    /*
     * Set up the global variables holding database id and default tablespace.
     * But note we won't actually try to touch the database just yet.
     *
     * We take a shortcut in the bootstrap case, otherwise we have to look up
     * the db's entry in pg_database.
     */
    if (bootstrap)
    {
        MyDatabaseId = TemplateDbOid;
        MyDatabaseTableSpace = DEFAULTTABLESPACE_OID;
    }
    else if (in_dbname != NULL)
    {
        HeapTuple   tuple;
        Form_pg_database dbform;

        tuple = GetDatabaseTuple(in_dbname);
        if (!HeapTupleIsValid(tuple))
            ereport(FATAL,
                    (errcode(ERRCODE_UNDEFINED_DATABASE),
                     errmsg("database \"%s\" does not exist", in_dbname)));
        dbform = (Form_pg_database) GETSTRUCT(tuple);
        MyDatabaseId = HeapTupleGetOid(tuple);
        MyDatabaseTableSpace = dbform->dattablespace;
        /* take database name from the caller, just for paranoia */
        strlcpy(dbname, in_dbname, sizeof(dbname));
    }
    else
    {
        /* caller specified database by OID */
        HeapTuple   tuple;
        Form_pg_database dbform;

        tuple = GetDatabaseTupleByOid(dboid);
        if (!HeapTupleIsValid(tuple))
            ereport(FATAL,
                    (errcode(ERRCODE_UNDEFINED_DATABASE),
                     errmsg("database %u does not exist", dboid)));
        dbform = (Form_pg_database) GETSTRUCT(tuple);
        MyDatabaseId = HeapTupleGetOid(tuple);
        MyDatabaseTableSpace = dbform->dattablespace;
        Assert(MyDatabaseId == dboid);
        strlcpy(dbname, NameStr(dbform->datname), sizeof(dbname));
        /* pass the database name back to the caller */
        if (out_dbname)
            strcpy(out_dbname, dbname);
    }

    /* Now we can mark our PGPROC entry with the database ID */
    /* (We assume this is an atomic store so no lock is needed) */
    MyProc->databaseId = MyDatabaseId;

    /*
     * Now, take a writer's lock on the database we are trying to connect to.
     * If there is a concurrently running DROP DATABASE on that database, this
     * will block us until it finishes (and has committed its update of
     * pg_database).
     *
     * Note that the lock is not held long, only until the end of this startup
     * transaction.  This is OK since we are already advertising our use of
     * the database in the PGPROC array; anyone trying a DROP DATABASE after
     * this point will see us there.
     *
     * Note: use of RowExclusiveLock here is reasonable because we envision
     * our session as being a concurrent writer of the database.  If we had a
     * way of declaring a session as being guaranteed-read-only, we could use
     * AccessShareLock for such sessions and thereby not conflict against
     * CREATE DATABASE.
     */
    if (!bootstrap)
        LockSharedObject(DatabaseRelationId, MyDatabaseId, 0,
                         RowExclusiveLock);

    /*
     * Recheck pg_database to make sure the target database hasn't gone away.
     * If there was a concurrent DROP DATABASE, this ensures we will die
     * cleanly without creating a mess.
     */
    if (!bootstrap)
    {
        HeapTuple   tuple;

        tuple = GetDatabaseTuple(dbname);
        if (!HeapTupleIsValid(tuple) ||
            MyDatabaseId != HeapTupleGetOid(tuple) ||
            MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace)
            ereport(FATAL,
                    (errcode(ERRCODE_UNDEFINED_DATABASE),
                     errmsg("database \"%s\" does not exist", dbname),
               errdetail("It seems to have just been dropped or renamed.")));
    }

    /*
     * Now we should be able to access the database directory safely. Verify
     * it's there and looks reasonable.
     */
    fullpath = GetDatabasePath(MyDatabaseId, MyDatabaseTableSpace);

    if (!bootstrap)
    {
        if (access(fullpath, F_OK) == -1)
        {
            if (errno == ENOENT)
                ereport(FATAL,
                        (errcode(ERRCODE_UNDEFINED_DATABASE),
                         errmsg("database \"%s\" does not exist",
                                dbname),
                    errdetail("The database subdirectory \"%s\" is missing.",
                              fullpath)));
            else
                ereport(FATAL,
                        (errcode_for_file_access(),
                         errmsg("could not access directory \"%s\": %m",
                                fullpath)));
        }

        ValidatePgVersion(fullpath);
    }

    SetDatabasePath(fullpath);

    /*
     * It's now possible to do real access to the system catalogs.
     *
     * Load relcache entries for the system catalogs.  This must create at
     * least the minimum set of "nailed-in" cache entries.
     */
    RelationCacheInitializePhase3();

    /* set up ACL framework (so CheckMyDatabase can check permissions) */
    initialize_acl();

    /*
     * Re-read the pg_database row for our database, check permissions and set
     * up database-specific GUC settings.  We can't do this until all the
     * database-access infrastructure is up.  (Also, it wants to know if the
     * user is a superuser, so the above stuff has to happen first.)
     */
    if (!bootstrap)
        CheckMyDatabase(dbname, am_superuser);

    /*
     * Now process any command-line switches and any additional GUC variable
     * settings passed in the startup packet.   We couldn't do this before
     * because we didn't know if client is a superuser.
     */
    if (MyProcPort != NULL)
        process_startup_options(MyProcPort, am_superuser);

    /* Process pg_db_role_setting options */
    process_settings(MyDatabaseId, GetSessionUserId());

    /* Apply PostAuthDelay as soon as we've read all options */
    if (PostAuthDelay > 0)
        pg_usleep(PostAuthDelay * 1000000L);

    /*
     * Initialize various default states that can't be set up until we've
     * selected the active user and gotten the right GUC settings.
     */

    /* set default namespace search path */
    InitializeSearchPath();

    /* initialize client encoding */
    InitializeClientEncoding();

    /* report this backend in the PgBackendStatus array */
    if (!bootstrap)
        pgstat_bestart();

    /* close the transaction we started above */
    if (!bootstrap)
        CommitTransactionCommand();
}

bool InLocalUserIdChange ( void   ) 
bool InSecurityRestrictedOperation ( void   ) 
char* make_absolute_path ( const char *  path  ) 

Definition at line 131 of file miscinit.c.

References buf, canonicalize_path(), elog, ereport, errcode(), errmsg(), FATAL, free, is_absolute_path, malloc, and NULL.

Referenced by regression_main(), SelectConfigFiles(), and SetDataDir().

{
    char       *new;

    /* Returning null for null input is convenient for some callers */
    if (path == NULL)
        return NULL;

    if (!is_absolute_path(path))
    {
        char       *buf;
        size_t      buflen;

        buflen = MAXPGPATH;
        for (;;)
        {
            buf = malloc(buflen);
            if (!buf)
                ereport(FATAL,
                        (errcode(ERRCODE_OUT_OF_MEMORY),
                         errmsg("out of memory")));

            if (getcwd(buf, buflen))
                break;
            else if (errno == ERANGE)
            {
                free(buf);
                buflen *= 2;
                continue;
            }
            else
            {
                free(buf);
                elog(FATAL, "could not get current working directory: %m");
            }
        }

        new = malloc(strlen(buf) + strlen(path) + 2);
        if (!new)
            ereport(FATAL,
                    (errcode(ERRCODE_OUT_OF_MEMORY),
                     errmsg("out of memory")));
        sprintf(new, "%s/%s", buf, path);
        free(buf);
    }
    else
    {
        new = strdup(path);
        if (!new)
            ereport(FATAL,
                    (errcode(ERRCODE_OUT_OF_MEMORY),
                     errmsg("out of memory")));
    }

    /* Make sure punctuation is canonical, too */
    canonicalize_path(new);

    return new;
}

void pg_bindtextdomain ( const char *  domain  ) 

Definition at line 1329 of file miscinit.c.

References get_locale_path(), my_exec_path, and pg_bind_textdomain_codeset().

Referenced by _PG_init().

{
#ifdef ENABLE_NLS
    if (my_exec_path[0] != '\0')
    {
        char        locale_path[MAXPGPATH];

        get_locale_path(my_exec_path, locale_path);
        bindtextdomain(domain, locale_path);
        pg_bind_textdomain_codeset(domain);
    }
#endif
}

void pg_split_opts ( char **  argv,
int *  argcp,
char *  optstr 
)

Definition at line 409 of file postinit.c.

Referenced by BackendRun(), and process_startup_options().

{
    while (*optstr)
    {
        while (isspace((unsigned char) *optstr))
            optstr++;
        if (*optstr == '\0')
            break;
        argv[(*argcp)++] = optstr;
        while (*optstr && !isspace((unsigned char) *optstr))
            optstr++;
        if (*optstr)
            *optstr++ = '\0';
    }
}

void PreventCommandDuringRecovery ( const char *  cmdname  ) 

Definition at line 282 of file utility.c.

References ereport, errcode(), errmsg(), ERROR, and RecoveryInProgress().

Referenced by LockTableCommand(), pg_notify(), standard_ProcessUtility(), and txid_current().

{
    if (RecoveryInProgress())
        ereport(ERROR,
                (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
        /* translator: %s is name of a SQL command, eg CREATE */
                 errmsg("cannot execute %s during recovery",
                        cmdname)));
}

void PreventCommandIfReadOnly ( const char *  cmdname  ) 

Definition at line 263 of file utility.c.

References ereport, errcode(), errmsg(), ERROR, and XactReadOnly.

Referenced by check_xact_readonly(), do_setval(), DoCopy(), ExecCheckXactReadOnly(), and nextval_internal().

{
    if (XactReadOnly)
        ereport(ERROR,
                (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
        /* translator: %s is name of a SQL command, eg CREATE */
                 errmsg("cannot execute %s in a read-only transaction",
                        cmdname)));
}

void process_local_preload_libraries ( void   ) 

Definition at line 1321 of file miscinit.c.

References load_libraries(), and local_preload_libraries_string.

Referenced by PostgresMain().

{
    load_libraries(local_preload_libraries_string,
                   "local_preload_libraries",
                   true);
}

void process_shared_preload_libraries ( void   ) 
void ProcessInterrupts ( void   ) 
void restore_stack_base ( pg_stack_base_t  base  ) 

Definition at line 3032 of file postgres.c.

References stack_base_ptr.

{
#if defined(__ia64__) || defined(__ia64)
    stack_base_ptr = base.stack_base_ptr;
    register_stack_base_ptr = base.register_stack_base_ptr;
#else
    stack_base_ptr = base;
#endif
}

pg_stack_base_t set_stack_base ( void   ) 

Definition at line 3001 of file postgres.c.

References stack_base_ptr.

Referenced by PostmasterMain().

{
    char        stack_base;
    pg_stack_base_t old;

#if defined(__ia64__) || defined(__ia64)
    old.stack_base_ptr = stack_base_ptr;
    old.register_stack_base_ptr = register_stack_base_ptr;
#else
    old = stack_base_ptr;
#endif

    /* Set up reference point for stack depth checking */
    stack_base_ptr = &stack_base;
#if defined(__ia64__) || defined(__ia64)
    register_stack_base_ptr = ia64_get_bsp();
#endif

    return old;
}

void SetCurrentRoleId ( Oid  roleid,
bool  is_superuser 
)

Definition at line 576 of file miscinit.c.

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

Referenced by assign_role().

{
    /*
     * Get correct info if it's SET ROLE NONE
     *
     * If SessionUserId hasn't been set yet, just do nothing --- the eventual
     * SetSessionUserId call will fix everything.  This is needed since we
     * will get called during GUC initialization.
     */
    if (!OidIsValid(roleid))
    {
        if (!OidIsValid(SessionUserId))
            return;

        roleid = SessionUserId;
        is_superuser = SessionUserIsSuperuser;

        SetRoleIsActive = false;
    }
    else
        SetRoleIsActive = true;

    SetOuterUserId(roleid);

    SetConfigOption("is_superuser",
                    is_superuser ? "on" : "off",
                    PGC_INTERNAL, PGC_S_OVERRIDE);
}

void SetDatabasePath ( const char *  path  ) 

Definition at line 76 of file miscinit.c.

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

Referenced by InitPostgres().

{
    /* This should happen only once per process */
    Assert(!DatabasePath);
    DatabasePath = MemoryContextStrdup(TopMemoryContext, path);
}

void SetDataDir ( const char *  dir  ) 

Definition at line 88 of file miscinit.c.

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

Referenced by SelectConfigFiles().

{
    char       *new;

    AssertArg(dir);

    /* If presented path is relative, convert to absolute */
    new = make_absolute_path(dir);

    if (DataDir)
        free(DataDir);
    DataDir = new;
}

void SetSessionAuthorization ( Oid  userid,
bool  is_superuser 
)

Definition at line 530 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().

{
    /* Must have authenticated already, else can't make permission check */
    AssertState(OidIsValid(AuthenticatedUserId));

    if (userid != AuthenticatedUserId &&
        !AuthenticatedUserIsSuperuser)
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("permission denied to set session authorization")));

    SetSessionUserId(userid, is_superuser);

    SetConfigOption("is_superuser",
                    is_superuser ? "on" : "off",
                    PGC_INTERNAL, PGC_S_OVERRIDE);
}

void SetUserIdAndContext ( Oid  userid,
bool  sec_def_context 
)

Definition at line 376 of file miscinit.c.

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

{
    /* We throw the same error SET ROLE would. */
    if (InSecurityRestrictedOperation())
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("cannot set parameter \"%s\" within security-restricted operation",
                        "role")));
    CurrentUserId = userid;
    if (sec_def_context)
        SecurityRestrictionContext |= SECURITY_LOCAL_USERID_CHANGE;
    else
        SecurityRestrictionContext &= ~SECURITY_LOCAL_USERID_CHANGE;
}

void SetUserIdAndSecContext ( Oid  userid,
int  sec_context 
)
bool superuser ( void   ) 

Definition at line 47 of file superuser.c.

References GetUserId(), and superuser_arg().

Referenced by AddRoleMems(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOpFamily(), AlterRole(), AlterRoleSet(), AlterTypeOwner(), ATExecChangeOwner(), bt_metap(), bt_page_items(), bt_page_stats(), check_conn_params(), check_encoding_locale_matches(), connect_pg_server(), CreateCast(), CreateEventTrigger(), CreateForeignDataWrapper(), CreateFunction(), CreateProceduralLanguage(), CreateRole(), CreateTableSpace(), dblink_connstr_check(), dblink_security_check(), DefineAggregate(), DefineOpClass(), DefineOpFamily(), DefineTSParser(), DefineTSTemplate(), DefineType(), DelRoleMems(), do_pg_start_backup(), do_pg_stop_backup(), DoCopy(), DropRole(), dummy_object_relabel(), EnableDisableTrigger(), ExecSetVariableStmt(), execute_extension_script(), ExecuteDoStmt(), file_fdw_validator(), fmgr_security_definer(), fsm_page_contents(), get_raw_page_internal(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionByNum(), GetConfigOptionResetString(), GUCArrayReset(), have_createdb_privilege(), heap_page_items(), InitPostgres(), lo_export(), lo_import_internal(), main(), page_header(), pg_create_restore_point(), pg_is_xlog_replay_paused(), pg_logdir_ls(), pg_ls_dir(), pg_read_binary_file(), pg_read_binary_file_all(), pg_read_file(), pg_read_file_all(), pg_reload_conf(), pg_relpages(), pg_rotate_logfile(), pg_signal_backend(), pg_stat_file(), 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_waiting(), pg_stat_get_backend_xact_start(), pg_stat_get_wal_senders(), pg_stat_statements(), pg_switch_xlog(), pg_xlog_replay_pause(), pg_xlog_replay_resume(), pgstat_get_backend_current_activity(), pgstat_reset_counters(), pgstat_reset_shared_counters(), pgstat_reset_single_counter(), pgstatginindex(), pgstatindex(), pgstattuple(), pgstattuplebyid(), ProcedureCreate(), RenameRole(), requireSuperuser(), sepgsql_restorecon(), set_config_by_name(), SetPGVariable(), ShowAllGUCConfig(), standard_ProcessUtility(), and validate_option_array_item().

{
    return superuser_arg(GetUserId());
}

bool superuser_arg ( Oid  roleid  ) 

Definition at line 57 of file superuser.c.

References AUTHOID, BOOTSTRAP_SUPERUSERID, CacheRegisterSyscacheCallback(), GETSTRUCT, HeapTupleIsValid, IsUnderPostmaster, last_roleid, last_roleid_is_super, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), roleid_callback_registered, RoleidCallback(), and SearchSysCache1.

Referenced by AddRoleMems(), AlterEventTriggerOwner_internal(), AlterForeignDataWrapperOwner_internal(), check_object_ownership(), DelRoleMems(), has_createrole_privilege(), has_privs_of_role(), is_admin_of_role(), is_member_of_role(), LockGXact(), pg_class_aclmask(), pg_class_ownercheck(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_database_aclmask(), pg_database_ownercheck(), pg_event_trigger_ownercheck(), pg_extension_ownercheck(), pg_foreign_data_wrapper_aclmask(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_aclmask(), pg_foreign_server_ownercheck(), pg_language_aclmask(), pg_language_ownercheck(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), pg_namespace_aclmask(), pg_namespace_ownercheck(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_tablespace_aclmask(), pg_tablespace_ownercheck(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_aclmask(), pg_type_ownercheck(), pltcl_init_load_unknown(), select_best_grantor(), and superuser().

{
    bool        result;
    HeapTuple   rtup;

    /* Quick out for cache hit */
    if (OidIsValid(last_roleid) && last_roleid == roleid)
        return last_roleid_is_super;

    /* Special escape path in case you deleted all your users. */
    if (!IsUnderPostmaster && roleid == BOOTSTRAP_SUPERUSERID)
        return true;

    /* OK, look up the information in pg_authid */
    rtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
    if (HeapTupleIsValid(rtup))
    {
        result = ((Form_pg_authid) GETSTRUCT(rtup))->rolsuper;
        ReleaseSysCache(rtup);
    }
    else
    {
        /* Report "not superuser" for invalid roleids */
        result = false;
    }

    /* If first time through, set up callback for cache flushes */
    if (!roleid_callback_registered)
    {
        CacheRegisterSyscacheCallback(AUTHOID,
                                      RoleidCallback,
                                      (Datum) 0);
        roleid_callback_registered = true;
    }

    /* Cache the result for next time */
    last_roleid = roleid;
    last_roleid_is_super = result;

    return result;
}

void TouchSocketLockFiles ( void   ) 

Definition at line 999 of file miscinit.c.

References close, DIRECTORY_LOCK_FILE, lfirst, NULL, PG_BINARY, and read.

Referenced by ServerLoop().

{
    ListCell   *l;

    foreach(l, lock_files)
    {
        char       *socketLockFile = (char *) lfirst(l);

        /* No need to touch the data directory lock file, we trust */
        if (strcmp(socketLockFile, DIRECTORY_LOCK_FILE) == 0)
            continue;

        /*
         * utime() is POSIX standard, utimes() is a common alternative; if we
         * have neither, fall back to actually reading the file (which only
         * sets the access time not mod time, but that should be enough in
         * most cases).  In all paths, we ignore errors.
         */
#ifdef HAVE_UTIME
        utime(socketLockFile, NULL);
#else                           /* !HAVE_UTIME */
#ifdef HAVE_UTIMES
        utimes(socketLockFile, NULL);
#else                           /* !HAVE_UTIMES */
        int         fd;
        char        buffer[1];

        fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0);
        if (fd >= 0)
        {
            read(fd, buffer, sizeof(buffer));
            close(fd);
        }
#endif   /* HAVE_UTIMES */
#endif   /* HAVE_UTIME */
    }
}

int trace_recovery ( int  trace_level  ) 
void ValidatePgVersion ( const char *  path  ) 

Definition at line 1162 of file miscinit.c.

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

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

{
    char        full_path[MAXPGPATH];
    FILE       *file;
    int         ret;
    long        file_major,
                file_minor;
    long        my_major = 0,
                my_minor = 0;
    char       *endptr;
    const char *version_string = PG_VERSION;

    my_major = strtol(version_string, &endptr, 10);
    if (*endptr == '.')
        my_minor = strtol(endptr + 1, NULL, 10);

    snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);

    file = AllocateFile(full_path, "r");
    if (!file)
    {
        if (errno == ENOENT)
            ereport(FATAL,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                     errmsg("\"%s\" is not a valid data directory",
                            path),
                     errdetail("File \"%s\" is missing.", full_path)));
        else
            ereport(FATAL,
                    (errcode_for_file_access(),
                     errmsg("could not open file \"%s\": %m", full_path)));
    }

    ret = fscanf(file, "%ld.%ld", &file_major, &file_minor);
    if (ret != 2)
        ereport(FATAL,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                 errmsg("\"%s\" is not a valid data directory",
                        path),
                 errdetail("File \"%s\" does not contain valid data.",
                           full_path),
                 errhint("You might need to initdb.")));

    FreeFile(file);

    if (my_major != file_major || my_minor != file_minor)
        ereport(FATAL,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                 errmsg("database files are incompatible with server"),
                 errdetail("The data directory was initialized by PostgreSQL version %ld.%ld, "
                           "which is not compatible with this version %s.",
                           file_major, file_minor, version_string)));
}


Variable Documentation

Definition at line 31 of file globals.c.

Referenced by internal_flush(), and ProcessInterrupts().

PGDLLIMPORT volatile uint32 CritSectionCount
int CTimeZone
char* DatabasePath
PGDLLIMPORT char* DataDir
int DateOrder
int DateStyle

Definition at line 91 of file globals.c.

Referenced by BackgroundWriterMain(), CheckpointerMain(), and errstart().

PGDLLIMPORT volatile uint32 InterruptHoldoffCount
PGDLLIMPORT volatile bool InterruptPending

Definition at line 86 of file globals.c.

Referenced by errstart(), GetNewObjectId(), pg_re_throw(), PostmasterMain(), and RequestCheckpoint().

PGDLLIMPORT bool IsUnderPostmaster

Definition at line 1226 of file miscinit.c.

Referenced by process_local_preload_libraries().

PGDLLIMPORT int maintenance_work_mem

Definition at line 51 of file miscinit.c.

PGDLLIMPORT char my_exec_path[]

Definition at line 70 of file bootstrap.c.

Referenced by AuxiliaryProcessMain().

PGDLLIMPORT Oid MyDatabaseId

Definition at line 63 of file globals.c.

Referenced by AfterTriggerSetState(), AlterSchemaOwner_internal(), analyze_rel(), asyncQueueNotificationToEntry(), asyncQueueProcessPageEntries(), backend_read_statsfile(), CacheInvalidateCatalog(), CacheInvalidateHeapTuple(), CacheInvalidateRelcache(), CacheInvalidateRelcacheByTuple(), CheckMyDatabase(), checkSharedDependencies(), classIdGetDbId(), CreateProceduralLanguage(), CreateSchemaCommand(), current_database(), database_to_xml_internal(), DeconstructQualifiedName(), do_analyze_rel(), do_autovacuum(), dropdb(), exec_object_restorecon(), ExpandColumnRefStar(), ExportSnapshot(), GetCurrentVirtualXIDs(), GetNewRelFileNode(), GetOldestXmin(), ImportSnapshot(), InitPostgres(), InitTempTableNamespace(), lazy_vacuum_rel(), LocalExecuteInvalidationMessage(), LockDatabaseObject(), LockGXact(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), movedb(), perform_relmap_update(), pg_namespace_aclmask(), pg_relation_filepath(), pgss_store(), pgstat_beshutdown_hook(), pgstat_bestart(), pgstat_fetch_stat_funcentry(), pgstat_fetch_stat_tabentry(), pgstat_report_analyze(), pgstat_report_deadlock(), pgstat_report_recovery_conflict(), pgstat_report_stat(), pgstat_report_tempfile(), pgstat_report_vacuum(), pgstat_reset_counters(), pgstat_reset_single_counter(), pgstat_send_funcstats(), pgstat_vacuum_stat(), PrepareToInvalidateCacheTuple(), PrepareTransaction(), ProcArrayInstallImportedXmin(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetCreationNamespace(), RangeVarGetRelidExtended(), RecordTransactionCommit(), ReindexDatabase(), RelationInitLockInfo(), RelationInitPhysicalAddr(), RelationMapFinishBootstrap(), RenameDatabase(), RenameSchema(), ScanPgRelation(), sepgsql_schema_post_create(), SetLocktagRelationOid(), shdepDropOwned(), shdepReassignOwned(), table_recheck_autovac(), transformColumnRef(), UnlockDatabaseObject(), vac_truncate_clog(), vac_update_datfrozenxid(), and vacuum_rel().

PGDLLIMPORT int MyProcPid
PGDLLIMPORT struct Port* MyProcPort
PGDLLIMPORT pg_time_t MyStartTime
PGDLLIMPORT int NBuffers

Definition at line 52 of file ipc_test.c.

Definition at line 50 of file globals.c.

Referenced by AuxiliaryProcessMain(), DebugFileOpen(), and process_postgres_switches().

char pkglib_path[]

Definition at line 53 of file globals.c.

Referenced by getInstallationPaths(), PostgresMain(), and substitute_libpath_macro().

volatile bool ProcDiePending

Definition at line 1225 of file miscinit.c.

Referenced by process_shared_preload_libraries().

Definition at line 420 of file guc.c.

Referenced by StartupXLOG(), and trace_recovery().

Definition at line 116 of file globals.c.

Referenced by MarkBufferDirty(), and MarkBufferDirtyHint().

Definition at line 114 of file globals.c.

Referenced by ReadBuffer_common().

Definition at line 115 of file globals.c.

Referenced by ReadBuffer_common().

Definition at line 122 of file globals.c.

Referenced by lazy_vacuum_rel(), MarkBufferDirty(), MarkBufferDirtyHint(), and vacuum().

Definition at line 120 of file globals.c.

Referenced by lazy_vacuum_rel(), ReadBuffer_common(), and vacuum().

Definition at line 121 of file globals.c.

Referenced by lazy_vacuum_rel(), ReadBuffer_common(), and vacuum().

PGDLLIMPORT int work_mem