mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Rename "enum blacklist" to "uncommitted enums".
We agreed to remove this terminology and use something more descriptive. Discussion: https://postgr.es/m/20200615182235.x7lch5n6kcjq4aue%40alap3.anarazel.de
This commit is contained in:
parent
4bd3fad80e
commit
c0d4f6d897
@ -75,7 +75,7 @@
|
|||||||
#define PARALLEL_KEY_PENDING_SYNCS UINT64CONST(0xFFFFFFFFFFFF000B)
|
#define PARALLEL_KEY_PENDING_SYNCS UINT64CONST(0xFFFFFFFFFFFF000B)
|
||||||
#define PARALLEL_KEY_REINDEX_STATE UINT64CONST(0xFFFFFFFFFFFF000C)
|
#define PARALLEL_KEY_REINDEX_STATE UINT64CONST(0xFFFFFFFFFFFF000C)
|
||||||
#define PARALLEL_KEY_RELMAPPER_STATE UINT64CONST(0xFFFFFFFFFFFF000D)
|
#define PARALLEL_KEY_RELMAPPER_STATE UINT64CONST(0xFFFFFFFFFFFF000D)
|
||||||
#define PARALLEL_KEY_ENUMBLACKLIST UINT64CONST(0xFFFFFFFFFFFF000E)
|
#define PARALLEL_KEY_UNCOMMITTEDENUMS UINT64CONST(0xFFFFFFFFFFFF000E)
|
||||||
|
|
||||||
/* Fixed-size parallel state. */
|
/* Fixed-size parallel state. */
|
||||||
typedef struct FixedParallelState
|
typedef struct FixedParallelState
|
||||||
@ -211,7 +211,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
|||||||
Size pendingsyncslen = 0;
|
Size pendingsyncslen = 0;
|
||||||
Size reindexlen = 0;
|
Size reindexlen = 0;
|
||||||
Size relmapperlen = 0;
|
Size relmapperlen = 0;
|
||||||
Size enumblacklistlen = 0;
|
Size uncommittedenumslen = 0;
|
||||||
Size segsize = 0;
|
Size segsize = 0;
|
||||||
int i;
|
int i;
|
||||||
FixedParallelState *fps;
|
FixedParallelState *fps;
|
||||||
@ -267,8 +267,8 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
|||||||
shm_toc_estimate_chunk(&pcxt->estimator, reindexlen);
|
shm_toc_estimate_chunk(&pcxt->estimator, reindexlen);
|
||||||
relmapperlen = EstimateRelationMapSpace();
|
relmapperlen = EstimateRelationMapSpace();
|
||||||
shm_toc_estimate_chunk(&pcxt->estimator, relmapperlen);
|
shm_toc_estimate_chunk(&pcxt->estimator, relmapperlen);
|
||||||
enumblacklistlen = EstimateEnumBlacklistSpace();
|
uncommittedenumslen = EstimateUncommittedEnumsSpace();
|
||||||
shm_toc_estimate_chunk(&pcxt->estimator, enumblacklistlen);
|
shm_toc_estimate_chunk(&pcxt->estimator, uncommittedenumslen);
|
||||||
/* If you add more chunks here, you probably need to add keys. */
|
/* If you add more chunks here, you probably need to add keys. */
|
||||||
shm_toc_estimate_keys(&pcxt->estimator, 11);
|
shm_toc_estimate_keys(&pcxt->estimator, 11);
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
|||||||
char *error_queue_space;
|
char *error_queue_space;
|
||||||
char *session_dsm_handle_space;
|
char *session_dsm_handle_space;
|
||||||
char *entrypointstate;
|
char *entrypointstate;
|
||||||
char *enumblacklistspace;
|
char *uncommittedenumsspace;
|
||||||
Size lnamelen;
|
Size lnamelen;
|
||||||
|
|
||||||
/* Serialize shared libraries we have loaded. */
|
/* Serialize shared libraries we have loaded. */
|
||||||
@ -404,11 +404,12 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
|||||||
shm_toc_insert(pcxt->toc, PARALLEL_KEY_RELMAPPER_STATE,
|
shm_toc_insert(pcxt->toc, PARALLEL_KEY_RELMAPPER_STATE,
|
||||||
relmapperspace);
|
relmapperspace);
|
||||||
|
|
||||||
/* Serialize enum blacklist state. */
|
/* Serialize uncommitted enum state. */
|
||||||
enumblacklistspace = shm_toc_allocate(pcxt->toc, enumblacklistlen);
|
uncommittedenumsspace = shm_toc_allocate(pcxt->toc,
|
||||||
SerializeEnumBlacklist(enumblacklistspace, enumblacklistlen);
|
uncommittedenumslen);
|
||||||
shm_toc_insert(pcxt->toc, PARALLEL_KEY_ENUMBLACKLIST,
|
SerializeUncommittedEnums(uncommittedenumsspace, uncommittedenumslen);
|
||||||
enumblacklistspace);
|
shm_toc_insert(pcxt->toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
|
||||||
|
uncommittedenumsspace);
|
||||||
|
|
||||||
/* Allocate space for worker information. */
|
/* Allocate space for worker information. */
|
||||||
pcxt->worker = palloc0(sizeof(ParallelWorkerInfo) * pcxt->nworkers);
|
pcxt->worker = palloc0(sizeof(ParallelWorkerInfo) * pcxt->nworkers);
|
||||||
@ -1257,7 +1258,7 @@ ParallelWorkerMain(Datum main_arg)
|
|||||||
char *pendingsyncsspace;
|
char *pendingsyncsspace;
|
||||||
char *reindexspace;
|
char *reindexspace;
|
||||||
char *relmapperspace;
|
char *relmapperspace;
|
||||||
char *enumblacklistspace;
|
char *uncommittedenumsspace;
|
||||||
StringInfoData msgbuf;
|
StringInfoData msgbuf;
|
||||||
char *session_dsm_handle_space;
|
char *session_dsm_handle_space;
|
||||||
|
|
||||||
@ -1449,10 +1450,10 @@ ParallelWorkerMain(Datum main_arg)
|
|||||||
relmapperspace = shm_toc_lookup(toc, PARALLEL_KEY_RELMAPPER_STATE, false);
|
relmapperspace = shm_toc_lookup(toc, PARALLEL_KEY_RELMAPPER_STATE, false);
|
||||||
RestoreRelationMap(relmapperspace);
|
RestoreRelationMap(relmapperspace);
|
||||||
|
|
||||||
/* Restore enum blacklist. */
|
/* Restore uncommitted enums. */
|
||||||
enumblacklistspace = shm_toc_lookup(toc, PARALLEL_KEY_ENUMBLACKLIST,
|
uncommittedenumsspace = shm_toc_lookup(toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
|
||||||
false);
|
false);
|
||||||
RestoreEnumBlacklist(enumblacklistspace);
|
RestoreUncommittedEnums(uncommittedenumsspace);
|
||||||
|
|
||||||
/* Attach to the leader's serializable transaction, if SERIALIZABLE. */
|
/* Attach to the leader's serializable transaction, if SERIALIZABLE. */
|
||||||
AttachSerializableXact(fps->serializable_xact_handle);
|
AttachSerializableXact(fps->serializable_xact_handle);
|
||||||
|
@ -41,10 +41,11 @@ Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
|
|||||||
* committed; otherwise, they might get into indexes where we can't clean
|
* 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.
|
* 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
|
* (See comments for check_safe_enum_use() in enum.c.) Values created by
|
||||||
* EnumValuesCreate are *not* blacklisted; we assume those are created during
|
* EnumValuesCreate are *not* entered into the table; we assume those are
|
||||||
* CREATE TYPE, so they can't go away unless the enum type itself does.
|
* 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 void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
|
||||||
static int sort_order_cmp(const void *p1, const void *p2);
|
static int sort_order_cmp(const void *p1, const void *p2);
|
||||||
@ -181,20 +182,20 @@ EnumValuesDelete(Oid enumTypeOid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the enum blacklist for this transaction.
|
* Initialize the uncommitted enum table for this transaction.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
init_enum_blacklist(void)
|
init_uncommitted_enums(void)
|
||||||
{
|
{
|
||||||
HASHCTL hash_ctl;
|
HASHCTL hash_ctl;
|
||||||
|
|
||||||
hash_ctl.keysize = sizeof(Oid);
|
hash_ctl.keysize = sizeof(Oid);
|
||||||
hash_ctl.entrysize = sizeof(Oid);
|
hash_ctl.entrysize = sizeof(Oid);
|
||||||
hash_ctl.hcxt = TopTransactionContext;
|
hash_ctl.hcxt = TopTransactionContext;
|
||||||
enum_blacklist = hash_create("Enum value blacklist",
|
uncommitted_enums = hash_create("Uncommitted enums",
|
||||||
32,
|
32,
|
||||||
&hash_ctl,
|
&hash_ctl,
|
||||||
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -490,12 +491,12 @@ restart:
|
|||||||
|
|
||||||
table_close(pg_enum, RowExclusiveLock);
|
table_close(pg_enum, RowExclusiveLock);
|
||||||
|
|
||||||
/* Set up the blacklist hash if not already done in this transaction */
|
/* Set up the uncommitted enum table if not already done in this tx */
|
||||||
if (enum_blacklist == NULL)
|
if (uncommitted_enums == NULL)
|
||||||
init_enum_blacklist();
|
init_uncommitted_enums();
|
||||||
|
|
||||||
/* Add the new value to the blacklist */
|
/* Add the new value to the table */
|
||||||
(void) hash_search(enum_blacklist, &newOid, HASH_ENTER, NULL);
|
(void) hash_search(uncommitted_enums, &newOid, HASH_ENTER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -584,19 +585,19 @@ RenameEnumLabel(Oid enumTypeOid,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test if the given enum value is on the blacklist
|
* Test if the given enum value is in the table of uncommitted enums.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
EnumBlacklisted(Oid enum_id)
|
EnumUncommitted(Oid enum_id)
|
||||||
{
|
{
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
/* If we've made no blacklist table, all values are safe */
|
/* If we've made no uncommitted table, all values are safe */
|
||||||
if (enum_blacklist == NULL)
|
if (uncommitted_enums == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Else, is it in the table? */
|
/* 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;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,11 +609,11 @@ void
|
|||||||
AtEOXact_Enum(void)
|
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
|
* The memory will go away automatically when TopTransactionContext is
|
||||||
* freed; it's sufficient to clear our pointer.
|
* freed; it's sufficient to clear our pointer.
|
||||||
*/
|
*/
|
||||||
enum_blacklist = NULL;
|
uncommitted_enums = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -691,12 +692,12 @@ sort_order_cmp(const void *p1, const void *p2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size
|
Size
|
||||||
EstimateEnumBlacklistSpace(void)
|
EstimateUncommittedEnumsSpace(void)
|
||||||
{
|
{
|
||||||
size_t entries;
|
size_t entries;
|
||||||
|
|
||||||
if (enum_blacklist)
|
if (uncommitted_enums)
|
||||||
entries = hash_get_num_entries(enum_blacklist);
|
entries = hash_get_num_entries(uncommitted_enums);
|
||||||
else
|
else
|
||||||
entries = 0;
|
entries = 0;
|
||||||
|
|
||||||
@ -705,7 +706,7 @@ EstimateEnumBlacklistSpace(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SerializeEnumBlacklist(void *space, Size size)
|
SerializeUncommittedEnums(void *space, Size size)
|
||||||
{
|
{
|
||||||
Oid *serialized = (Oid *) space;
|
Oid *serialized = (Oid *) space;
|
||||||
|
|
||||||
@ -713,15 +714,15 @@ SerializeEnumBlacklist(void *space, Size size)
|
|||||||
* Make sure the hash table hasn't changed in size since the caller
|
* Make sure the hash table hasn't changed in size since the caller
|
||||||
* reserved the space.
|
* reserved the space.
|
||||||
*/
|
*/
|
||||||
Assert(size == EstimateEnumBlacklistSpace());
|
Assert(size == EstimateUncommittedEnumsSpace());
|
||||||
|
|
||||||
/* Write out all the values from the hash table, if there is one. */
|
/* Write out all the values from the hash table, if there is one. */
|
||||||
if (enum_blacklist)
|
if (uncommitted_enums)
|
||||||
{
|
{
|
||||||
HASH_SEQ_STATUS status;
|
HASH_SEQ_STATUS status;
|
||||||
Oid *value;
|
Oid *value;
|
||||||
|
|
||||||
hash_seq_init(&status, enum_blacklist);
|
hash_seq_init(&status, uncommitted_enums);
|
||||||
while ((value = (Oid *) hash_seq_search(&status)))
|
while ((value = (Oid *) hash_seq_search(&status)))
|
||||||
*serialized++ = *value;
|
*serialized++ = *value;
|
||||||
}
|
}
|
||||||
@ -737,11 +738,11 @@ SerializeEnumBlacklist(void *space, Size size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RestoreEnumBlacklist(void *space)
|
RestoreUncommittedEnums(void *space)
|
||||||
{
|
{
|
||||||
Oid *serialized = (Oid *) 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
|
* As a special case, if the list is empty then don't even bother to
|
||||||
@ -752,9 +753,9 @@ RestoreEnumBlacklist(void *space)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Read all the values into a new hash table. */
|
/* Read all the values into a new hash table. */
|
||||||
init_enum_blacklist();
|
init_uncommitted_enums();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
hash_search(enum_blacklist, serialized++, HASH_ENTER, NULL);
|
hash_search(uncommitted_enums, serialized++, HASH_ENTER, NULL);
|
||||||
} while (OidIsValid(*serialized));
|
} while (OidIsValid(*serialized));
|
||||||
}
|
}
|
||||||
|
@ -82,12 +82,12 @@ check_safe_enum_use(HeapTuple enumval_tup)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the enum value is blacklisted. If not, it's safe, because it
|
* Check if the enum value is uncommitted. If not, it's safe, because it
|
||||||
* was made during CREATE TYPE AS ENUM and can't be shorter-lived than its
|
* was made during CREATE TYPE AS ENUM and can't be shorter-lived than its
|
||||||
* owning type. (This'd also be false for values made by other
|
* owning type. (This'd also be false for values made by other
|
||||||
* transactions; but the previous tests should have handled all of those.)
|
* transactions; but the previous tests should have handled all of those.)
|
||||||
*/
|
*/
|
||||||
if (!EnumBlacklisted(en->oid))
|
if (!EnumUncommitted(en->oid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -60,10 +60,10 @@ extern void AddEnumLabel(Oid enumTypeOid, const char *newVal,
|
|||||||
bool skipIfExists);
|
bool skipIfExists);
|
||||||
extern void RenameEnumLabel(Oid enumTypeOid,
|
extern void RenameEnumLabel(Oid enumTypeOid,
|
||||||
const char *oldVal, const char *newVal);
|
const char *oldVal, const char *newVal);
|
||||||
extern bool EnumBlacklisted(Oid enum_id);
|
extern bool EnumUncommitted(Oid enum_id);
|
||||||
extern Size EstimateEnumBlacklistSpace(void);
|
extern Size EstimateUncommittedEnumsSpace(void);
|
||||||
extern void SerializeEnumBlacklist(void *space, Size size);
|
extern void SerializeUncommittedEnums(void *space, Size size);
|
||||||
extern void RestoreEnumBlacklist(void *space);
|
extern void RestoreUncommittedEnums(void *space);
|
||||||
extern void AtEOXact_Enum(void);
|
extern void AtEOXact_Enum(void);
|
||||||
|
|
||||||
#endif /* PG_ENUM_H */
|
#endif /* PG_ENUM_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user