[EMAIL PROTECTED] uttered:
I'm working on a new API routine for SQLite and I have
questions for the community.
The working name of the new api is sqlite3_prepare_v2().
sqlite3_prepare_v2() works like sqlite3_prepare() in that
it generates a prepared statement in an sqlite3_stmt
structure. The differences is in the behavior of the
resulting sqlite3_stmt and in particular a difference in
the way sqlite3_step() responds to the sqlite3_stmt. The
differences are these:
* You never get an SQLITE_SCHEMA error. sqlite3_prepare_v2
retains the original SQL and automatically reprepares and
rebinds it following a schema change.
Good.
* sqlite3_step() returns the correct error code right
away, rather than just returning SQLITE_ERROR and making
you call sqlite3_reset() to find the true reason for the
error.
In this way, I am hoping that sqlite3_prepare_v2() will work
around two of the most visible warts in the current API.
QUESTION 1: sqlite3_prepare_v2 is the merely the working name
for the new function. What should the official name be?
Some possibilities include:
sqlite3_prepare_ex1
sqlite3_prepare_ng
sqlite3_new_prepare
sqlite3_compile
I'd leave it as sqlite3_prepare, with default as the old behaviour, then
add a new function to switch an existing sqlite3_stmt to the new
behaviour, such as:
#define SQLITE3_STMT_RECOMPILE (1<<0)
#define SQLITE3_STMT_STEP_WITH_ERRORCODE (1<<1)
int sqlite3_stmt_setflags( int flags );
My personal opinion is that functions appended with _ex or 2 or obviously
extending an older version function looks sloppy. You just have to look at
Win32 for examples of bad APIs extended. It's not an entirely rationale
argument, I admit.
QUESTION 2: Are there any other API warts that need to be
worked around that can be fixed by this same change?
I trust that the return codes from sqlite3_step will now be able to be
arbitrarily extended, to cover such cases as:
http://www.sqlite.org/cvstrac/tktview?tn=1837,2
QUESTION 3: Suppose there is a schema change and the SQL
statement is automatically reprepared. But the schema change
is such that the SQL is no longer valid. (Perhaps one of the
tables mentioned in a SELECT statement was dropped.) What
error code should sqlite3_step() return in that case?
How about the error code that would be returned from sqlite3_prepare with
the given SQL.
--
D. Richard Hipp <[EMAIL PROTECTED]>
--
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST MS ATTACHMENTS
/ \
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------