At Wed, 3 Apr 2013 17:35:46 +0400, Sergei Petrunia <psergey@askmonty.org> wrote:
Could you please tell, what exactly is wrong with the results you're getting? Is it the right data, but in the wrong order, or the data itself is also wrong?
Data are correct, but order is wrong. If I print key variable (see link to dbmail-message.c below) it prints 1,1,2,3,2,3,3 however from commandline order is good: SELECT l.part_key,l.part_depth,l.part_order,l.is_header,DATE_FORMAT(ph.internal_date, GET_FORMAT(DATETIME,'ISO')) FROM dbmail_mimeparts p JOIN dbmail_partlists l ON p.id = l.part_id JOIN dbmail_physmessage ph ON ph.id = l.physmessage_id WHERE l.physmessage_id = 4748475 ORDER BY l.part_key,l.part_order ASC; +----------+------------+------------+-----------+-----------------------------------------------------------+ | part_key | part_depth | part_order | is_header | DATE_FORMAT(ph.internal_date, GET_FORMAT(DATETIME,'ISO')) | +----------+------------+------------+-----------+-----------------------------------------------------------+ | 1 | 0 | 0 | 1 | 2013-04-02 12:49:41 | | 1 | 0 | 1 | 0 | 2013-04-02 12:49:41 | | 2 | 1 | 0 | 1 | 2013-04-02 12:49:41 | | 2 | 1 | 1 | 0 | 2013-04-02 12:49:41 | | 3 | 1 | 0 | 1 | 2013-04-02 12:49:41 | | 3 | 1 | 1 | 0 | 2013-04-02 12:49:41 | | 3 | 0 | 3 | 0 | 2013-04-02 12:49:41 | +----------+------------+------------+-----------+-----------------------------------------------------------+
You mention
however when I run it from command line it works well.
How is it run not from commandline? (sorry if this question is trivial, but I'm not familiar with the dbmail codebase).
See file: http://git.dbmail.eu/paul/dbmail/tree/src/dbmail-message.c?id=4333e2d94dc03b... function: static DbmailMessage * _mime_retrieve(DbmailMessage *self) You may also want to look into libzdb sources, but they look like just wrappers to provide unified API. http://www.tildeslash.com/libzdb/
What version of dbmail are you using? Is your table definition for table dbmail_partlists the same as in dbmail-3.0.2, file sql/mysql/create_tables.mysql ?
I use dbmail-3.0.2. Database was created by older version many years ago, but mysqldump shows current table description: CREATE TABLE `dbmail_partlists` ( `physmessage_id` bigint(20) unsigned NOT NULL DEFAULT '0', `is_header` tinyint(1) NOT NULL DEFAULT '0', `part_key` smallint(6) NOT NULL DEFAULT '0', `part_depth` smallint(6) NOT NULL DEFAULT '0', `part_order` smallint(6) NOT NULL DEFAULT '0', `part_id` bigint(20) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `message_parts` (`physmessage_id`,`part_key`,`part_depth`,`part_order`), KEY `physmessage_id` (`physmessage_id`), KEY `part_id` (`part_id`), CONSTRAINT `dbmail_partlists_ibfk_1` FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dbmail_partlists_ibfk_2` FOREIGN KEY (`part_id`) REFERENCES `dbmail_mimeparts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */;