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 17:00:03
Message-ID: aKX_Ey7oMYJ3EQXi@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 20, 2025 at 11:47:38AM -0500, Nathan Bossart wrote:
> 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.

Concretely, after the following commands, the patch causes pg_dump to call
setval with the wrong value:

CREATE SEQUENCE test;
ALTER SEQUENCE test RESTART WITH 2;

Without patch:
SELECT pg_catalog.setval('public.test', 2, false);

With patch:
SELECT pg_catalog.setval('public.test', 1, false);

--
nathan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-08-20 17:00:49 Re: Organize working memory under per-PlanState context
Previous Message Nathan Bossart 2025-08-20 16:47:38 Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence