[yunqa.de] Re: schema error

  • From: "Radovan Antloga" <radovan.antloga@xxxxxxxx>
  • To: <yunqa@xxxxxxxxxxxxx>
  • Date: Wed, 8 Jul 2009 22:58:12 +0200

Is there any reason why you did not use sqlite3_prepare_v2
in DISQLite3Database? I have replaced old prepare with v2
in that file. Did not find any problem after. Will you use v2 in
next release?

Best Regards,
Radovan Antloga

----- Original Message ----- From: "Delphi Inspiration" <delphi@xxxxxxxx>
To: <yunqa@xxxxxxxxxxxxx>; <yunqa@xxxxxxxxxxxxx>
Sent: Wednesday, July 08, 2009 6:00 PM
Subject: [yunqa.de] Re: schema error


At 15:50 08.07.2009, Radovan Antloga wrote:

I use my own sqlite tool for exploring databases.
I did not investigate enough to see where exactly
problem is. With this tool I often call GetTableNames
function. So I modified test program to see error.

Use sqlite3_perpare_v2() instead of sqlite3_prepare(). sqlite3_prepare_v2() will cause sqlite3_step() to reprepare the statement in case of SQLITE_SCHEMA.

Here are the details from the help file:

The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are recommended for all new programs. The two older interfaces are retained for backwards compatibility, but their use is discouraged. In the "v2" interfaces, the prepared statement that is returned (the sqlite3_stmt object) contains a copy of the original SQL text. This causes the sqlite3_step() interface to behave a differently in two ways:

1. If the database schema changes, instead of returning SQLITE_SCHEMA as it always used to do, sqlite3_step() will automatically recompile the SQL statement and try to run it again. If the schema has changed in a way that makes the statement no longer valid, sqlite3_step() will still return SQLITE_SCHEMA. But unlike the legacy behavior, SQLITE_SCHEMA is now a fatal error. Calling sqlite3_prepare_v2() again will not make the error go away. Note: use sqlite3_errmsg() to find the text of the parsing error that results in an SQLITE_SCHEMA return.

2. When an error occurs, sqlite3_step() will return one of the detailed error codes or extended error codes. The legacy behavior was that sqlite3_step() would only return a generic SQLITE_ERROR result code and you would have to make a second call to sqlite3_reset() in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.

Ralf

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa




__________ Informacija od ESET NOD32 Antivirus, zbirka virusnih definicij 4225 (20090708) __________

To sporoèilo je preveril ESET NOD32 Antivirus.

http://www.eset.si




_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: