[EMAIL PROTECTED] writes:
> The sqlite3_prepare()/sqlite3_step() API only executes a single
> statement. The sqlite3_prepare() routine returns a pointer to
> the next statement if you give it a list of statements.
I see. It looks like the JDBC driver punts on using the pzTail
parameter¹:
,----
| JNIEXPORT jlong JNICALL Java_org_sqlite_NativeDB_prepare(
| JNIEnv *env, jobject this, jstring sql)
| {
| sqlite3* db = gethandle(env, this);
| sqlite3_stmt* stmt;
|
| const char *strsql = (*env)->GetStringUTFChars(env, sql, 0);
| int status = sqlite3_prepare(db, strsql, -1, &stmt, 0);
| (*env)->ReleaseStringUTFChars(env, sql, strsql);
|
| if (status != SQLITE_OK) {
| throwex(env, this);
| return fromref(0);
| }
| return fromref(stmt);
| }
`----
Given that the string it's feeding to sqlite3_prepare might be
allocated in the GetStringUTFChars() call before -- and released right
afterward, guessing for now at what these functions do -- it wouldn't
be prudent for the library to try to hold onto a pointer into that
ephemeral string. It would instead need to figure out an offset for
safer keeping.
> The sqlite3_exec() interface executes every statement in the string
> you hand it.
Unfortunately this library has yet to wrap this function.
Ouch.
Footnotes:
¹ http://www.sqlite.org/capi3ref.html#sqlite3_prepare
--
Steven E. Harris
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------