pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence

Поиск
Список
Период
Сортировка
От vignesh C
Тема pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Дата
Msg-id CALDaNm36PKfjSJPQWFi1kB832zhkDxyyFCLkg1x39Sz+eikRaw@mail.gmail.com
обсуждение исходный текст
Ответы Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Список pgsql-hackers
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

Вложения

В списке pgsql-hackers по дате отправления: