6.0.0-beta1
7/4/25

[#12979] IMAP Client issues / Wrong SQL statement?
Summary IMAP Client issues / Wrong SQL statement?
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State No Feedback
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester markus (at) mwagner (dot) info
Created 02/18/2014 (4154 days ago)
Due
Updated 04/28/2014 (4085 days ago)
Assigned 02/19/2014 (4153 days ago)
Resolved 03/21/2014 (4123 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
04/28/2014 07:46:57 AM wojnas (at) gmail (dot) com Comment #11 Reply to this comment

[Show Quoted Text - 9 lines]
Hello,
i got the same problem, after upgrade horde 2 weeks ago by pear.
Here is my database structure (there is no autoincremet option i 
messageid column):

mysql> DESCRIBE horde_imap_client_data;
+-----------+------------------+------+-----+---------+-------+
| Field     | Type             | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+-------+
| messageid | int(10) unsigned | NO   | PRI | 0       |       |
| hostspec  | varchar(255)     | NO   | MUL | NULL    |       |
| mailbox   | varchar(255)     | NO   |     | NULL    |       |
| modified  | bigint(20)       | YES  |     | NULL    |       |
| port      | int(11)          | NO   |     | NULL    |       |
| username  | varchar(255)     | NO   |     | NULL    |       |
+-----------+------------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

New users can't log to webmail.
He is error from my log file

Apr 28 09:26:18 hostname HORDE: [imp] SQL QUERY FAILED: 
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 
'0' for key 'PRIMARY'  #012#011INSERT INTO horde_imap_client_data 
(hostspec, mailbox, port, username)#012#011  VALUES ('host', 'INBOX', 
'143', 'username@domain') [pid 9236 on line 204 of 
"/usr/share/pear/Horde/Db/Adapter/Pdo/Base.php"]

How can i fix the problem?

03/21/2014 12:16:53 PM Jan Schneider State ⇒ No Feedback
 
02/19/2014 01:28:31 PM markus (at) mwagner (dot) info Comment #10 Reply to this comment
Always via official debian repository (though sid/experimental).
(I used to have a PEAR installation way before...)
So, did you install the original horde_imap_client version through 
apt/dpkg and then upgraded via PEAR?
Do you remember the versions of that library before and after the upgrade?
It starts to sound like a botched upgrade rather than a design issue 
of the migration scripts.
02/19/2014 01:20:40 PM Jan Schneider Comment #9
Version ⇒ Git master
Reply to this comment
So, did you install the original horde_imap_client version through 
apt/dpkg and then upgraded via PEAR?
Do you remember the versions of that library before and after the upgrade?
It starts to sound like a botched upgrade rather than a design issue 
of the migration scripts.
02/19/2014 01:03:39 PM markus (at) mwagner (dot) info Comment #8 Reply to this comment
I don't know, if during migration the table has been altered to add 
the auto_increment feature.

I tried to do so manually and it caused a hick-up due to an entry with 
'0' as messageid, thus setting the auto-increment sequence to 1 and 
having a PRIMARY violation. Setting this record to anything > 0 will 
make the table alteration successful.

[Show Quoted Text - 26 lines]
02/19/2014 10:46:31 AM markus (at) mwagner (dot) info Comment #7 Reply to this comment
And are you really using FRAMEWORK_5_1 code?
I was assuming so, since Horde says in the upper left, that version is 
"5.1.5".

Unfortunately, checking for newer versions under adminstration does 
not work anymore... (but this ought to be another story)

Thanks!
02/19/2014 10:44:20 AM markus (at) mwagner (dot) info Comment #6 Reply to this comment
I am using MySQL - and yes, I assume it has been migrated from an 
earlier version. (I am using Debian sid/experimental packages and at 
some point imap_client came into the game)

--
-- Table structure for table `horde_imap_client_data`
--
CREATE TABLE IF NOT EXISTS `horde_imap_client_data` (
   `messageid` int(10) unsigned NOT NULL DEFAULT '0',
   `hostspec` varchar(255) NOT NULL,
   `mailbox` varchar(255) NOT NULL,
   `modified` bigint(20) DEFAULT NULL,
   `port` int(11) NOT NULL,
   `username` varchar(255) NOT NULL,
   PRIMARY KEY (`messageid`),
   KEY 
`index_horde_imap_client_data_on_hostspec_and_mailbox_and_port_an` 
(`hostspec`,`mailbox`,`port`,`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

So I assume, the autoincrement got lost at some point...
Sounds like your messageid column is not an autoincrement column 
(anymore?). What database do you use, and has this been migrated 
from an earlier version of the Horde_Imap_Client database schema?
02/19/2014 10:36:35 AM Jan Schneider Comment #5 Reply to this comment
And are you really using FRAMEWORK_5_1 code?
02/19/2014 10:36:01 AM Jan Schneider Comment #4
State ⇒ Feedback
Reply to this comment
Sounds like your messageid column is not an autoincrement column 
(anymore?). What database do you use, and has this been migrated from 
an earlier version of the Horde_Imap_Client database schema?
02/19/2014 09:18:02 AM markus (at) mwagner (dot) info Comment #3 Reply to this comment
But I _do_ have the column 'messageid' and no column 'uid' in table 
'horde_imap_client_data' !?

Also, my running codebase shows in file 
1_horde_imap_client_base_tables.php 'messageid' as autoincrementKey.

BTW: I can move messages to older folders. But when creating a folder, 
it seems that the appropriate enrtry cannot be made into table 
'horde_imap_client_data'.

Further ideas to investigate on this one?

02/19/2014 06:56:43 AM Michael Slusarz Comment #2
State ⇒ Assigned
Assigned to Jan Schneider
Reply to this comment
This was changed by this commit:

commit f47da21798ffc4d1664e167a620ca846c2808ff6
Author: Jan Schneider <jan@horde.org>
Date:   Tue Feb 11 23:06:14 2014 +0100

     Rename uid column to messageid.

     uid is a reserved word on Oracle databases.
02/18/2014 12:33:07 PM markus (at) mwagner (dot) info Comment #1
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
New Attachment: horde5-imp-sql-error.png Download
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Framework Packages
Due ⇒ 02/28/2014
Summary ⇒ IMAP Client issues / Wrong SQL statement?
Type ⇒ Bug
Reply to this comment
When moving a message with IMP on my IMAP-Server from INBOX to 
Folder.Subfolder I receive the following error (attachment) and also 
the following log entry is issued.

2014-02-18T13:16:23+01:00 ERR: HORDE [imp] SQL QUERY FAILED: 
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 
'0' for key 'PRIMARY'
         INSERT INTO horde_imap_client_data (hostspec, mailbox, port, username)
           VALUES ('localhost', 'Folder.Subfolder', '143',
           'user@domain.com') [pid 16977 on line 553 of 
"/usr/share/php/Horde/Db/Adapter/Base.php"

There is a messageid field in the horde_imap_client_data table which 
is set to 0 already for "Folder". Other folders have other numbers.

Also, when looking at the folder (e.g. click to show content), I just 
see nothing/empty folder.
However, for other (older) IMAP-Folders everything works perfectely.

What could be the reason for this?! DB out of date/not properly updated?

Thanks for any pointers/fixes.


Saved Queries