On 2016/11/23 2:08 AM, Scott Hess wrote:
https://www.sqlite.org/pragma.html has:
"No error messages are generated if an unknown pragma is issued.
Unknown pragmas are simply ignored. This means if there is a typo in a
pragma statement the library does not inform the user of the fact."

I just lost some time due to this, even though I was fully aware of
it.  My code wasn't working, so I instrumented to report errors, and
gradually dug things deeper and deeper.  It wasn't until I was
verifying statements line-by-line against sqlite3 in a terminal window
that I saw that I was setting journal_mod rather than journal_mode!

I realize that pragma don't have the compatibility guarantees that
other syntax has.  But that means I actually _would_ want my code to
start barfing if a PRAGMA stops being supported.  Say I'm issuing
"PRAGMA secure_delete=ON" - presumably it's for a reason, and I'm
going to want to revisit that reason if it's no longer supported.

The problem is more the other way round - Backward compatibility is hard when you introduce a new pragma, and a previous version of SQLite "barfs" suddenly when it encounters that statement. Recent posts here re-emphasize the frequency with which old versions are still used out there....

Silently ignoring an unrecognized pragma is a great way to be able to introduce new functionality without worrying that the old will break.

That said - we have been lobbying a long time for a "Strict-Mode" in SQLite (though that would probably hurt the "lite-ness" of it), but this is another example where such a mode would prove very useful.

Also - there are many tools that will syntax-check and/or use code-highlighting for your SQL for SQLite (SQLitespeed found here: www.sqlc.rifin.co.za or sqliteexpert.com being two of them and others regularly pop up here) which would high-light such problems. If you do not wish to check ALL your statements, at least try those that break on one of these systems before starting a big dig.

Good luck!
Ryan

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to