Help with libdbi code

Colin Law clanlaw at
Fri May 6 11:17:32 EDT 2016

I want to add some code to adjust the mysql sql_options if necessary,
in order to avoid bug #765872 [1].  I believe that this needs to be
called from gnc-backend-dbi.c in gnc_dbi_mysql_session_begin.  I need
to adjust the options after the mysql connection is made but before
the database is opened (since I need to do it before creating the
database in the case that the database does not already exist).  I
thought that I should do it before the call to dbi_conn_error_handler
at line 867 (maint branch) but cannot get it to work there.  If,
however, I put it after the line
result = dbi_conn_connect( be->conn );
then (provided the database already exists) it does work.

The failing code is

    result = dbi_conn_query( connection, "SELECT @@sql_mode");

If the database has not been opened then this returns NULL, but when I
then call dbi_conn_error this returns 0, which seems odd. The error
message is also empty.
If I run the SELECT query from the mysql command line before opening a
database then it works correctly.
Can anyone point out where I am going wrong?




More information about the gnucash-devel mailing list