Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Date
Msg-id aKX_Ey7oMYJ3EQXi@nathan
Whole thread Raw
In response to Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence  (Nathan Bossart <nathandbossart@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence
Next
From: Jeff Davis
Date:
Subject: Re: Organize working memory under per-PlanState context