* Over time, this has also become the preferred place for widely known
* resource-limitation stuff, such as work_mem and check_stack_depth().
*
- * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.168 2004/09/06 23:55:34 tgl Exp $
+ * src/include/miscadmin.h
*
* NOTES
* some of the information in this file should be moved to other files.
#ifndef MISCADMIN_H
#define MISCADMIN_H
+#include "pgtime.h" /* for pg_time_t */
-#define PG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
+
+#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
/*****************************************************************************
* course, only if the interrupt holdoff counter is zero). See the
* related code for details.
*
+ * A lost connection is handled similarly, although the loss of connection
+ * does not raise a signal, but is detected when we fail to write to the
+ * socket. If there was a signal for a broken connection, we could make use of
+ * it by setting ClientConnectionLost in the signal handler.
+ *
* A related, but conceptually distinct, mechanism is the "critical section"
* mechanism. A critical section not only holds off cancel/die interrupts,
* but causes any ereport(ERROR) or ereport(FATAL) to become ereport(PANIC)
/* in globals.c */
/* these are marked volatile because they are set by signal handlers: */
-extern DLLIMPORT volatile bool InterruptPending;
+extern PGDLLIMPORT volatile bool InterruptPending;
extern volatile bool QueryCancelPending;
extern volatile bool ProcDiePending;
+extern volatile bool ClientConnectionLost;
+
/* these are marked volatile because they are examined by signal handlers: */
extern volatile bool ImmediateInterruptOK;
-extern volatile uint32 InterruptHoldoffCount;
-extern volatile uint32 CritSectionCount;
+extern PGDLLIMPORT volatile uint32 InterruptHoldoffCount;
+extern PGDLLIMPORT volatile uint32 CritSectionCount;
/* in tcop/postgres.c */
extern void ProcessInterrupts(void);
if (InterruptPending) \
ProcessInterrupts(); \
} while(0)
-
#else /* WIN32 */
#define CHECK_FOR_INTERRUPTS() \
do { \
- if (WaitForSingleObjectEx(pgwin32_signal_event,0,TRUE) == WAIT_OBJECT_0) \
+ if (UNBLOCKED_SIGNAL_QUEUE()) \
pgwin32_dispatch_queued_signals(); \
if (InterruptPending) \
ProcessInterrupts(); \
*/
extern pid_t PostmasterPid;
extern bool IsPostmasterEnvironment;
-extern bool IsUnderPostmaster;
+extern PGDLLIMPORT bool IsUnderPostmaster;
+extern bool IsBinaryUpgrade;
extern bool ExitOnAnyError;
-extern char *DataDir;
+extern PGDLLIMPORT char *DataDir;
-extern DLLIMPORT int NBuffers;
+extern PGDLLIMPORT int NBuffers;
extern int MaxBackends;
+extern int MaxConnections;
-extern DLLIMPORT int MyProcPid;
-extern struct Port *MyProcPort;
+extern PGDLLIMPORT int MyProcPid;
+extern PGDLLIMPORT pg_time_t MyStartTime;
+extern PGDLLIMPORT struct Port *MyProcPort;
extern long MyCancelKey;
+extern int MyPMChildSlot;
extern char OutputFileName[];
-extern char my_exec_path[];
+extern PGDLLIMPORT char my_exec_path[];
extern char pkglib_path[];
#ifdef EXEC_BACKEND
*
* extern BackendId MyBackendId;
*/
-extern DLLIMPORT Oid MyDatabaseId;
+extern PGDLLIMPORT Oid MyDatabaseId;
-extern DLLIMPORT Oid MyDatabaseTableSpace;
+extern PGDLLIMPORT Oid MyDatabaseTableSpace;
/*
* Date/Time Configuration
#define USE_ISO_DATES 1
#define USE_SQL_DATES 2
#define USE_GERMAN_DATES 3
+#define USE_XSD_DATES 4
/* valid DateOrder values */
#define DATEORDER_YMD 0
extern int DateStyle;
extern int DateOrder;
+/*
+ * IntervalStyles
+ * INTSTYLE_POSTGRES Like Postgres < 8.4 when DateStyle = 'iso'
+ * INTSTYLE_POSTGRES_VERBOSE Like Postgres < 8.4 when DateStyle != 'iso'
+ * INTSTYLE_SQL_STANDARD SQL standard interval literals
+ * INTSTYLE_ISO_8601 ISO-8601-basic formatted intervals
+ */
+#define INTSTYLE_POSTGRES 0
+#define INTSTYLE_POSTGRES_VERBOSE 1
+#define INTSTYLE_SQL_STANDARD 2
+#define INTSTYLE_ISO_8601 3
+
+extern int IntervalStyle;
+
/*
* HasCTZSet is true if user has set timezone as a numeric offset from UTC.
* If so, CTimeZone is the timezone offset in seconds (using the Unix-ish
extern bool enableFsync;
extern bool allowSystemTableMods;
-extern DLLIMPORT int work_mem;
-extern DLLIMPORT int maintenance_work_mem;
+extern PGDLLIMPORT int work_mem;
+extern PGDLLIMPORT int maintenance_work_mem;
extern int VacuumCostPageHit;
extern int VacuumCostPageMiss;
extern int VacuumCostLimit;
extern int VacuumCostDelay;
+extern int VacuumPageHit;
+extern int VacuumPageMiss;
+extern int VacuumPageDirty;
+
extern int VacuumCostBalance;
extern bool VacuumCostActive;
/* in tcop/postgres.c */
+
+#if defined(__ia64__) || defined(__ia64)
+typedef struct
+{
+ char *stack_base_ptr;
+ char *register_stack_base_ptr;
+} pg_stack_base_t;
+#else
+typedef char *pg_stack_base_t;
+#endif
+
+extern pg_stack_base_t set_stack_base(void);
+extern void restore_stack_base(pg_stack_base_t base);
extern void check_stack_depth(void);
+/* in tcop/utility.c */
+extern void PreventCommandIfReadOnly(const char *cmdname);
+extern void PreventCommandDuringRecovery(const char *cmdname);
+
+/* in utils/misc/guc.c */
+extern int trace_recovery_messages;
+extern int trace_recovery(int trace_level);
/*****************************************************************************
* pdir.h -- *
* POSTGRES directory path definitions. *
*****************************************************************************/
-extern char *DatabasePath;
+/* flags to be OR'd to form sec_context */
+#define SECURITY_LOCAL_USERID_CHANGE 0x0001
+#define SECURITY_RESTRICTED_OPERATION 0x0002
-/* in utils/misc/database.c */
-extern void GetRawDatabaseInfo(const char *name, Oid *db_id, Oid *db_tablespace);
+extern char *DatabasePath;
/* now in utils/init/miscinit.c */
extern void SetDatabasePath(const char *path);
-extern char *GetUserNameFromId(AclId userid);
-extern AclId GetUserId(void);
-extern void SetUserId(AclId userid);
-extern AclId GetSessionUserId(void);
-extern void SetSessionUserId(AclId userid);
-extern void InitializeSessionUserId(const char *username);
+extern char *GetUserNameFromId(Oid roleid);
+extern Oid GetUserId(void);
+extern Oid GetOuterUserId(void);
+extern Oid GetSessionUserId(void);
+extern void GetUserIdAndSecContext(Oid *userid, int *sec_context);
+extern void SetUserIdAndSecContext(Oid userid, int sec_context);
+extern bool InLocalUserIdChange(void);
+extern bool InSecurityRestrictedOperation(void);
+extern void GetUserIdAndContext(Oid *userid, bool *sec_def_context);
+extern void SetUserIdAndContext(Oid userid, bool sec_def_context);
+extern void InitializeSessionUserId(const char *rolename);
extern void InitializeSessionUserIdStandalone(void);
-extern void SetSessionAuthorization(AclId userid, bool is_superuser);
+extern void SetSessionAuthorization(Oid userid, bool is_superuser);
+extern Oid GetCurrentRoleId(void);
+extern void SetCurrentRoleId(Oid roleid, bool is_superuser);
extern void SetDataDir(const char *dir);
+extern void ChangeToDataDir(void);
+extern char *make_absolute_path(const char *path);
/* in utils/misc/superuser.c */
extern bool superuser(void); /* current user is superuser */
-extern bool superuser_arg(AclId userid); /* given user is superuser */
+extern bool superuser_arg(Oid roleid); /* given user is superuser */
/*****************************************************************************
*****************************************************************************/
/* in utils/init/postinit.c */
-extern void InitPostgres(const char *dbname, const char *username);
+extern void pg_split_opts(char **argv, int *argcp, char *optstr);
+extern void InitPostgres(const char *in_dbname, Oid dboid, const char *username,
+ char *out_dbname);
extern void BaseInit(void);
/* in utils/init/miscinit.c */
-extern void IgnoreSystemIndexes(bool mode);
-extern bool IsIgnoringSystemIndexes(void);
-extern void SetReindexProcessing(Oid heapOid, Oid indexOid);
-extern void ResetReindexProcessing(void);
-extern bool ReindexIsProcessingHeap(Oid heapOid);
-extern bool ReindexIsProcessingIndex(Oid indexOid);
-extern void CreateDataDirLockFile(const char *datadir, bool amPostmaster);
+extern bool IgnoreSystemIndexes;
+extern PGDLLIMPORT bool process_shared_preload_libraries_in_progress;
+extern char *shared_preload_libraries_string;
+extern char *local_preload_libraries_string;
+
+/*
+ * As of 9.1, the contents of the data-directory lock file are:
+ *
+ * line #
+ * 1 postmaster PID (or negative of a standalone backend's PID)
+ * 2 data directory path
+ * 3 postmaster start timestamp (time_t representation)
+ * 4 port number
+ * 5 socket directory path (empty on Windows)
+ * 6 first listen_address (IP address or "*"; empty if no TCP port)
+ * 7 shared memory key (not present on Windows)
+ *
+ * Lines 6 and up are added via AddToDataDirLockFile() after initial file
+ * creation; they have to be ordered according to time of addition.
+ *
+ * The socket lock file, if used, has the same contents as lines 1-5.
+ */
+#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
+
+extern void CreateDataDirLockFile(bool amPostmaster);
extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster);
extern void TouchSocketLockFile(void);
-extern void RecordSharedMemoryInLockFile(unsigned long id1,
- unsigned long id2);
+extern void AddToDataDirLockFile(int target_line, const char *str);
extern void ValidatePgVersion(const char *path);
-extern void process_preload_libraries(char *preload_libraries_string);
+extern void process_shared_preload_libraries(void);
+extern void process_local_preload_libraries(void);
+extern void pg_bindtextdomain(const char *domain);
+extern bool is_authenticated_user_replication_role(void);
+
+/* in access/transam/xlog.c */
+extern bool BackupInProgress(void);
+extern void CancelBackup(void);
#endif /* MISCADMIN_H */