diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3dd4805..83f87c1 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -19521,11 +19521,11 @@ SELECT setval('myseq', 42, false); Next nextval Returns information about the sequence. lsn is the - page lsn of the sequence, last_value is the value - most recently returned by nextval in the current + page lsn of the sequence, last_value is the most + recent value returned by nextval in the current session, log_cnt shows how many fetches remain - before a new WAL record has to be written and - is_called indicates whethere the sequence has been + before a new WAL record has to be written, and + is_called indicates whether the sequence has been used. diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index cd7639f..f33f689 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -338,7 +338,7 @@ ResetSequence(Oid seq_relid) * responsible for permissions checking. * * Note: This function resembles do_setval but does not include the locking and - * verification steps, as those are managed in a slightly diffrent manner for + * verification steps, as those are managed in a slightly different manner for * logical replication. */ void @@ -1262,7 +1262,9 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel) * *buf receives the reference to the pinned-and-ex-locked buffer * *seqdatatuple receives the reference to the sequence tuple proper * (this arg should point to a local variable of type HeapTupleData) - * *lsn_ret will be set to page LSN if the caller requested it + * *lsn_ret will be set to the page LSN if the caller requested it. + * This allows the caller to determine which sequence changes are + * before/after the returned sequence state. * * Function's return value points to the data payload of the tuple */ @@ -1285,11 +1287,7 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple, elog(ERROR, "bad magic number in sequence \"%s\": %08X", RelationGetRelationName(rel), sm->magic); - /* - * If the caller requested it, return the page LSN. This allows the - * caller to determine which sequence changes are before/after the - * returned sequence state. - */ + /* If the caller requested it, return the page LSN. */ if (lsn_ret) *lsn_ret = PageGetLSN(page); @@ -1957,9 +1955,9 @@ pg_sequence_state(PG_FUNCTION_ARGS) seq = read_seq_tuple(seqrel, &buf, &seqtuple, &lsn); - is_called = seq->is_called; last_value = seq->last_value; log_cnt = seq->log_cnt; + is_called = seq->is_called; UnlockReleaseBuffer(buf); relation_close(seqrel, NoLock); @@ -1970,13 +1968,10 @@ pg_sequence_state(PG_FUNCTION_ARGS) /* The value most recently returned by nextval in the current session */ values[1] = Int64GetDatum(last_value); - /* - * Shows how many fetches remain before a new WAL record has to be - * written. - */ + /* How many fetches remain before a new WAL record has to be written */ values[2] = Int64GetDatum(log_cnt); - /* Indicates whethere the sequence has been used */ + /* Indicates whether the sequence has been used */ values[3] = BoolGetDatum(is_called); tuple = heap_form_tuple(tupdesc, values, nulls);