/*-------------------------------------------------------------------------
*
* miscadmin.h
- * this file contains general postgres administration and initialization
+ * This file contains general postgres administration and initialization
* stuff that used to be spread out between the following files:
* globals.h global variables
* pdir.h directory path crud
* pinit.h postgres initialization
* pmod.h processing modes
+ * 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-2002, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.110 2002/09/05 18:28:46 petere Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.201 2008/02/20 22:46:24 tgl Exp $
*
* NOTES
- * some of the information in this file should be moved to
- * other files.
+ * 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_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
/*****************************************************************************
*
* A related, but conceptually distinct, mechanism is the "critical section"
* mechanism. A critical section not only holds off cancel/die interrupts,
- * but causes any elog(ERROR) or elog(FATAL) to become elog(STOP) --- that is,
- * a system-wide reset is forced. Needless to say, only really *critical*
- * code should be marked as a critical section! Currently, this mechanism
- * is only used for XLOG-related code.
+ * but causes any ereport(ERROR) or ereport(FATAL) to become ereport(PANIC)
+ * --- that is, a system-wide reset is forced. Needless to say, only really
+ * *critical* code should be marked as a critical section! Currently, this
+ * mechanism is only used for XLOG-related code.
*
*****************************************************************************/
/* 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;
/* 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 postgres.c */
+/* in tcop/postgres.c */
extern void ProcessInterrupts(void);
+#ifndef WIN32
+
#define CHECK_FOR_INTERRUPTS() \
- do { \
- if (InterruptPending) \
- ProcessInterrupts(); \
- } while(0)
+do { \
+ if (InterruptPending) \
+ ProcessInterrupts(); \
+} while(0)
+#else /* WIN32 */
+
+#define CHECK_FOR_INTERRUPTS() \
+do { \
+ if (UNBLOCKED_SIGNAL_QUEUE()) \
+ pgwin32_dispatch_queued_signals(); \
+ if (InterruptPending) \
+ ProcessInterrupts(); \
+} while(0)
+#endif /* WIN32 */
+
#define HOLD_INTERRUPTS() (InterruptHoldoffCount++)
#define RESUME_INTERRUPTS() \
- do { \
- Assert(InterruptHoldoffCount > 0); \
- InterruptHoldoffCount--; \
- } while(0)
+do { \
+ Assert(InterruptHoldoffCount > 0); \
+ InterruptHoldoffCount--; \
+} while(0)
#define START_CRIT_SECTION() (CritSectionCount++)
#define END_CRIT_SECTION() \
- do { \
- Assert(CritSectionCount > 0); \
- CritSectionCount--; \
- } while(0)
+do { \
+ Assert(CritSectionCount > 0); \
+ CritSectionCount--; \
+} while(0)
/*****************************************************************************
*****************************************************************************/
/*
- * from postmaster/postmaster.c
+ * from utils/init/globals.c
*/
+extern pid_t PostmasterPid;
+extern bool IsPostmasterEnvironment;
extern bool IsUnderPostmaster;
-extern bool ClientAuthInProgress;
-extern int PostmasterMain(int argc, char *argv[]);
-extern void ClosePostmasterPorts(bool pgstat_too);
+extern bool ExitOnAnyError;
-/*
- * from utils/init/globals.c
- */
-extern bool Noversion;
-extern char *DataDir;
+extern PGDLLIMPORT char *DataDir;
-extern DLLIMPORT int MyProcPid;
-extern struct Port *MyProcPort;
+extern PGDLLIMPORT int NBuffers;
+extern int MaxBackends;
+extern int MaxConnections;
+
+extern PGDLLIMPORT int MyProcPid;
+extern PGDLLIMPORT pg_time_t MyStartTime;
+extern PGDLLIMPORT struct Port *MyProcPort;
extern long MyCancelKey;
extern char OutputFileName[];
-extern char pg_pathname[];
+extern PGDLLIMPORT char my_exec_path[];
+extern char pkglib_path[];
+
+#ifdef EXEC_BACKEND
+extern char postgres_exec_path[];
+#endif
/*
* done in storage/backendid.h for now.
*
* extern BackendId MyBackendId;
*/
-extern DLLIMPORT Oid MyDatabaseId;
+extern PGDLLIMPORT Oid MyDatabaseId;
+
+extern PGDLLIMPORT Oid MyDatabaseTableSpace;
-/* Date/Time Configuration
+/*
+ * Date/Time Configuration
+ *
+ * DateStyle defines the output formatting choice for date/time types:
+ * USE_POSTGRES_DATES specifies traditional Postgres format
+ * USE_ISO_DATES specifies ISO-compliant format
+ * USE_SQL_DATES specifies Oracle/Ingres-compliant format
+ * USE_GERMAN_DATES specifies German-style dd.mm/yyyy
*
- * Constants to pass info from runtime environment:
- * USE_POSTGRES_DATES specifies traditional postgres format for output.
- * USE_ISO_DATES specifies ISO-compliant format for output.
- * USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
- * USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
+ * DateOrder defines the field order to be assumed when reading an
+ * ambiguous date (anything not in YYYY-MM-DD format, with a four-digit
+ * year field first, is taken to be ambiguous):
+ * DATEORDER_YMD specifies field order yy-mm-dd
+ * DATEORDER_DMY specifies field order dd-mm-yy ("European" convention)
+ * DATEORDER_MDY specifies field order mm-dd-yy ("US" convention)
*
- * DateStyle specifies preference for date formatting for output.
- * EuroDates if client prefers dates interpreted and written w/European conventions.
+ * In the Postgres and SQL DateStyles, DateOrder also selects output field
+ * order: day comes before month in DMY style, else month comes before day.
*
- * HasCTZSet if client timezone is specified by client.
- * CDayLight is the apparent daylight savings time status.
- * CTimeZone is the timezone offset in seconds.
- * CTZName is the timezone label.
+ * The user-visible "DateStyle" run-time parameter subsumes both of these.
*/
-#define MAXTZLEN 10 /* max TZ name len, not counting tr. null */
-
+/* valid DateStyle values */
#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
+
+/* valid DateOrder values */
+#define DATEORDER_YMD 0
+#define DATEORDER_DMY 1
+#define DATEORDER_MDY 2
extern int DateStyle;
-extern bool EuroDates;
+extern int DateOrder;
+
+/*
+ * 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
+ * sign convention, ie, positive offset is west of UTC, rather than the
+ * SQL-ish convention that positive is east of UTC).
+ */
extern bool HasCTZSet;
-extern bool CDayLight;
extern int CTimeZone;
-extern char CTZName[];
-extern char FloatFormat[];
-extern char DateFormat[];
+#define MAXTZLEN 10 /* max TZ name len, not counting tr. null */
extern bool enableFsync;
extern bool allowSystemTableMods;
-extern DLLIMPORT int SortMem;
-extern int VacuumMem;
+extern PGDLLIMPORT int work_mem;
+extern PGDLLIMPORT int maintenance_work_mem;
-/*
- * A few postmaster startup options are exported here so the
- * configuration file processor can access them.
- */
+extern int VacuumCostPageHit;
+extern int VacuumCostPageMiss;
+extern int VacuumCostPageDirty;
+extern int VacuumCostLimit;
+extern int VacuumCostDelay;
-extern bool NetServer;
-extern bool EnableSSL;
-extern bool SilentMode;
-extern int MaxBackends;
-extern int ReservedBackends;
-extern int NBuffers;
-extern int PostPortNumber;
-extern int Unix_socket_permissions;
-extern char *Unix_socket_group;
-extern char *UnixSocketDir;
-extern char *VirtualHost;
+extern int VacuumCostBalance;
+extern bool VacuumCostActive;
+
+
+/* in tcop/postgres.c */
+extern void check_stack_depth(void);
/*****************************************************************************
* POSTGRES directory path definitions. *
*****************************************************************************/
-extern char *DatabaseName;
extern char *DatabasePath;
-/* in utils/misc/database.c */
-extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path);
-extern char *ExpandDatabasePath(const char *path);
-
/* now in utils/init/miscinit.c */
-extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path);
-extern char *GetUserNameFromId(Oid userid);
-
+extern char *GetUserNameFromId(Oid roleid);
extern Oid GetUserId(void);
-extern void SetUserId(Oid userid);
+extern Oid GetOuterUserId(void);
extern Oid GetSessionUserId(void);
-extern void SetSessionUserId(Oid userid);
-extern void InitializeSessionUserId(const char *username);
+extern void GetUserIdAndContext(Oid *userid, bool *sec_def_context);
+extern void SetUserIdAndContext(Oid userid, bool sec_def_context);
+extern bool InSecurityDefinerContext(void);
+extern void InitializeSessionUserId(const char *rolename);
extern void InitializeSessionUserIdStandalone(void);
-extern void SetSessionAuthorization(Oid userid);
+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 int FindExec(char *full_path, const char *argv0,
- const char *binary_name);
-extern int CheckPathAccess(char *path, char *name, int open_mode);
-
-#ifdef CYR_RECODE
-extern void SetCharSet(void);
-extern char *convertstr(unsigned char *buff, int len, int dest);
-#endif
+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(Oid userid); /* given user is superuser */
-extern bool is_dbadmin(Oid dbid); /* current user is owner of
- * database */
+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 bool InitPostgres(const char *in_dbname, Oid dboid, const char *username,
+ char **out_dbname);
extern void BaseInit(void);
/* in utils/init/miscinit.c */
-extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster);
-extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster);
+extern bool IgnoreSystemIndexes;
+extern char *shared_preload_libraries_string;
+extern char *local_preload_libraries_string;
+
+extern void SetReindexProcessing(Oid heapOid, Oid indexOid);
+extern void ResetReindexProcessing(void);
+extern bool ReindexIsProcessingHeap(Oid heapOid);
+extern bool ReindexIsProcessingIndex(Oid indexOid);
+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 ValidatePgVersion(const char *path);
-
-/* these externs do not belong here... */
-extern void IgnoreSystemIndexes(bool mode);
-extern bool IsIgnoringSystemIndexes(void);
-extern bool IsCacheInitialized(void);
+extern void process_shared_preload_libraries(void);
+extern void process_local_preload_libraries(void);
#endif /* MISCADMIN_H */