#define PARALLEL_KEY_PENDING_SYNCS UINT64CONST(0xFFFFFFFFFFFF000B)
#define PARALLEL_KEY_REINDEX_STATE UINT64CONST(0xFFFFFFFFFFFF000C)
#define PARALLEL_KEY_RELMAPPER_STATE UINT64CONST(0xFFFFFFFFFFFF000D)
-#define PARALLEL_KEY_ENUMBLACKLIST UINT64CONST(0xFFFFFFFFFFFF000E)
+#define PARALLEL_KEY_UNCOMMITTEDENUMS UINT64CONST(0xFFFFFFFFFFFF000E)
/* Fixed-size parallel state. */
typedef struct FixedParallelState
Size pendingsyncslen = 0;
Size reindexlen = 0;
Size relmapperlen = 0;
- Size enumblacklistlen = 0;
+ Size uncommittedenumslen = 0;
Size segsize = 0;
int i;
FixedParallelState *fps;
shm_toc_estimate_chunk(&pcxt->estimator, reindexlen);
relmapperlen = EstimateRelationMapSpace();
shm_toc_estimate_chunk(&pcxt->estimator, relmapperlen);
- enumblacklistlen = EstimateEnumBlacklistSpace();
- shm_toc_estimate_chunk(&pcxt->estimator, enumblacklistlen);
+ uncommittedenumslen = EstimateUncommittedEnumsSpace();
+ shm_toc_estimate_chunk(&pcxt->estimator, uncommittedenumslen);
/* If you add more chunks here, you probably need to add keys. */
shm_toc_estimate_keys(&pcxt->estimator, 11);
char *error_queue_space;
char *session_dsm_handle_space;
char *entrypointstate;
- char *enumblacklistspace;
+ char *uncommittedenumsspace;
Size lnamelen;
/* Serialize shared libraries we have loaded. */
shm_toc_insert(pcxt->toc, PARALLEL_KEY_RELMAPPER_STATE,
relmapperspace);
- /* Serialize enum blacklist state. */
- enumblacklistspace = shm_toc_allocate(pcxt->toc, enumblacklistlen);
- SerializeEnumBlacklist(enumblacklistspace, enumblacklistlen);
- shm_toc_insert(pcxt->toc, PARALLEL_KEY_ENUMBLACKLIST,
- enumblacklistspace);
+ /* Serialize uncommitted enum state. */
+ uncommittedenumsspace = shm_toc_allocate(pcxt->toc,
+ uncommittedenumslen);
+ SerializeUncommittedEnums(uncommittedenumsspace, uncommittedenumslen);
+ shm_toc_insert(pcxt->toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
+ uncommittedenumsspace);
/* Allocate space for worker information. */
pcxt->worker = palloc0(sizeof(ParallelWorkerInfo) * pcxt->nworkers);
char *pendingsyncsspace;
char *reindexspace;
char *relmapperspace;
- char *enumblacklistspace;
+ char *uncommittedenumsspace;
StringInfoData msgbuf;
char *session_dsm_handle_space;
relmapperspace = shm_toc_lookup(toc, PARALLEL_KEY_RELMAPPER_STATE, false);
RestoreRelationMap(relmapperspace);
- /* Restore enum blacklist. */
- enumblacklistspace = shm_toc_lookup(toc, PARALLEL_KEY_ENUMBLACKLIST,
- false);
- RestoreEnumBlacklist(enumblacklistspace);
+ /* Restore uncommitted enums. */
+ uncommittedenumsspace = shm_toc_lookup(toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
+ false);
+ RestoreUncommittedEnums(uncommittedenumsspace);
/* Attach to the leader's serializable transaction, if SERIALIZABLE. */
AttachSerializableXact(fps->serializable_xact_handle);
* committed; otherwise, they might get into indexes where we can't clean
* them up, and then if the transaction rolls back we have a broken index.
* (See comments for check_safe_enum_use() in enum.c.) Values created by
- * EnumValuesCreate are *not* blacklisted; we assume those are created during
- * CREATE TYPE, so they can't go away unless the enum type itself does.
+ * EnumValuesCreate are *not* entered into the table; we assume those are
+ * created during CREATE TYPE, so they can't go away unless the enum type
+ * itself does.
*/
-static HTAB *enum_blacklist = NULL;
+static HTAB *uncommitted_enums = NULL;
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
static int sort_order_cmp(const void *p1, const void *p2);
}
/*
- * Initialize the enum blacklist for this transaction.
+ * Initialize the uncommitted enum table for this transaction.
*/
static void
-init_enum_blacklist(void)
+init_uncommitted_enums(void)
{
HASHCTL hash_ctl;
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(Oid);
hash_ctl.hcxt = TopTransactionContext;
- enum_blacklist = hash_create("Enum value blacklist",
- 32,
- &hash_ctl,
- HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
+ uncommitted_enums = hash_create("Uncommitted enums",
+ 32,
+ &hash_ctl,
+ HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
}
/*
table_close(pg_enum, RowExclusiveLock);
- /* Set up the blacklist hash if not already done in this transaction */
- if (enum_blacklist == NULL)
- init_enum_blacklist();
+ /* Set up the uncommitted enum table if not already done in this tx */
+ if (uncommitted_enums == NULL)
+ init_uncommitted_enums();
- /* Add the new value to the blacklist */
- (void) hash_search(enum_blacklist, &newOid, HASH_ENTER, NULL);
+ /* Add the new value to the table */
+ (void) hash_search(uncommitted_enums, &newOid, HASH_ENTER, NULL);
}
/*
- * Test if the given enum value is on the blacklist
+ * Test if the given enum value is in the table of uncommitted enums.
*/
bool
-EnumBlacklisted(Oid enum_id)
+EnumUncommitted(Oid enum_id)
{
bool found;
- /* If we've made no blacklist table, all values are safe */
- if (enum_blacklist == NULL)
+ /* If we've made no uncommitted table, all values are safe */
+ if (uncommitted_enums == NULL)
return false;
/* Else, is it in the table? */
- (void) hash_search(enum_blacklist, &enum_id, HASH_FIND, &found);
+ (void) hash_search(uncommitted_enums, &enum_id, HASH_FIND, &found);
return found;
}
AtEOXact_Enum(void)
{
/*
- * Reset the blacklist table, as all our enum values are now committed.
+ * Reset the uncommitted table, as all our enum values are now committed.
* The memory will go away automatically when TopTransactionContext is
* freed; it's sufficient to clear our pointer.
*/
- enum_blacklist = NULL;
+ uncommitted_enums = NULL;
}
}
Size
-EstimateEnumBlacklistSpace(void)
+EstimateUncommittedEnumsSpace(void)
{
size_t entries;
- if (enum_blacklist)
- entries = hash_get_num_entries(enum_blacklist);
+ if (uncommitted_enums)
+ entries = hash_get_num_entries(uncommitted_enums);
else
entries = 0;
}
void
-SerializeEnumBlacklist(void *space, Size size)
+SerializeUncommittedEnums(void *space, Size size)
{
Oid *serialized = (Oid *) space;
* Make sure the hash table hasn't changed in size since the caller
* reserved the space.
*/
- Assert(size == EstimateEnumBlacklistSpace());
+ Assert(size == EstimateUncommittedEnumsSpace());
/* Write out all the values from the hash table, if there is one. */
- if (enum_blacklist)
+ if (uncommitted_enums)
{
HASH_SEQ_STATUS status;
Oid *value;
- hash_seq_init(&status, enum_blacklist);
+ hash_seq_init(&status, uncommitted_enums);
while ((value = (Oid *) hash_seq_search(&status)))
*serialized++ = *value;
}
}
void
-RestoreEnumBlacklist(void *space)
+RestoreUncommittedEnums(void *space)
{
Oid *serialized = (Oid *) space;
- Assert(!enum_blacklist);
+ Assert(!uncommitted_enums);
/*
* As a special case, if the list is empty then don't even bother to
return;
/* Read all the values into a new hash table. */
- init_enum_blacklist();
+ init_uncommitted_enums();
do
{
- hash_search(enum_blacklist, serialized++, HASH_ENTER, NULL);
+ hash_search(uncommitted_enums, serialized++, HASH_ENTER, NULL);
} while (OidIsValid(*serialized));
}