pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ganeshpandi.eswaran@chainsys.com
Subject: BUG #18761: Sequence Value Discrepancy After Running VACUUM ANALYZE
Date: Tue, 31 Dec 2024 09:26:36 +0000
Message-ID: <18761-624bbdc5e7434bdb@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18761
Logged by:          Ganeshpandi Eswaran
Email address:      ganeshpandi.eswaran@chainsys.com
PostgreSQL version: 13.15
Operating system:   Oracle sql developer
Description:        

Issue Report: Sequence Value Discrepancy After Running VACUUM ANALYZE
Description:
After executing the following UPDATE query, which updates a table using a
PostgreSQL sequence to assign a batch number:

SQL query: 

UPDATE stgtbl_837465r4 STGTBL 
SET ATTR_7 = PVQUERY.batch_number, ATTR_1 = PVQUERY.batch_number , TF_1 =
'S' 
FROM ( 
    SELECT CAST(BATCH_SEQ AS NUMERIC) AS BATCH_NUMBER, 
           CAST(BATCH_SEQ AS VARCHAR(50)) AS BATCH, 
           BATCH_TEXT 
    FROM (
        SELECT NEXTVAL('sample_sequence__2899') AS BATCH_SEQ,
               'A' AS BATCH_TEXT
        FROM test_act
    ) A 
) PVQUERY 
WHERE PVQUERY.batch_text IS NOT NULL;

Expected Behavior:
The sequence (sample_sequence__2899) should return different sequence
numbers (e.g., 1, 2, 3) for each record updated in the UPDATE query.

Observed Behavior:
After running VACUUM ANALYZE on the table stgtbl_837465r4, the sequence
returns the same value (e.g., 4) for all records, even though it should
return unique values for each record.

Steps to Reproduce:
Run the UPDATE query as stated above.
Observe the sequence values returned for each record before VACUUM ANALYZE
is executed.
Run the VACUUM ANALYZE operation on the table stgtbl_837465r4.
Re-run the same UPDATE query.
Observe that the sequence returns the same value (e.g., 4) for all updated
records.

Kindly provide a solution to the issue due to this issue affecting our most
functionality



view thread (3+ messages)  latest in thread

Message-ID: <18761-624bbdc5e7434bdb@postgresql.org>
Permalink:  ../18761-624bbdc5e7434bdb@postgresql.org/
Also on:    postgresql.org/message-id/18761-624bbdc5e7434bdb@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, ganeshpandi.eswaran@chainsys.com
  Subject: Re: BUG #18761: Sequence Value Discrepancy After Running VACUUM ANALYZE
  In-Reply-To: <18761-624bbdc5e7434bdb@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox