Hi,
I noticed an inconsistency in the behavior of sequence-related
functions for a freshly created sequence.
CREATE SEQUENCE s1;
postgres=# select last_value from pg_sequences;
last_value
------------
(1 row)
postgres=# select pg_sequence_last_value('s1');
pg_sequence_last_value
------------------------
(1 row)
postgres=# select las_value from pg_get_sequence_data('s1');
last_value
------------
1
(1 row)
As you can see:
pg_sequences and pg_sequence_last_value return NULL for last_value,
which aligns with the expectation that the sequence hasn't been used
yet. However, pg_get_sequence_data returns the start value (1) even
though is_called is false. This seems inconsistent. I felt
pg_get_sequence_data should also return NULL for last_value in this
case to match the others.
Attached patch has a fix for the same. Thoughts?
Regards,
Vignesh