[pkg-horde] Bug#880380: Column missing in DB + kronolith errors

Ivan Sergio Borgonovo ivan.s.b at gmail.com
Tue Oct 31 01:18:47 UTC 2017


Package: php-horde-db
Version: 2.4.0-1

I just noticed that when I try to add events to the calendar I get these 
errors

2017-10-31 00:18:29.942 CET [31212] horde at horde ERROR:  column 
"increment_by" does not exist at character 92

2017-10-31 00:18:29.942 CET [31212] horde at horde STATEMENT:  SELECT 
setval('rampage_objects_object_id_seq', (SELECT 
COALESCE(MAX("object_id") + (SELECT increment_by FROM 
rampage_objects_object_id_seq), (SELECT min_value FROM 
rampage_objects_object_id_seq)) FROM "rampage_objects"), false)

2017-10-31 00:53:00.959 CET [4298] horde at horde ERROR:  column 
"increment_by" does not exist at character 109

2017-10-31 00:53:00.959 CET [4298] horde at horde STATEMENT:  SELECT 
setval('horde_histories_modseq_history_modseq_seq', (SELECT 
COALESCE(MAX("history_modseq") + (SELECT increment_by FROM 
horde_histories_modseq_history_modseq_seq), (SELECT min_value FROM 
horde_histories_modseq_history_modseq_seq)) FROM 
"horde_histories_modseq"), false)

Checking in
Administration->Configuration
all DB schema are reported as ready

This seems to be caused by changed support for sequences in postgres 10.

I have the feeling this is not the way to do even in previous postgresql 
but right now I can't grasp what the query is really doing to further 
improve it.

Sequences metadata should be accessed through pg_sequences.

pg_sequences should be supported even by pretty old postgresql version 
and it shouldn't be a problem to change the query.

If anyone is willing to help to decipher what's the use of the above 
queries I could improve the overall query.
Otherwise this could be a reasonable patch for now

/usr/share/php/Horde/Db/Adapter/Postgresql/Schema.php

$sql = sprintf('SELECT setval(%s, (SELECT COALESCE(MAX(%s) + (SELECT 
increment_by FROM pg_sequences where schemaname== ANY 
(CURRENT_SCHEMAS(false)) and sequencename=%s), (SELECT min_value FROM 
pg_sequences where schemaname=(CURRENT_SCHEMAS(false)) and 
sequencename=%s)) FROM %s), false)',
                                $quotedSequence,
                                $quotedPk,
                                $quotedSequence,
                                $quotedSequence,
                                $quotedTable);

Tested.

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it http://www.borgonovo.net



More information about the pkg-horde-hackers mailing list