Help with libdbi code

John Ralls jralls at
Sat May 7 10:56:33 EDT 2016

> On May 7, 2016, at 9:27 AM, Geert Janssens <geert.gnucash at> wrote:
> On Saturday 07 May 2016 14:00:41 Colin Law wrote:
> > On 7 May 2016 at 12:23, Colin Law <clanlaw at <mailto:clanlaw at>> wrote:
> > > On 7 May 2016 at 12:01, John Ralls <jralls at <mailto:jralls at>> wrote:
> > >> Hmm, the trace files from the bug report seemed to show that the
> > >> error was from saving a slot row with a 0-valued date rather than
> > >> from creating a table with a default value of 0.> 
> > > No doubt you are right (again), it is probably not the actual
> > > creation but the writing that is the issue.  Me jumping to
> > > conclusions again. I will investigate whether it is necessary to
> > > change the options for creating the db.
> > 
> > Actually, looking at the trace file again, it appears we were both
> > correct.  The first error in the file is
> >  CRIT <gnc.backend.dbi> [mysql_error_fn()] DBI error: 1067: Invalid
> > default value for 'date'
> > where it is complaining about the default value being 0, and later
> > there are errors complaining about writing into the slots table with a
> > NULL value for a date.
> > 
> Actually, I read the trace file from the bug report as follows:
> 1. the first two errors are a complaint about the invalid default value of 0.
> 2. The next error message suggests that due to these errors with default values the transactions table is not created (BAD!)
> 3. Similar sets of errors follow for the splits table and the slots table, meaning these tables are not create as well
> 4. Then come the INSERT errors. GnuCash fails to insert values into the slots table, which at that point makes sense because those tables weren't created.
> I don't think this last error complains about an attempt to insert NULL as a value, rather it complains that whole table doesn't exist.
> So I do believe it fails while creating the tables as you originally assumed. Later errors are just a consequence of that.

If that's correct, and it sure sounds plausible, it might be a really simple fix that doesn't need any server config changes.

Try changing gnc-backend-dbi.c line 2702 from 
    type_name = "TIMESTAMP NULL DEFAULT 0";

John Ralls

More information about the gnucash-devel mailing list