GNOME Bugzilla – Bug 790506
GnuCash 2.6.18 does not work with PostgreSQL lc_messages != 'english'
Last modified: 2018-06-30 00:00:44 UTC
Created attachment 363932 [details] gnclock table Hi, Using gnucash 2.6.18 and postgresql 9.5 (the remote access is configured), on a clear installation i get this message: "The server at URL postgres://postgres@10.8.0.1/gnucash experienced an error or encountered bad or corrupt data." I tried with another user with all privileges and get the same error, I tried installing a postgresql server local and get the same error, If exists a database with name gnucash i get a message to overwrite the database, when i click in yes, get the same error, but it create an empty table named "gnclock"
Created attachment 363933 [details] gnucash error
Please attach the trace file. See https://wiki.gnucash.org/wiki/Tracefile for where to find it. Please also attach the database logs covering the times of the failed sessions. Please note that we can't provide any support for database configuration or administration. Database server users are expected to be experts in the operation of their servers or to employ such an expert.
Created attachment 363934 [details] gnucash trace Added the gnucash trace file
OK, the database is refusing to accept the transactions. The logs should show why. Did you remember to grant create database on the user?
yes, i tried with 2 users, the super user postgres and a gnucash user with create database privilege
Created attachment 363944 [details] users on pgadmin
Created attachment 363945 [details] postgresql log I can see that it try to rename the table 'numtest' 2 times, where the errors begin 017-11-17 12:29:50 CST LOG: sentencia: SELECT relname FROM pg_class WHERE relname !~ '^pg_' AND relkind = 'r' AND relowner = (SELECT datdba FROM pg_database WHERE datname = 'gnucash') ORDER BY relname 2017-11-17 12:29:50 CST LOG: sentencia: ALTER TABLE numtest RENAME TO numtest_back 2017-11-17 12:29:50 CST LOG: sentencia: ALTER TABLE numtest RENAME TO numtest_back 2017-11-17 12:29:50 CST ERROR: no existe la relación «numtest»
OK, I managed to replicate your failure by trying to overwrite an existing database with a fresh save-as. Try dropping the database or using a new name.
Created attachment 363957 [details] gnucash log without overwrite database i got the same error, but the log is different, gnucash does not create the database.
Created attachment 363958 [details] postgresql log postgresql log, gnucash does not send a "create database" statement
That looks like you tried "File>Open" rather than "File>Save As...".
Yes, i know, but i did a "File>Save As..."
The line CRIT <gnc.core-utils> gnc_uri_get_components: assertion 'uri != NULL && strlen (uri) > 0' failed might be a clue. That implies that there was a problem retrieving the values from the database dialog box (the one that collects host, database name, user name, and password). I wonder if there might be a localization problem. Can you switch the locale to English_UnitedStates (you can edit c:\Program Files (x86)\gnucash\etc\gnucash\environment if you don't want to change the computer's locale).
Created attachment 363963 [details] gnucash trace after change locale i changed the locale to en_US and i got the same error, that means that is not retrieving the values to make the URI?
I think it's still a localization issue, but not one that can be solved by changing GnuCash's locale. I think that the problem is that Postgresql (or maybe libdbdpgsql) doesn't set an error code for "database not found", so GnuCash has to parse the error message. I was just looking at that in the debugger this afternoon while I was following the file opening process. It does that in English so the Spanish error message isn't detected and GnuCash doesn't set the "database exists" flag to False and so it doesn't realize that it needs to create the database. If it's practical for you to change the locale of the postgresql server to English that might be a workaround and a useful test. I'll see if I can find a way to get the flag set in a locale-neutral way for 2.8.
Created attachment 363981 [details] postgresql config locale Yes, that is the problem, i changed the postgresql.conf, switch the locales from lc_messages = 'Spanish_Nicaragua.1252' lc_monetary = 'Spanish_Nicaragua.1252' lc_numeric = 'Spanish_Nicaragua.1252' lc_time = 'Spanish_Nicaragua.1252' to lc_messages = 'english' lc_monetary = 'english' lc_numeric = 'english' lc_time = 'english' It works!
Jorge, can you test it with: lc_messages = 'english' lc_monetary = 'Spanish_Nicaragua.1252' lc_numeric = 'Spanish_Nicaragua.1252' lc_time = 'Spanish_Nicaragua.1252'
Created attachment 364350 [details] postgresql log Hi Frank, I tested with that configuration and works fine,
Next question: Is this specific to Windows or are other OSes also affected?
Frank, It's generic. See https://github.com/Gnucash/gnucash/blob/maint/src/backend/dbi/gnc-backend-dbi.c#L1333. The obvious fix is to use error codes instead, but as I said in comment 15 the error code isn't set for this particular error. Since the error level--"FATAL"--isn't localized we could assume that that combined with err_num == 0 means that there's no DB and it needs to be created. That's a bit brittle but it might be our best choice.
The numtest table was the source of bug 794765 as well. Perhaps my (potential) fix for that one will help here as well ? I wasn't aware of the lc_messages influence though so possibly my idea was way off.
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=790506. Please continue processing the bug there and please update any external references or bookmarks.