Bug 726912 - FC15 Gnucash and libdbi versions are incompatible - cannot save to mysql database
Summary: FC15 Gnucash and libdbi versions are incompatible - cannot save to mysql data...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: libdbi
Version: 15
Hardware: i686
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Tom Lane
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-30 19:16 UTC by Andy Campbell
Modified: 2013-07-03 03:37 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-05 23:32:18 UTC
Type: ---


Attachments (Terms of Use)

Description Andy Campbell 2011-07-30 19:16:18 UTC
Description of problem:
I use gnucash (and love it!) and would like to use the new functionality to save to a MySQL database.  To make this work, requires the libdbi library & drivers.

The current version of Gnucash in FC15 (gnucash-2.4.7-1.fc15.i686) is not compatible with shipped version of libdbi (libdbi-0.8.3-4.fc15.i686)



Version-Release number of selected component (if applicable):
gnucash-2.4.7-1.fc15.i686
libdbi-0.8.3-4.fc15.i686



How reproducible:
Always



Steps to Reproduce:
1. install gnucash & deps
2. install libdbi-0.8.3-4.fc15.i686, libdbi-dbd-mysql-0.8.3-8.fc15.i686, libdbi-drivers-0.8.3-8.fc15.i686.  (After this is done, gnucash offers expanded Save As options)
3. install mysql 
4. create new mysql database called gnucash.  Create user gnucash with all permissions to access database gnuchash
5. start gnucash, and create some test data.   
6. Choose "Save As", select "Data Format = mysql", populate database name, username, password and click Save As



Actual results:
Pop-up dialog with this error:
"The library "libdbi" installed on your system doesn't correctly store large numbers.  This means GnuCash cannot use SQL databases correctly.  Gnucash will not open or save to SQL databases until this is fixed by installing a different version of "libdbi".  Please see https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more information."



Expected results:
Account data saved to mysql



Additional info:
Relavent bug report, including notes about fix in another distro
https://bugzilla.gnome.org/show_bug.cgi?id=611936

Comment 1 Tom Lane 2011-07-31 19:35:48 UTC
I can't replicate this on either i386 or x86_64 builds... are you sure you're using an up-to-date build of libdbi and libdbi-drivers?

Comment 2 Andy Campbell 2011-08-01 20:21:13 UTC
I checked all the installed versions:
$ rpm -qa | grep libdbi
libdbi-0.8.3-4.fc15.i686
libdbi-dbd-mysql-0.8.3-8.fc15.i686
libdbi-drivers-0.8.3-8.fc15.i686

[andy@speedy ~]$ rpm -qi libdbi-0.8.3-4.fc15.i686
Name        : libdbi
Version     : 0.8.3
Release     : 4.fc15
Architecture: i686
Install Date: Sat 02 Jul 2011 16:00:58 BST
Group       : Development/Libraries
Size        : 92176
<snip>

Plus these
gnucash-2.4.7-1.fc15.i686
mysql-5.5.14-2.fc15.i686

I'm running a clean install of 32 bit FC15, not an upgrade.

This is the newest version I can find on koji.  Do you have a newer build?

Comment 3 Tom Lane 2011-08-01 23:18:11 UTC
Hmph.  Those are the exact versions I tested, on an F15 x86 install that was fresh and "yum update"d as of yesterday.  Barring something really unpleasant like a vendor-specific CPU bug, it doesn't seem like this could be a version-skew issue.  What seems more likely is that I didn't do the same thing you did.  Bearing in mind that I know nothing worth mentioning about gnucash, could you walk me through the exact reproduction sequence?  Might be a good idea to work in a virgin user account, too.  And while I'm speculating, do you have any nondefault settings in /etc/my.cnf?

Comment 4 Andy Campbell 2011-08-03 21:55:06 UTC
Hi, 

Here are the steps to reproduce on my system

I started with a completely new test user account

As root
:: install gnucash & deps
:: install mysql 
:: start mysqld
:: install libdbi-0.8.3-4.fc15.i686, libdbi-dbd-mysql-0.8.3-8.fc15.i686 &
libdbi-drivers-0.8.3-8.fc15.i686.  


create new mysql database called gnucash.  I do this using the mysql client with the commands below
----
[root@speedy ~]# mysql <optionally add password if you set one for mysql>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database gnucash;
Query OK, 1 row affected (0.00 sec)
----



Create a new user called gnucash with all permissions to access the new database gnuchash.  Again, use mysql client as admin user, and execute this
----
mysql> create user 'gnuchash'@'localhost' identified by 'gnucash';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on gnucash.* to 'gnuchash'@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> <ctrl-d to exit>
----



check that the new gnucash mysql user can login to the new database correctly
---
[andy@speedy ~]$ mysql -u gnucash gnucash -p
Enter password: <gnucash>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> <ctrl-d to exit>
---



launch gnucash from Activties menu

After Tip of the Day, a "Welcome to GnuCash!" dialog appears

Select "Create a new set of accounts", OK
"New Account Hierarchy Setup" assistant appears,
select click Forward a few times to accept Default account options then Apply

gnucash displays the main Accounts tab with 5 default top level accounts 

Select File / Save As...
Choose Data Format = mysql
Host = localhost
Database = gnucash
Username = gnucash
Password = gnucash

Click "Save As" button, and the error appears
"The library "libdbi" installed on your system doesn't correctly store large numbers.  This means GnuCash cannot use SQL databases correctly.  Gnucash will not open or save to SQL databases until this is fixed by installing a different version of "libdbi".  Please see https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more information."



I checked my /etc/my.cnf - it's default.

Also, I checked my CPU type
---
[andy@speedy ~]$ cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 15
model		: 4
model name	: Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping	: 1
<snip>
---


I studied the bug report again.  It seems to be a 32-bit specific issue.  It looks like there are 3 patches attached to this bugzilla which seem to fix the problem
https://bugzilla.gnome.org/show_bug.cgi?id=611936

Comment 5 Tom Lane 2011-08-04 18:14:54 UTC
OK, that was what I did, and I just did it again to make sure, and the error doesn't happen on my somewhat-recent laptop (Core i5 processor).  So it's looking like maybe it *is* processor specific.  I do still have a Pentium 4 machine gathering dust in the corner ... I'll see if I can get it to run F15 at all.  More news later.

Comment 6 Tom Lane 2011-08-04 20:49:04 UTC
Well, that was a bust ... no bug visible on that machine either.  This one is a 2001-vintage Dell Pentium 4, /proc/cpuinfo showing

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 1
model name      : Intel(R) Pentium(R) 4 CPU 1.80GHz
stepping        : 2
cpu MHz         : 1794.151
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up pebs bts
bogomips        : 3588.30
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 32 bits virtual
power management:

which is apparently a good bit older than yours, so now I'm baffled again.  Could you show the complete cpuinfo printout from yours?  What age and model is it?

Another line of thought is that the problem is triggered by some system-level setting we're not thinking about; I suddenly recall the comments about locale settings in the gnome BZ entry for instance.  I'm just using vanilla C locale, what about you?

Comment 7 Andy Campbell 2011-08-04 23:00:49 UTC
Thanks for your tenacity Tom!

I'm not sure if this is the locale setting that you mean, but I found that root shows a US locale
[root@speedy ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
<snip>

and my test user showed the UK locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
<snip>

That got me excited!  I changed the local in the gnome control panel, and re-logged in -- unfortunately, no change.

Here is my cpu info
[root@speedy ~]# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 15
model		: 4
model name	: Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping	: 1
cpu MHz		: 3000.000
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 5
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc pebs bts pni dtes64 monitor ds_cpl cid xtpr
bogomips	: 5998.05
clflush size	: 64
cache_alignment	: 128
address sizes	: 36 bits physical, 32 bits virtual
power management:



I found another PC and installed 32 bit FC15 on that - using the same package versions.  libdbi works perfectly on that other machine...

The other machine has an older cpu (cpu family=6, model=15) and the locale is set to en_US.utf8.  

So, I think you are right - this seems to be machine or local specific. 

On the problem machine, the root user and my test user had different locales.  I think I changed the display locale via the gnome control panel.  Where is the correct location to set the system locale?

Thanks

A

Comment 8 Tom Lane 2011-08-05 00:16:42 UTC
Hmm. I'm not sure where's the "correct" place either, but it does seem possible that the issue is a discrepancy between the locale the running mysql daemon is using and gnucash's locale.  Try doing this to check what mysqld is seeing:

1. Do
ps auxww | grep mysqld
Look to see which PID (second column) is associated with the mysqld process (don't get confused by mysqld_safe).

2. Do
sudo cat /proc/PID/environ | tr '\0' ' '    
where PID is the PID you found above.

You'll see a list of name=value pairs ... what is the value for LANG?

As an example, when I do this I get

$ sudo cat /proc/2611/environ | tr '\0' ' '
PATH=/sbin:/usr/sbin:/bin:/usr/bin PWD=/ LANG=en_US.UTF-8 SHLVL=2 MYSQL_HOME=/usr _=/usr/bin/nohup

so my mysqld is in en_US.UTF-8 locale.

(I tried that together with en_GB.UTF-8 for gnucash, btw, with no luck...)

Comment 9 Tom Lane 2011-08-05 00:43:14 UTC
A different line of inquiry ... I poked into what exactly gnucash is doing to test compatibility, and it seems that they issue these queries:

CREATE TEMPORARY TABLE numtest ( test_int BIGINT, test_unsigned BIGINT, test_double FLOAT8 );
INSERT INTO numtest VALUES (-9223372036854775807, 9223372036854775807, 1.7976921348623158e+307);
SELECT * FROM numtest;

When I do this by hand in the mysql command-line client, I get

mysql> SELECT * FROM numtest;
+----------------------+---------------------+------------------------+
| test_int             | test_unsigned       | test_double            |
+----------------------+---------------------+------------------------+
| -9223372036854775807 | 9223372036854775807 | 1.7976921348623158e307 |
+----------------------+---------------------+------------------------+
1 row in set (0.00 sec)

I wonder whether you see the same thing on your problematic machine ...

Comment 10 Tom Lane 2011-08-05 17:20:02 UTC
Another question ... after poking into the gnucash sources a bit, I realized that it ought to be emitting some log messages into /tmp/gnucash.trace when it gets this error.  Would you look there for lines mentioning "Test_DBI_Library"?

Comment 11 Andy Campbell 2011-08-05 23:11:55 UTC
Tom, you nailed it with that one... and, I'm embarrassed...

I was chasing the wrong problem.

It turns out that my gnucash user in MySQL did not have the correct permissions on the database.  The user could login, but could not create new tables.  

When using the Save As MySQL option, GnuCash first opens the connection.  If the supplied credentials cannot login, it displays a meaningful permissions error.  If the user can login, and the schema is empty, GnuCash then tries to create the schema.  If that fails, it seems to display the wrong error message...

I found that in /tmp/gnucash.trace as you suggested.  That file contained this:
------
[andy@speedy ~]$ cat gnucash.trace 
* 23:52:03  WARN <gnc.backend.dbi> [conn_test_dbi_library()] Test_DBI_Library: Create table failed
* 23:53:19  CRIT <gnc.backend.dbi> gnc_dbi_unlock: assertion `dbi_conn_error( dcon, NULL ) == 0' failed
* 23:53:19  CRIT <gnc.engine.sx> gnc_sx_get_sxes_referencing_account: assertion `sxactions != NULL' failed
------

So the pop-up error "The library "libdbi" installed on your system doesn't correctly store large numbers...." is quite misleading - I believe it should really say "Create table failed"

I fixed the permissions, and now everything works

I am really sorry for the false alarm.  Thanks very much for your help!

Comment 12 Tom Lane 2011-08-05 23:32:18 UTC
(In reply to comment #11)
> [andy@speedy ~]$ cat gnucash.trace 
> * 23:52:03  WARN <gnc.backend.dbi> [conn_test_dbi_library()] Test_DBI_Library:
> Create table failed

Hah.  Well, at least we learned where to look for more info about gnucash problems.

> So the pop-up error "The library "libdbi" installed on your system doesn't
> correctly store large numbers...." is quite misleading - I believe it should
> really say "Create table failed"

Yeah, I've been less than impressed with the quality of most of gnucash's database-related error messages --- what's presented to the user contains next to no hard facts, and more often than not a mistaken claim about the origin of the problem.  But I'm not going to volunteer to fix it ...


Note You need to log in before you can comment on or make changes to this bug.