From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
---|---|
To: | vignesh C <vignesh21(at)gmail(dot)com> |
Cc: | Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Hou, Zhijie/侯 志杰 <houzj(dot)fnst(at)fujitsu(dot)com>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org> |
Subject: | Re: Logical Replication of sequences |
Date: | 2024-06-26 09:10:39 |
Message-ID: | CAHut+Pv8aV-+K8t0JcikTowZm0Q9YHMJgdYG+p+jdCJmKxjZ0w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Here are my initial review comments for the first patch v20240625-0001.
======
General
1. Missing docs?
Section 9.17. "Sequence Manipulation Functions" [1] describes some
functions. Shouldn't your new function be documented here also?
~~~
2. Missing tests?
Shouldn't there be some test code that at least executes your new
pg_sequence_state function to verify that sane values are returned?
======
Commit Message
3.
This patch introduces new functionalities to PostgreSQL:
- pg_sequence_state allows retrieval of sequence values using LSN.
- SetSequence enables updating sequences with user-specified values.
~
3a.
I didn't understand why this says "using LSN" because IIUC 'lsn' is an
output parameter of that function. Don't you mean "... retrieval of
sequence values including LSN"?
~
3b.
Does "user-specified" make sense? Is this going to be exposed to a
user? How about just "specified"?
======
src/backend/commands/sequence.c
4. SetSequence:
+void
+SetSequence(Oid seq_relid, int64 value)
Would 'new_last_value' be a better parameter name here?
~~~
5.
This new function logic looks pretty similar to the do_setval()
function. Can you explain (maybe in the function comment) some info
about how and why it differs from that other function?
~~~
6.
I saw that RelationNeedsWAL() is called 2 times. It may make no sense,
but is it possible to assign that to a variable 1st time so you don't
need to call it 2nd time within the critical section?
~~~
NITPICK - remove junk (') char in comment
NITPICK - missing periods (.) in multi-sentence comment
~~~
7.
-read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
+read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple,
+ XLogRecPtr *lsn)
7a.
The existing parameters were described in the function comment. So,
the new 'lsn' parameter should be described here also.
~
7b.
Maybe the new parameter name should be 'lsn_res' or 'lsn_out' or
similar to emphasise that this is a returned value.
~~
NITPICK - tweaked comment. YMMV.
~~~
8. pg_sequence_state:
Should you give descriptions of the output parameters in the function
header comment? Otherwise, where are they described so called knows
what they mean?
~~~
NITPICK - /relid/seq_relid/
NITPICK - declare the variables in the same order as the output parameters
NITPICK - An alternative to the memset for nulls is just to use static
initialisation
"bool nulls[4] = {false, false, false, false};"
======
+extern void SetSequence(Oid seq_relid, int64 value);
9.
Would 'SetSequenceLastValue' be a better name for what this function is doing?
======
99.
See also my attached diff which is a top-up patch implementing those
nitpicks mentioned above. Please apply any of these that you agree
with.
======
[1] https://www.postgresql.org/docs/devel/functions-sequence.html
Kind Regards,
Peter Smith.
Fujitsu Australia
Attachment | Content-Type | Size |
---|---|---|
PS_NITPICKS_20240626_SEQ_0001.txt | text/plain | 2.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Zhijie Hou (Fujitsu) | 2024-06-26 09:15:48 | RE: New standby_slot_names GUC in PG 17 |
Previous Message | Tatsuro Yamada | 2024-06-26 09:06:43 | Re: Showing applied extended statistics in explain Part 2 |