mysql Ver 15.1 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper GnuCash 4.4 Build ID: 4.4+(2020-12-28) Error message from GnuCash: An error occurred while processing mysql://gord@localhost/gnucash. - I have an XML database loaded into GnuCash. - I try to save the database as mysql (MariaDB) in the same machine running debian linux (I get the same error message if I try to save the database from a windows machine to the MariaDB on the debian machine) -- File -> Save As... Then select mysql as the Data Format. Then enter the Username and Password required for the database. -- GnuCash thinks for a while then gives me the error message in a popup window It appears that mysql (or somewhere in the backend of gnuCash) does not like a back slash character as the last character in a field. The data I was trying to save had one entry with a 'notes' field that had a backslash as the last character. The text was "2 books one for A one for\". It appears when I save this as an XML file there is no problem but if I try to save this as a mysql I get an error message. A backslash other than at the end of the field does not appear to cause a problem. BTW if I remove the backslash and successfully save to a mysql file and then go back into the register GnuCash will not let me add a backslash to a field. However, if I save it as an XML file the backslash is allowed. Here are the relevant lines from the 'gnucash.trace' file: * 09:09:43 ERROR <gnc.backend.dbi> [error_handler()] DBI error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1970-01-01 00:00:00',0,1)' at line 1 * 09:09:43 ERROR <gnc.backend.dbi> [GncDbiSqlConnection::execute_nonselect_statement()] Error executing SQL INSERT INTO slots(obj_guid,name,slot_type,int64_val,string_val,timespec_val,numeric_val_num,numeric_val_denom) VALUES('c4f3c08454534822a2ff8cbb662b44cf','notes',4,0,'2 books one for A one for\','1970-01-01 00:00:00',0,1) * 09:09:43 ERROR <gnc.backend.sql> [GncSqlBackend::execute_nonselect_statement()] SQL error: INSERT INTO slots(obj_guid,name,slot_type,int64_val,string_val,timespec_val,numeric_val_num,numeric_val_denom) VALUES('c4f3c08454534822a2ff8cbb662b44cf','notes',4,0,'2 books one for A one for\','1970-01-01 00:00:00',0,1) * 09:09:43 ERROR <gnc.backend.sql> [GncSqlTransBackend::commit()] Transaction Chapters dated 2011-02-21 in account Gifts not saved due to Slots save failed. Check trace log for SQL errors.
MySQL defaults to treating a backslash in a string element the same way the C compiler does, as an introduction to a small set of text escapes: For example \n represents a newline and \t represents a tab. If a backslash is found without one of the known codes it's an error, as seen here. This feature is not part of standard SQL so I've disabled it beginning with GnuCash 4.5: A backslash will be treated the same as any other character. Until then you can disable the feature (set NO_BACKSLASH_ESCAPES) yourself in your existing GnuCash databases or you can clean your book.