vergoh / vnstat

vnStat - a network traffic monitor for Linux and BSD
GNU General Public License v2.0
1.45k stars 123 forks source link

vnstat: no longer works after databases/sqlite3 disabled DQS #243

Closed joeroback closed 1 year ago

joeroback commented 1 year ago

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269966

causing issues on FreeBSD and other systems like OPNsense (based on FreeBSD).

FreeBSD bug has an attachment bug fix

vergoh commented 1 year ago

Thanks for this bug report. Looking at https://sqlite.org/quirks.html#dblquote, this interpretation difference between single and double quotes is something I wasn't aware of and I've clearly somehow managed to pick the less future proof option. However, I think that the correct solution would be to refactor the queries having column names in single-quotes instead of using sqlite3_db_config() to change the feature configuration. According to https://sqlite.org/c3ref/c_dbconfig_defensive.html SQLITE_DBCONFIG_DQS_DML and SQLITE_DBCONFIG_DQS_DDL both can be used to activate legacy features so the better approach would be not to use legacy in the first place (assuming there's no backwards incompatibility with older sqlite3 releases).

Since this situation is at least currently reproducable in FreeBSD, I should be able to replicate the situation and test for a fix myself.

vergoh commented 1 year ago

The test suite (make check) of affected vnStat releases (past releases included) will fail if DQS wasn't enabled so the status can be tested without install. The committed refactoring of queries causing the issue has been tested starting from SQLite version 3.6.22 without causing backwards incompatible side effects. DQS doesn't affect the database structure so this correction doesn't require any vnStat database updates.