diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/slru.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_inherits_fn.h | 1 | ||||
-rw-r--r-- | src/include/commands/trigger.h | 67 | ||||
-rw-r--r-- | src/include/miscadmin.h | 27 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 4 | ||||
-rw-r--r-- | src/include/pg_config.h.win32 | 4 | ||||
-rw-r--r-- | src/include/port.h | 3 | ||||
-rw-r--r-- | src/include/replication/walreceiver.h | 6 | ||||
-rw-r--r-- | src/include/replication/walsender_private.h | 9 | ||||
-rw-r--r-- | src/include/utils/pidfile.h | 55 |
10 files changed, 137 insertions, 43 deletions
diff --git a/src/include/access/slru.h b/src/include/access/slru.h index f1b4d6cc9d..d829a6fab4 100644 --- a/src/include/access/slru.h +++ b/src/include/access/slru.h @@ -29,10 +29,6 @@ * 0xFFFFFFFF/xxxx_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need * take no explicit notice of that fact in slru.c, except when comparing * segment and page numbers in SimpleLruTruncate (see PagePrecedes()). - * - * Note: slru.c currently assumes that segment file names will be four hex - * digits. This sets a lower bound on the segment size (64K transactions - * for 32-bit TransactionIds). */ #define SLRU_PAGES_PER_SEGMENT 32 diff --git a/src/include/catalog/pg_inherits_fn.h b/src/include/catalog/pg_inherits_fn.h index abfa4766a1..7743388899 100644 --- a/src/include/catalog/pg_inherits_fn.h +++ b/src/include/catalog/pg_inherits_fn.h @@ -21,6 +21,7 @@ extern List *find_inheritance_children(Oid parentrelId, LOCKMODE lockmode); extern List *find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **parents); extern bool has_subclass(Oid relationId); +extern bool has_superclass(Oid relationId); extern bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId); #endif /* PG_INHERITS_FN_H */ diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index 5061bee782..9f5580d0c7 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -42,6 +42,51 @@ typedef struct TriggerData } TriggerData; /* + * The state for capturing old and new tuples into transition tables for a + * single ModifyTable node. + */ +typedef struct TransitionCaptureState +{ + /* + * Is there at least one trigger specifying each transition relation on + * the relation explicitly named in the DML statement or COPY command? + */ + bool tcs_delete_old_table; + bool tcs_update_old_table; + bool tcs_update_new_table; + bool tcs_insert_new_table; + + /* + * For UPDATE and DELETE, AfterTriggerSaveEvent may need to convert the + * new and old tuples from a child table's format to the format of the + * relation named in a query so that it is compatible with the transition + * tuplestores. + */ + TupleConversionMap *tcs_map; + + /* + * For INSERT and COPY, it would be wasteful to convert tuples from child + * format to parent format after they have already been converted in the + * opposite direction during routing. In that case we bypass conversion + * and allow the inserting code (copy.c and nodeModifyTable.c) to provide + * the original tuple directly. + */ + HeapTuple tcs_original_insert_tuple; + + /* + * The tuplestores backing the transition tables. We use separate + * tuplestores for INSERT and UPDATE, because INSERT ... ON CONFLICT + * ... DO UPDATE causes INSERT and UPDATE triggers to fire and needs a way + * to keep track of the new tuple images resulting from the two cases + * separately. We only need a single old image tuplestore, because there + * is no statement that can both update and delete at the same time. + */ + Tuplestorestate *tcs_old_tuplestore; /* for DELETE and UPDATE old images */ + Tuplestorestate *tcs_insert_tuplestore; /* for INSERT new images */ + Tuplestorestate *tcs_update_tuplestore; /* for UPDATE new images */ +} TransitionCaptureState; + +/* * TriggerEvent bit flags * * Note that we assume different event types (INSERT/DELETE/UPDATE/TRUNCATE) @@ -131,26 +176,33 @@ extern void RelationBuildTriggers(Relation relation); extern TriggerDesc *CopyTriggerDesc(TriggerDesc *trigdesc); +extern const char *FindTriggerIncompatibleWithInheritance(TriggerDesc *trigdesc); +extern TransitionCaptureState *MakeTransitionCaptureState(TriggerDesc *trigdesc); +extern void DestroyTransitionCaptureState(TransitionCaptureState *tcs); + extern void FreeTriggerDesc(TriggerDesc *trigdesc); extern void ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo); extern void ExecASInsertTriggers(EState *estate, - ResultRelInfo *relinfo); + ResultRelInfo *relinfo, + TransitionCaptureState *transition_capture); extern TupleTableSlot *ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot); extern void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, - List *recheckIndexes); + List *recheckIndexes, + TransitionCaptureState *transition_capture); extern TupleTableSlot *ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot); extern void ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo); extern void ExecASDeleteTriggers(EState *estate, - ResultRelInfo *relinfo); + ResultRelInfo *relinfo, + TransitionCaptureState *transition_capture); extern bool ExecBRDeleteTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, @@ -159,14 +211,16 @@ extern bool ExecBRDeleteTriggers(EState *estate, extern void ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, - HeapTuple fdw_trigtuple); + HeapTuple fdw_trigtuple, + TransitionCaptureState *transition_capture); extern bool ExecIRDeleteTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple); extern void ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo); extern void ExecASUpdateTriggers(EState *estate, - ResultRelInfo *relinfo); + ResultRelInfo *relinfo, + TransitionCaptureState *transition_capture); extern TupleTableSlot *ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, @@ -178,7 +232,8 @@ extern void ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple fdw_trigtuple, HeapTuple newtuple, - List *recheckIndexes); + List *recheckIndexes, + TransitionCaptureState *transition_capture); extern TupleTableSlot *ExecIRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 58feafd919..586922b579 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -29,8 +29,6 @@ #include "pgtime.h" /* for pg_time_t */ -#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n" - #define InvalidPid (-1) @@ -445,31 +443,6 @@ extern char *session_preload_libraries_string; 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 first Unix socket directory path (empty if none) - * 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. - * - * 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 ForgetLockFiles(void); extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster, diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 86f379c126..acd8b16e89 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -968,6 +968,10 @@ typedef struct ModifyTableState TupleConversionMap **mt_partition_tupconv_maps; /* Per partition tuple conversion map */ TupleTableSlot *mt_partition_tuple_slot; + struct TransitionCaptureState *mt_transition_capture; + /* controls transition table population */ + TupleConversionMap **mt_transition_tupconv_maps; + /* Per plan/partition tuple conversion */ } ModifyTableState; /* ---------------- diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index d7cd0ac4f6..16bfb3bc5c 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -557,7 +557,7 @@ #define PACKAGE_STRING "Postgres-XL 10alpha1" /* Define to the version of this package. */ -#define PACKAGE_VERSION "10beta1" +#define PACKAGE_VERSION "10beta2" /* Define to the name of a signed 128-bit integer type. */ #undef PG_INT128_TYPE @@ -566,7 +566,7 @@ #define PG_INT64_TYPE long long int /* PostgreSQL version as a string */ -#define PG_VERSION "10beta1" +#define PG_VERSION "10beta2" /* PostgreSQL version as a number */ #define PG_VERSION_NUM 100000 diff --git a/src/include/port.h b/src/include/port.h index 3729b7a306..5fffa111f9 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -98,6 +98,9 @@ extern int find_my_exec(const char *argv0, char *retpath); extern int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath); +/* Doesn't belong here, but this is used with find_other_exec(), so... */ +#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n" + /* Windows security token manipulation (in exec.c) */ #ifdef WIN32 extern BOOL AddUserToTokenDacl(HANDLE hToken); diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index c8652dbd48..9a8b2e207e 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -114,6 +114,9 @@ typedef struct */ char slotname[NAMEDATALEN]; + /* set true once conninfo is ready to display (obfuscated pwds etc) */ + bool ready_to_display; + slock_t mutex; /* locks shared variables shown above */ /* @@ -122,9 +125,6 @@ typedef struct */ bool force_reply; - /* set true once conninfo is ready to display (obfuscated pwds etc) */ - bool ready_to_display; - /* * Latch used by startup process to wake up walreceiver after telling it * where to start streaming (after setting receiveStart and diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h index 0aa80d5c3e..17c68cba23 100644 --- a/src/include/replication/walsender_private.h +++ b/src/include/replication/walsender_private.h @@ -30,10 +30,17 @@ typedef enum WalSndState /* * Each walsender has a WalSnd struct in shared memory. + * + * This struct is protected by 'mutex', with two exceptions: one is + * sync_standby_priority as noted below. The other exception is that some + * members are only written by the walsender process itself, and thus that + * process is free to read those members without holding spinlock. pid and + * needreload always require the spinlock to be held for all accesses. */ typedef struct WalSnd { - pid_t pid; /* this walsender's process id, or 0 */ + pid_t pid; /* this walsender's PID, or 0 if not active */ + WalSndState state; /* this walsender's state */ XLogRecPtr sentPtr; /* WAL has been sent up to this point */ bool needreload; /* does currently-open file need to be diff --git a/src/include/utils/pidfile.h b/src/include/utils/pidfile.h new file mode 100644 index 0000000000..c3db4c46e3 --- /dev/null +++ b/src/include/utils/pidfile.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------------------- + * + * pidfile.h + * Declarations describing the data directory lock file (postmaster.pid) + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/pidfile.h + * + *------------------------------------------------------------------------- + */ +#ifndef UTILS_PIDFILE_H +#define UTILS_PIDFILE_H + +/* + * As of Postgres 10, 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 first Unix socket directory path (empty if none) + * 6 first listen_address (IP address or "*"; empty if no TCP port) + * 7 shared memory key (empty on Windows) + * 8 postmaster status (see values below) + * + * Lines 6 and up are added via AddToDataDirLockFile() after initial file + * creation; also, line 5 is initially empty and is changed after the first + * Unix socket is opened. + * + * Socket lock file(s), if used, have the same contents as lines 1-5, with + * line 5 being their own directory. + */ +#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 +#define LOCK_FILE_LINE_PM_STATUS 8 + +/* + * The PM_STATUS line may contain one of these values. All these strings + * must be the same length, per comments for AddToDataDirLockFile(). + * We pad with spaces as needed to make that true. + */ +#define PM_STATUS_STARTING "starting" /* still starting up */ +#define PM_STATUS_STOPPING "stopping" /* in shutdown sequence */ +#define PM_STATUS_READY "ready " /* ready for connections */ +#define PM_STATUS_STANDBY "standby " /* up, won't accept connections */ + +#endif /* UTILS_PIDFILE_H */ |