Skip to content

Commit c0d4f6d

Browse files
committed
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
1 parent 4bd3fad commit c0d4f6d

File tree

4 files changed

+55
-53
lines changed

4 files changed

+55
-53
lines changed

src/backend/access/transam/parallel.c

+16-15
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#define PARALLEL_KEY_PENDING_SYNCS UINT64CONST(0xFFFFFFFFFFFF000B)
7676
#define PARALLEL_KEY_REINDEX_STATE UINT64CONST(0xFFFFFFFFFFFF000C)
7777
#define PARALLEL_KEY_RELMAPPER_STATE UINT64CONST(0xFFFFFFFFFFFF000D)
78-
#define PARALLEL_KEY_ENUMBLACKLIST UINT64CONST(0xFFFFFFFFFFFF000E)
78+
#define PARALLEL_KEY_UNCOMMITTEDENUMS UINT64CONST(0xFFFFFFFFFFFF000E)
7979

8080
/* Fixed-size parallel state. */
8181
typedef struct FixedParallelState
@@ -211,7 +211,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
211211
Size pendingsyncslen = 0;
212212
Size reindexlen = 0;
213213
Size relmapperlen = 0;
214-
Size enumblacklistlen = 0;
214+
Size uncommittedenumslen = 0;
215215
Size segsize = 0;
216216
int i;
217217
FixedParallelState *fps;
@@ -267,8 +267,8 @@ InitializeParallelDSM(ParallelContext *pcxt)
267267
shm_toc_estimate_chunk(&pcxt->estimator, reindexlen);
268268
relmapperlen = EstimateRelationMapSpace();
269269
shm_toc_estimate_chunk(&pcxt->estimator, relmapperlen);
270-
enumblacklistlen = EstimateEnumBlacklistSpace();
271-
shm_toc_estimate_chunk(&pcxt->estimator, enumblacklistlen);
270+
uncommittedenumslen = EstimateUncommittedEnumsSpace();
271+
shm_toc_estimate_chunk(&pcxt->estimator, uncommittedenumslen);
272272
/* If you add more chunks here, you probably need to add keys. */
273273
shm_toc_estimate_keys(&pcxt->estimator, 11);
274274

@@ -348,7 +348,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
348348
char *error_queue_space;
349349
char *session_dsm_handle_space;
350350
char *entrypointstate;
351-
char *enumblacklistspace;
351+
char *uncommittedenumsspace;
352352
Size lnamelen;
353353

354354
/* Serialize shared libraries we have loaded. */
@@ -404,11 +404,12 @@ InitializeParallelDSM(ParallelContext *pcxt)
404404
shm_toc_insert(pcxt->toc, PARALLEL_KEY_RELMAPPER_STATE,
405405
relmapperspace);
406406

407-
/* Serialize enum blacklist state. */
408-
enumblacklistspace = shm_toc_allocate(pcxt->toc, enumblacklistlen);
409-
SerializeEnumBlacklist(enumblacklistspace, enumblacklistlen);
410-
shm_toc_insert(pcxt->toc, PARALLEL_KEY_ENUMBLACKLIST,
411-
enumblacklistspace);
407+
/* Serialize uncommitted enum state. */
408+
uncommittedenumsspace = shm_toc_allocate(pcxt->toc,
409+
uncommittedenumslen);
410+
SerializeUncommittedEnums(uncommittedenumsspace, uncommittedenumslen);
411+
shm_toc_insert(pcxt->toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
412+
uncommittedenumsspace);
412413

413414
/* Allocate space for worker information. */
414415
pcxt->worker = palloc0(sizeof(ParallelWorkerInfo) * pcxt->nworkers);
@@ -1257,7 +1258,7 @@ ParallelWorkerMain(Datum main_arg)
12571258
char *pendingsyncsspace;
12581259
char *reindexspace;
12591260
char *relmapperspace;
1260-
char *enumblacklistspace;
1261+
char *uncommittedenumsspace;
12611262
StringInfoData msgbuf;
12621263
char *session_dsm_handle_space;
12631264

@@ -1449,10 +1450,10 @@ ParallelWorkerMain(Datum main_arg)
14491450
relmapperspace = shm_toc_lookup(toc, PARALLEL_KEY_RELMAPPER_STATE, false);
14501451
RestoreRelationMap(relmapperspace);
14511452

1452-
/* Restore enum blacklist. */
1453-
enumblacklistspace = shm_toc_lookup(toc, PARALLEL_KEY_ENUMBLACKLIST,
1454-
false);
1455-
RestoreEnumBlacklist(enumblacklistspace);
1453+
/* Restore uncommitted enums. */
1454+
uncommittedenumsspace = shm_toc_lookup(toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
1455+
false);
1456+
RestoreUncommittedEnums(uncommittedenumsspace);
14561457

14571458
/* Attach to the leader's serializable transaction, if SERIALIZABLE. */
14581459
AttachSerializableXact(fps->serializable_xact_handle);

src/backend/catalog/pg_enum.c

+33-32
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
4141
* committed; otherwise, they might get into indexes where we can't clean
4242
* them up, and then if the transaction rolls back we have a broken index.
4343
* (See comments for check_safe_enum_use() in enum.c.) Values created by
44-
* EnumValuesCreate are *not* blacklisted; we assume those are created during
45-
* CREATE TYPE, so they can't go away unless the enum type itself does.
44+
* EnumValuesCreate are *not* entered into the table; we assume those are
45+
* created during CREATE TYPE, so they can't go away unless the enum type
46+
* itself does.
4647
*/
47-
static HTAB *enum_blacklist = NULL;
48+
static HTAB *uncommitted_enums = NULL;
4849

4950
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
5051
static int sort_order_cmp(const void *p1, const void *p2);
@@ -181,20 +182,20 @@ EnumValuesDelete(Oid enumTypeOid)
181182
}
182183

183184
/*
184-
* Initialize the enum blacklist for this transaction.
185+
* Initialize the uncommitted enum table for this transaction.
185186
*/
186187
static void
187-
init_enum_blacklist(void)
188+
init_uncommitted_enums(void)
188189
{
189190
HASHCTL hash_ctl;
190191

191192
hash_ctl.keysize = sizeof(Oid);
192193
hash_ctl.entrysize = sizeof(Oid);
193194
hash_ctl.hcxt = TopTransactionContext;
194-
enum_blacklist = hash_create("Enum value blacklist",
195-
32,
196-
&hash_ctl,
197-
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
195+
uncommitted_enums = hash_create("Uncommitted enums",
196+
32,
197+
&hash_ctl,
198+
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
198199
}
199200

200201
/*
@@ -490,12 +491,12 @@ AddEnumLabel(Oid enumTypeOid,
490491

491492
table_close(pg_enum, RowExclusiveLock);
492493

493-
/* Set up the blacklist hash if not already done in this transaction */
494-
if (enum_blacklist == NULL)
495-
init_enum_blacklist();
494+
/* Set up the uncommitted enum table if not already done in this tx */
495+
if (uncommitted_enums == NULL)
496+
init_uncommitted_enums();
496497

497-
/* Add the new value to the blacklist */
498-
(void) hash_search(enum_blacklist, &newOid, HASH_ENTER, NULL);
498+
/* Add the new value to the table */
499+
(void) hash_search(uncommitted_enums, &newOid, HASH_ENTER, NULL);
499500
}
500501

501502

@@ -584,19 +585,19 @@ RenameEnumLabel(Oid enumTypeOid,
584585

585586

586587
/*
587-
* Test if the given enum value is on the blacklist
588+
* Test if the given enum value is in the table of uncommitted enums.
588589
*/
589590
bool
590-
EnumBlacklisted(Oid enum_id)
591+
EnumUncommitted(Oid enum_id)
591592
{
592593
bool found;
593594

594-
/* If we've made no blacklist table, all values are safe */
595-
if (enum_blacklist == NULL)
595+
/* If we've made no uncommitted table, all values are safe */
596+
if (uncommitted_enums == NULL)
596597
return false;
597598

598599
/* Else, is it in the table? */
599-
(void) hash_search(enum_blacklist, &enum_id, HASH_FIND, &found);
600+
(void) hash_search(uncommitted_enums, &enum_id, HASH_FIND, &found);
600601
return found;
601602
}
602603

@@ -608,11 +609,11 @@ void
608609
AtEOXact_Enum(void)
609610
{
610611
/*
611-
* Reset the blacklist table, as all our enum values are now committed.
612+
* Reset the uncommitted table, as all our enum values are now committed.
612613
* The memory will go away automatically when TopTransactionContext is
613614
* freed; it's sufficient to clear our pointer.
614615
*/
615-
enum_blacklist = NULL;
616+
uncommitted_enums = NULL;
616617
}
617618

618619

@@ -691,12 +692,12 @@ sort_order_cmp(const void *p1, const void *p2)
691692
}
692693

693694
Size
694-
EstimateEnumBlacklistSpace(void)
695+
EstimateUncommittedEnumsSpace(void)
695696
{
696697
size_t entries;
697698

698-
if (enum_blacklist)
699-
entries = hash_get_num_entries(enum_blacklist);
699+
if (uncommitted_enums)
700+
entries = hash_get_num_entries(uncommitted_enums);
700701
else
701702
entries = 0;
702703

@@ -705,23 +706,23 @@ EstimateEnumBlacklistSpace(void)
705706
}
706707

707708
void
708-
SerializeEnumBlacklist(void *space, Size size)
709+
SerializeUncommittedEnums(void *space, Size size)
709710
{
710711
Oid *serialized = (Oid *) space;
711712

712713
/*
713714
* Make sure the hash table hasn't changed in size since the caller
714715
* reserved the space.
715716
*/
716-
Assert(size == EstimateEnumBlacklistSpace());
717+
Assert(size == EstimateUncommittedEnumsSpace());
717718

718719
/* Write out all the values from the hash table, if there is one. */
719-
if (enum_blacklist)
720+
if (uncommitted_enums)
720721
{
721722
HASH_SEQ_STATUS status;
722723
Oid *value;
723724

724-
hash_seq_init(&status, enum_blacklist);
725+
hash_seq_init(&status, uncommitted_enums);
725726
while ((value = (Oid *) hash_seq_search(&status)))
726727
*serialized++ = *value;
727728
}
@@ -737,11 +738,11 @@ SerializeEnumBlacklist(void *space, Size size)
737738
}
738739

739740
void
740-
RestoreEnumBlacklist(void *space)
741+
RestoreUncommittedEnums(void *space)
741742
{
742743
Oid *serialized = (Oid *) space;
743744

744-
Assert(!enum_blacklist);
745+
Assert(!uncommitted_enums);
745746

746747
/*
747748
* As a special case, if the list is empty then don't even bother to
@@ -752,9 +753,9 @@ RestoreEnumBlacklist(void *space)
752753
return;
753754

754755
/* Read all the values into a new hash table. */
755-
init_enum_blacklist();
756+
init_uncommitted_enums();
756757
do
757758
{
758-
hash_search(enum_blacklist, serialized++, HASH_ENTER, NULL);
759+
hash_search(uncommitted_enums, serialized++, HASH_ENTER, NULL);
759760
} while (OidIsValid(*serialized));
760761
}

src/backend/utils/adt/enum.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ check_safe_enum_use(HeapTuple enumval_tup)
8282
return;
8383

8484
/*
85-
* Check if the enum value is blacklisted. If not, it's safe, because it
85+
* Check if the enum value is uncommitted. If not, it's safe, because it
8686
* was made during CREATE TYPE AS ENUM and can't be shorter-lived than its
8787
* owning type. (This'd also be false for values made by other
8888
* transactions; but the previous tests should have handled all of those.)
8989
*/
90-
if (!EnumBlacklisted(en->oid))
90+
if (!EnumUncommitted(en->oid))
9191
return;
9292

9393
/*

src/include/catalog/pg_enum.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ extern void AddEnumLabel(Oid enumTypeOid, const char *newVal,
6060
bool skipIfExists);
6161
extern void RenameEnumLabel(Oid enumTypeOid,
6262
const char *oldVal, const char *newVal);
63-
extern bool EnumBlacklisted(Oid enum_id);
64-
extern Size EstimateEnumBlacklistSpace(void);
65-
extern void SerializeEnumBlacklist(void *space, Size size);
66-
extern void RestoreEnumBlacklist(void *space);
63+
extern bool EnumUncommitted(Oid enum_id);
64+
extern Size EstimateUncommittedEnumsSpace(void);
65+
extern void SerializeUncommittedEnums(void *space, Size size);
66+
extern void RestoreUncommittedEnums(void *space);
6767
extern void AtEOXact_Enum(void);
6868

6969
#endif /* PG_ENUM_H */

0 commit comments

Comments
 (0)