Change the logic of setval function, so that the next nextval of sequence will return exactly the specified value. #3273

This commit is contained in:
Akshay Joshi 2025-01-28 17:52:21 +05:30
parent 1e00611792
commit 1317e5a921
7 changed files with 11 additions and 4 deletions

View File

@ -20,9 +20,11 @@ Bundled PostgreSQL Utilities
New features
************
| `Issue #6513 <https://github.com/pgadmin-org/pgadmin4/issues/6513>`_ - Change button labels and color in delete confirmation dialog for all objects to improve UX.
| `Issue #7708 <https://github.com/pgadmin-org/pgadmin4/issues/7708>`_ - Enhanced pgAdmin 4 with support for Workspace layouts.
| `Issue #8332 <https://github.com/pgadmin-org/pgadmin4/issues/8332>`_ - Added the MAINTAIN privilege for PostgreSQL version 17 and above.
| `Issue #8391 <https://github.com/pgadmin-org/pgadmin4/issues/8391>`_ - Add support for OAuth2 profile array response, which also takes care of the GitHub Private Email ID issue.
Housekeeping
************
@ -32,6 +34,7 @@ Housekeeping
Bug fixes
*********
| `Issue #3273 <https://github.com/pgadmin-org/pgadmin4/issues/3273>`_ - Change the logic of setval function, so that the next nextval of sequence will return exactly the specified value.
| `Issue #5204 <https://github.com/pgadmin-org/pgadmin4/issues/5204>`_ - Fixed an issue where pgadmin cannot install into path with non ASCII characters.
| `Issue #6044 <https://github.com/pgadmin-org/pgadmin4/issues/6044>`_ - Fixed an issue where filter dialog save fails when the PostgreSQL server/database connection is lost.
| `Issue #6968 <https://github.com/pgadmin-org/pgadmin4/issues/6968>`_ - Fixed an issue where option key was not registering in PSQL tool.

View File

@ -35,6 +35,9 @@ Click the *Definition* tab to continue.
Use the fields in the *Definition* tab to define the sequence:
* Use the *Current Value* field to specify the sequence object\'s current value.
The next nextval will return exactly the specified value, and sequence advancement
commences with the following nextval. *This field is only available in the edit mode*.
* Use the *Increment* field to specify which value is added to the current
sequence value to create a new value.
* Provide a value in the *Start* field to specify the beginning value of the

View File

@ -136,6 +136,7 @@ export default class SequenceSchema extends BaseUISchema {
}, {
id: 'current_value', label: gettext('Current value'), type: 'int',
mode: ['properties', 'edit'], group: gettext('Definition'),
helpMessage: gettext('Sets the sequence object\'s current value. The next nextval will return exactly the specified value, and sequence advancement commences with the following nextval.')
}, {
id: 'increment', label: gettext('Increment'), type: 'int',
mode: ['properties', 'create', 'edit'], group: gettext('Definition'),

View File

@ -20,7 +20,7 @@ ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
{% endif %}
{% if data.current_value is defined %}
{% set seqname = conn|qtIdent(o_data.schema, data.name) %}
SELECT setval({{ seqname|qtLiteral(conn) }}, {{ data.current_value }}, true);
SELECT setval({{ seqname|qtLiteral(conn) }}, {{ data.current_value }}, false);
{% endif %}
{% if data.relpersistence in [True, False] and data.relpersistence != o_data.relpersistence %}

View File

@ -20,7 +20,7 @@ ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
{% endif %}
{% if data.current_value is defined %}
{% set seqname = conn|qtIdent(o_data.schema, data.name) %}
SELECT setval({{ seqname|qtLiteral(conn) }}, {{ data.current_value }}, true);
SELECT setval({{ seqname|qtLiteral(conn) }}, {{ data.current_value }}, false);
{% endif %}
{% set defquery = '' %}

View File

@ -1,4 +1,4 @@
SELECT setval(E'public."Seq1_$%{}[]()&*^!@""''`\\/#"', 7, true);
SELECT setval(E'public."Seq1_$%{}[]()&*^!@""''`\\/#"', 7, false);
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
INCREMENT 12

View File

@ -1,4 +1,4 @@
SELECT setval(E'public."Seq1_$%{}[]()&*^!@""''`\\/#"', 7, true);
SELECT setval(E'public."Seq1_$%{}[]()&*^!@""''`\\/#"', 7, false);
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
INCREMENT 12