Why Corrupted DB File Cause No Error?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Why Corrupted DB File Cause No Error?

sanhua.zh
I make a database, create a table and insert some data.
And then delete a section of data manually using binary editor, result that I can’t get any of column but SQLite does not give me a error message.


console log before db file corrupted:
sqlite .open test.db
sqlite select * from testtable;
autotestmember1|1449050967|0|0|0||
newsapp|1449049422|2|0|0||
sqlite .exit;


console logafter db file corrupted:
sqlite .opentest.db
sqlite select * fromtesttable;
||||||
||||||
||||||
sqlite .exit;


or


sqlite .opentest.db
sqlite select * fromtesttable;
sqlite .exit;


Why it does not show error, some thing like“Error: database disk image is malformed”? Is it a bug in SQLite?
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

Stephan Beal-3
On Wed, Dec 2, 2015 at 11:59 AM, sanhua.zh <[hidden email]> wrote:

> Why it does not show error, some thing like“Error: database disk image is
> malformed”? Is it a bug in SQLite?
>

because you didn't corrupt a part it actually read. Imagine if you have a
20GB db and you expect it to report such errors when you open the db. It
would have to read the whole db to figure that out, slowing sqlite to a
crawl. Since most dbs are not corrupt, it would be slowest for the average
case and faster for the error case (since it must stop reading on the first
error).

--
----- 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
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

sanhua.zh
In reply to this post by sanhua.zh
Thanks for your answer.


But you can see my example, I should get 2 column from testtable, but I get none. It means that db is already reading the corrupted part but get nothing.


原始邮件
发件人:Stephan [hidden email]
收件人:SQLite mailing [hidden email]
发送时间:2015年12月2日(周三) 19:38
主题:Re: [sqlite] Why Corrupted DB File Cause No Error?


On Wed, Dec 2, 2015 at 11:59 AM, sanhua.zh [hidden email] wrote:  Why it does not show error, some thing like“Error: database disk image is  malformed”? Is it a bug in SQLite?  because you didn't corrupt a part it actually read. Imagine if you have a 20GB db and you expect it to report such errors when you open the db. It would have to read the whole db to figure that out, slowing sqlite to a crawl. Since most dbs are not corrupt, it would be slowest for the average case and faster for the error case (since it must stop reading on the first error). -- ----- 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 _______________________________________________ sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

Simon Slavin-3
In reply to this post by Stephan Beal-3

On 2 Dec 2015, at 11:38am, Stephan Beal <[hidden email]> wrote:

> On Wed, Dec 2, 2015 at 11:59 AM, sanhua.zh <[hidden email]> wrote:
>
>> Why it does not show error, some thing like“Error: database disk image is
>> malformed”? Is it a bug in SQLite?
>
> because you didn't corrupt a part it actually read.

Looking at the transcription of the sqlite3.exe sessions included in the post, it would appear that the corruption did change the result.  Therefore the corruption was in a part it actually read.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

sanhua.zh
In reply to this post by sanhua.zh
I guess so too.
But, It can be happen in real scene.
A part of data may be lost by a low chance accident in the application lifecycle. It would be very hard to find out this problem and fix it because of causing no error.




原始邮件
发件人:Simon [hidden email]
收件人:SQLite mailing [hidden email]
发送时间:2015年12月2日(周三) 19:42
主题:Re: [sqlite] Why Corrupted DB File Cause No Error?


On 2 Dec 2015, at 11:38am, Stephan Beal [hidden email] wrote:  On Wed, Dec 2, 2015 at 11:59 AM, sanhua.zh [hidden email] wrote:   Why it does not show error, some thing like“Error: database disk image is  malformed”? Is it a bug in SQLite?   because you didn't corrupt a part it actually read. Looking at the transcription of the sqlite3.exe sessions included in the post, it would appear that the corruption did change the result. Therefore the corruption was in a part it actually read. Simon. _______________________________________________ sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

Stephan Beal-3
On Wed, Dec 2, 2015 at 12:56 PM, sanhua.zh <[hidden email]> wrote:

> I guess so too.
> But, It can be happen in real scene.
>

A part of data may be lost by a low chance accident in the application
> lifecycle. It would be very hard to find out this problem and fix it
> because of causing no error.
>


It's a hypothetical problem. It doesn't happen with correct usage, and
sqlite cannot protect users from all possible misuse.

--
----- 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
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

Richard Hipp-3
In reply to this post by sanhua.zh
On 12/2/15, sanhua.zh <[hidden email]> wrote:
> I make a database, create a table and insert some data.
> And then delete a section of data manually using binary editor,

Did you really "delete" the data, or did you simply change the data to
have all NULL content?

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why Corrupted DB File Cause No Error?

sanhua.zh
In reply to this post by sanhua.zh
I try both.
Depending on the data deleting or rewriting, I get 2 empty column, or just empty(no column).


原始邮件
发件人:Richard [hidden email]
收件人:SQLite mailing [hidden email]
发送时间:2015年12月2日(周三) 21:31
主题:Re: [sqlite] Why Corrupted DB File Cause No Error?


On 12/2/15, sanhua.zh [hidden email] wrote:  I make a database, create a table and insert some data.  And then delete a section of data manually using binary editor, Did you really "delete" the data, or did you simply change the data to have all NULL content? -- D. Richard Hipp [hidden email] _______________________________________________ sqlite-users mailing list [hidden email] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users