6.0.0-alpha10
5/14/25

[#14878] Sequence reset incompatible with PostgreSQL 10+
Summary Sequence reset incompatible with PostgreSQL 10+
Queue Horde Base
Queue Version 5.2.20
Type Bug
State Unconfirmed
Priority 2. Medium
Owners
Requester stefan (at) stklcode (dot) de
Created 11/26/2018 (2361 days ago)
Due
Updated 02/10/2020 (1920 days ago)
Assigned
Resolved
Milestone
Patch No

History
02/10/2020 09:54:24 AM stefan (at) stklcode (dot) de Comment #3 Reply to this comment
Related to this GitHub PR:
https://github.com/horde/Db/pull/1
04/15/2019 09:47:54 AM lst_hoe02 (at) kwsoft (dot) de Comment #2 Reply to this comment
Looks like located in Horde/Db/Adapter/Postgresql/Schema.php

One of our Devs suggested to use this in a similar case which should 
work on all PostgreSQL versions at least since 9

select increment from information_schema.sequences where 
sequence_schema='{schema}' and sequence_name='{sequence}'


11/26/2018 11:16:13 AM stefan (at) stklcode (dot) de Comment #1
Priority ⇒ 2. Medium
New Attachment: horde-seq-pg11.log Download
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Base
Summary ⇒ Sequence reset incompatible with PostgreSQL 10+
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
After upgrading the database from PostgreSQL 9.6 to 11 certain 
operations fail when trying to reset a sequence.

Example to reproduce:
Create a new event in Kronolith raises an error (see attached log). 
After refreshing the page the event is created successfully.

Cause:
Method "resetPkSequence" in file 
"pear/Horde/Db/Adapter/Postgresql/Schema.php" executes the following 
SQL:
SELECT setval(%s, (SELECT COALESCE(MAX(%s) + (SELECT increment_by FROM 
%s), (SELECT min_value FROM %s)) FROM %s), false)

Sequence column "increment_by" is no longer available in PostgreSQL 10 
and above.

Saved Queries