Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0d4f6d

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 parent4bd3fad commitc0d4f6d

File tree

4 files changed

+55
-53
lines changed

4 files changed

+55
-53
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#definePARALLEL_KEY_PENDING_SYNCSUINT64CONST(0xFFFFFFFFFFFF000B)
7676
#definePARALLEL_KEY_REINDEX_STATEUINT64CONST(0xFFFFFFFFFFFF000C)
7777
#definePARALLEL_KEY_RELMAPPER_STATEUINT64CONST(0xFFFFFFFFFFFF000D)
78-
#definePARALLEL_KEY_ENUMBLACKLISTUINT64CONST(0xFFFFFFFFFFFF000E)
78+
#definePARALLEL_KEY_UNCOMMITTEDENUMSUINT64CONST(0xFFFFFFFFFFFF000E)
7979

8080
/* Fixed-size parallel state. */
8181
typedefstructFixedParallelState
@@ -211,7 +211,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
211211
Sizependingsyncslen=0;
212212
Sizereindexlen=0;
213213
Sizerelmapperlen=0;
214-
Sizeenumblacklistlen=0;
214+
Sizeuncommittedenumslen=0;
215215
Sizesegsize=0;
216216
inti;
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
Sizelnamelen;
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
StringInfoDatamsgbuf;
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-
/* Restoreenum blacklist. */
1453-
enumblacklistspace=shm_toc_lookup(toc,PARALLEL_KEY_ENUMBLACKLIST,
1454-
false);
1455-
RestoreEnumBlacklist(enumblacklistspace);
1453+
/* Restoreuncommitted 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

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Oidbinary_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-
staticHTAB*enum_blacklist=NULL;
48+
staticHTAB*uncommitted_enums=NULL;
4849

4950
staticvoidRenumberEnumType(Relationpg_enum,HeapTuple*existing,intnelems);
5051
staticintsort_order_cmp(constvoid*p1,constvoid*p2);
@@ -181,20 +182,20 @@ EnumValuesDelete(Oid enumTypeOid)
181182
}
182183

183184
/*
184-
* Initialize the enumblacklist for this transaction.
185+
* Initialize theuncommittedenumtable for this transaction.
185186
*/
186187
staticvoid
187-
init_enum_blacklist(void)
188+
init_uncommitted_enums(void)
188189
{
189190
HASHCTLhash_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 theblacklist hashif not already done in thistransaction */
494-
if (enum_blacklist==NULL)
495-
init_enum_blacklist();
494+
/* Set up theuncommitted enum tableif not already done in thistx */
495+
if (uncommitted_enums==NULL)
496+
init_uncommitted_enums();
496497

497-
/* Add the new value to theblacklist */
498-
(void)hash_search(enum_blacklist,&newOid,HASH_ENTER,NULL);
498+
/* Add the new value to thetable */
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 ison theblacklist
588+
* Test if the given enum value isin thetable of uncommitted enums.
588589
*/
589590
bool
590-
EnumBlacklisted(Oidenum_id)
591+
EnumUncommitted(Oidenum_id)
591592
{
592593
boolfound;
593594

594-
/* If we've made noblacklist table, all values are safe */
595-
if (enum_blacklist==NULL)
595+
/* If we've made nouncommitted 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
returnfound;
601602
}
602603

@@ -608,11 +609,11 @@ void
608609
AtEOXact_Enum(void)
609610
{
610611
/*
611-
* Reset theblacklist table, as all our enum values are now committed.
612+
* Reset theuncommitted 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_tentries;
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,Sizesize)
709+
SerializeUncommittedEnums(void*space,Sizesize)
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_STATUSstatus;
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

Lines changed: 2 additions & 2 deletions
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 isblacklisted. If not, it's safe, because it
85+
* Check if the enum value isuncommitted. 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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ extern void AddEnumLabel(Oid enumTypeOid, const char *newVal,
6060
boolskipIfExists);
6161
externvoidRenameEnumLabel(OidenumTypeOid,
6262
constchar*oldVal,constchar*newVal);
63-
externboolEnumBlacklisted(Oidenum_id);
64-
externSizeEstimateEnumBlacklistSpace(void);
65-
externvoidSerializeEnumBlacklist(void*space,Sizesize);
66-
externvoidRestoreEnumBlacklist(void*space);
63+
externboolEnumUncommitted(Oidenum_id);
64+
externSizeEstimateUncommittedEnumsSpace(void);
65+
externvoidSerializeUncommittedEnums(void*space,Sizesize);
66+
externvoidRestoreUncommittedEnums(void*space);
6767
externvoidAtEOXact_Enum(void);
6868

6969
#endif/* PG_ENUM_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp