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