On Thu, Jan 14, 2016 at 2:02 PM, sanhua.zh <sanhua.zh at foxmail.com> wrote:

> I don?t mean to be rude. BUT, I can?t agree with your opinion, Simon.
>
>
> 1. Not all other codes except SQLITE_OK, SQLITE_ROW, SQLITE_DONE should be
> treated as fatal errors.
>   As an example, SQLITE_BUSY indicates that this op is temporarily failed,
> but it can be done later. (Note that sometimes you should not retry
> forever.)
>

Simon's fundamentally right, though. The cases you mention here are not
ERROR codes - they're result codes which indicate varying types of success
(or recoverable errors). The errors you ignored early on are not (for most
cases) recoverable errors. If you continue to use an sqlite3 handle after
its API has returned a true error code, you're invoking Undefined Behaviour.

Aside from that, all OSes i've worked with tend to fail in strange ways
when their disks are out of space.

2. Quit while get error is also not a great enough idea.


sqlite has told you "something bad has happened." If you continue, you do
so at your own risk. Weird things happen as various apps and daemons
compete for that last byte of drive space.


> Because not all pragram is a command line tool. It can be a user-oriented
> application instead of a developer-oriented tool. Users don?t wish to meet
> a crash.
>

Pop up a dialog saying, "I/O error!" and _then_ quit. That's better than
the app corrupting their data.


> So, find out how SQLITE_FULL leading to SQLITE_CORRUPT, and fix it or
> avoid it (if it can?t be fixed) might be the better solution.
>

FULL means the drive is full. Most apps can't do much about that. It
generally needs to be resolved by user action - freeing up space.

CORRUPT means sqlite cannot work with it - there is no generic recovery
strategy aside from throwing the DB away and building it anew.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf

Reply via email to