6.0.0-git
2019-08-23

[#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 2018-11-26 (270 days ago)
Due
Updated 2019-04-15 (130 days ago)
Assigned
Resolved
Milestone
Patch No

History
2019-04-15 09:47:54 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}'


2018-11-26 11:16:13 stefan (at) stklcode (dot) de Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Summary ⇒ Sequence reset incompatible with PostgreSQL 10+
Queue ⇒ Horde Base
Milestone ⇒
Patch ⇒ No
New Attachment: horde-seq-pg11.log Download
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