Sqlite still crashes hard when the disk is full, so the disk space check IS necessary:

(gdb) bt
#0  0x000000351ca1cf49 in memcpy (__len=48, __src=0x6895b0, __dest=0x7ffff196c030) at /usr/include/bits/string3.h:52
#1  walIndexWriteHdr (pWal=pWal@entry=0x689568) at sqlite3.c:45983
#2  0x000000351ca3aa84 in walIndexRecover (pWal=0x689568) at sqlite3.c:46524
#3  walIndexReadHdr (pWal=pWal@entry=0x689568, pChanged=pChanged@entry=0x7fffffffd74c) at sqlite3.c:47329
#4  0x000000351ca3b173 in walTryBeginRead (useWal=<optimized out>, pChanged=0x7fffffffd74c, pWal=0x689568, cnt=<optimized out>) at sqlite3.c:47442
#5  walTryBeginRead (pWal=0x689568, pChanged=0x7fffffffd74c, useWal=<optimized out>, cnt=<optimized out>) at sqlite3.c:47405
#6  0x000000351ca414c2 in sqlite3WalBeginReadTransaction (pChanged=0x7fffffffd74c, pWal=0x689568) at sqlite3.c:47599
#7  pagerBeginReadTransaction (pPager=0x686b58) at sqlite3.c:41469
#8  sqlite3PagerSharedLock (pPager=0x686b58) at sqlite3.c:43338
#9  0x000000351ca502f1 in lockBtree (pBt=0x686698) at sqlite3.c:51672
#10 sqlite3BtreeBeginTrans (p=0x68de18, wrflag=wrflag@entry=0) at sqlite3.c:51972
#11 0x000000351ca6c3d7 in sqlite3InitOne (db=db@entry=0x686088, iDb=iDb@entry=0, pzErrMsg=pzErrMsg@entry=0x6877f0) at sqlite3.c:93862
#12 0x000000351ca6c731 in sqlite3Init (db=0x686088, pzErrMsg=pzErrMsg@entry=0x6877f0) at sqlite3.c:94035
#13 0x000000351ca6cb51 in sqlite3ReadSchema (pParse=pParse@entry=0x6877e8) at sqlite3.c:94072
#14 0x000000351ca5baff in sqlite3Pragma (pParse=pParse@entry=0x6877e8, pId1=pId1@entry=0x687b00, pId2=pId2@entry=0x687b20, pValue=pValue@entry=0x687b60, minusFlag=minusFlag@entry=0) at sqlite3.c:92643
#15 0x000000351ca5e51f in yy_reduce (yyruleno=255, yypParser=0x687a88) at sqlite3.c:110777
#16 sqlite3Parser (yyp=yyp@entry=0x687a88, yymajor=yymajor@entry=1, yyminor=..., pParse=pParse@entry=0x6877e8) at sqlite3.c:45624
#17 0x000000351ca63672 in sqlite3RunParser (pParse=pParse@entry=0x6877e8, zSql=zSql@entry=0x69d7f8 "PRAGMA journal_mode=WAL", pzErrMsg=pzErrMsg@entry=0x7fffffffdc58) at sqlite3.c:111997
#18 0x000000351ca651c2 in sqlite3Prepare (db=db@entry=0x686088, zSql=zSql@entry=0x69d7f8 "PRAGMA journal_mode=WAL", nBytes=nBytes@entry=-1, saveSqlFlag=saveSqlFlag@entry=1, pReprepare=pReprepare@entry=0x0, ppStmt=ppStmt@entry=0x687740, pzTail=pzTail@entry=0x7fffffffdd28)
    at sqlite3.c:94249
#19 0x000000351ca65429 in sqlite3LockAndPrepare (pzTail=0x7fffffffdd28, ppStmt=0x687740, pOld=0x0, saveSqlFlag=1, nBytes=-1, zSql=0x69d7f8 "PRAGMA journal_mode=WAL", db=0x686088) at sqlite3.c:94341
#20 sqlite3LockAndPrepare (db=0x686088, zSql=0x69d7f8 "PRAGMA journal_mode=WAL", nBytes=-1, saveSqlFlag=1, pOld=0x0, ppStmt=0x687740, pzTail=0x7fffffffdd28) at sqlite3.c:28788
#21 0x000000351ca65567 in sqlite3Prepare16 (db=0x686088, zSql=0x67b39a, nBytes=<optimized out>, saveSqlFlag=1, ppStmt=0x687740, pzTail=0x7fffffffdd88) at sqlite3.c:94450
#22 0x00007ffff07697be in QSQLiteResult::prepare (this=0x687630, query=...) at ../../../sql/drivers/sqlite/qsql_sqlite.cpp:360
#23 0x00007ffff07686da in QSQLiteResult::reset (this=0x687630, query=...) at ../../../sql/drivers/sqlite/qsql_sqlite.cpp:342
#24 0x000000330ae1116e in QSqlQuery::exec (this=0x7fffffffdf10, query=...) at kernel/qsqlquery.cpp:378
#25 0x0000000000401578 in main (argc=1, argv=<optimized out>) at test.cpp:17