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

Commit6e951bf

Browse files
committed
Group more closely cache updates for backends in sequence.c
Information of sequences is cached for each backend for currval() andnextval(), and the update of some cached information was mixed in themiddle of computations based on the other properties of a sequence, forthe increment value in nextval() and the cached state when altering asequence.Grouping them makes the code easier to follow and to refactor in thefuture, when splitting the computation and the SeqTable change parts.Note that the cached data is untouched between the areas where thesecache updates are moved.Issue noticed while doing some refactoring of the sequence code.Author: Michael PaquierReviewed-by: Tomas VondraDiscussion:https://postgr.es/m/ZWlohtKAs0uVVpZ3@paquier.xyz
1 parent449e798 commit6e951bf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎src/backend/commands/sequence.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,6 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
489489
seqform,newdataform,
490490
&need_seq_rewrite,&owned_by);
491491

492-
/* Clear local cache so that we don't think we have cached numbers */
493-
/* Note that we do not change the currval() state */
494-
elm->cached=elm->last;
495-
496492
/* If needed, rewrite the sequence relation itself */
497493
if (need_seq_rewrite)
498494
{
@@ -520,6 +516,10 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
520516
fill_seq_with_data(seqrel,newdatatuple);
521517
}
522518

519+
/* Clear local cache so that we don't think we have cached numbers */
520+
/* Note that we do not change the currval() state */
521+
elm->cached=elm->last;
522+
523523
/* process OWNED BY if given */
524524
if (owned_by)
525525
process_owned_by(seqrel,owned_by,stmt->for_identity);
@@ -683,7 +683,6 @@ nextval_internal(Oid relid, bool check_permissions)
683683
seq=read_seq_tuple(seqrel,&buf,&seqdatatuple);
684684
page=BufferGetPage(buf);
685685

686-
elm->increment=incby;
687686
last=next=result=seq->last_value;
688687
fetch=cache;
689688
log=seq->log_cnt;
@@ -781,6 +780,7 @@ nextval_internal(Oid relid, bool check_permissions)
781780
Assert(log >=0);
782781

783782
/* save info in local cache */
783+
elm->increment=incby;
784784
elm->last=result;/* last returned number */
785785
elm->cached=last;/* last fetched number */
786786
elm->last_valid= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp