Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Date: 2025-08-20 16:47:38
Message-ID: aKX8Ko8p-ENR3Ieo@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 20, 2025 at 07:16:55PM +0530, vignesh C wrote:
> 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?

This function returns the values in the sequence tuple, primarily for
pg_dump (see commit bd15b7d). IIUC your patch would break pg_dump on v18
and newer versions.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-08-20 17:00:03 Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Previous Message Peter Eisentraut 2025-08-20 16:24:30 Re: minor error message enhancement in refuseDupeIndexAttach