jmethodID ctorStringBA /* the String(byte[],Charset) constructor */;
jmethodID stringGetBytes /* the String.getBytes(Charset) method */;
} g /* refs to global Java state */;
- jobject currentStmt /* Current Java sqlite3_stmt object being
- prepared, stepped, reset, or
- finalized. Needed for tracing, the
- alternative being that we create a new
- sqlite3_stmt wrapper object for every tracing
- call which needs a stmt object. This approach
- is rather invasive, however, requiring code
- in all stmt operations which can lead through
- the tracing API. */;
#ifdef SQLITE_ENABLE_FTS5
jobject jFtsExt /* Global ref to Java singleton for the
Fts5ExtensionApi instance. */;
UNREF_G(p->g.cLong);
UNREF_G(p->g.cString);
UNREF_G(p->g.oCharsetUtf8);
- UNREF_G(p->currentStmt);
#ifdef SQLITE_ENABLE_FTS5
UNREF_G(p->jFtsExt);
UNREF_G(p->jPhraseIter.klazz);
return sqlite3_initialize();
}
-/**
- Sets jc->currentStmt to the 2nd arugment and returns the previous
- value of jc->currentStmt. This must always be called in pairs: once
- to replace the current statement with the call-local one, and once
- to restore it. It must be used in any stmt-handling routines which
- may lead to the tracing callback being called, as the current stmt
- is needed for certain tracing flags. At a minumum those ops are:
- step, reset, finalize, prepare.
-*/
-static jobject stmt_set_current(S3JniEnvCache * const jc, jobject jStmt){
- jobject const old = jc->currentStmt;
- jc->currentStmt = jStmt;
- return old;
-}
-
JDECL(jint,1finalize)(JENV_CSELF, jobject jpStmt){
int rc = 0;
sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jpStmt);
if( pStmt ){
- S3JniEnvCache * const jc = S3JniGlobal_env_cache(env);
- jobject const pPrev = stmt_set_current(jc, jpStmt);
rc = sqlite3_finalize(pStmt);
NativePointerHolder_set(env, jpStmt, 0, S3JniClassNames.sqlite3_stmt);
- (void)stmt_set_current(jc, pPrev);
}
return rc;
}
jobject jStmt = 0;
const char * zTail = 0;
jbyte * const pBuf = JBA_TOC(baSql);
- S3JniEnvCache * const jc = S3JniGlobal_env_cache(env);
- jobject const pOldStmt = stmt_set_current(jc, 0);
int rc = SQLITE_ERROR;
assert(prepVersion==1 || prepVersion==2 || prepVersion==3);
if( !pBuf ){
}
#endif
OutputPointer_set_sqlite3_stmt(env, jOutStmt, jStmt);
- (void)stmt_set_current(jc, pOldStmt);
return (jint)rc;
}
JDECL(jint,1prepare)(JNIEnv * const env, jclass self, jobject jDb, jbyteArray baSql,
int rc = 0;
sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jpStmt);
if( pStmt ){
- S3JniEnvCache * const jc = S3JniGlobal_env_cache(env);
- jobject const pPrev = stmt_set_current(jc, jpStmt);
rc = sqlite3_reset(pStmt);
- (void)stmt_set_current(jc, pPrev);
}
return rc;
}
int rc = SQLITE_MISUSE;
sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jStmt);
if(pStmt){
- S3JniEnvCache * const jc = S3JniGlobal_env_cache(env);
- jobject const jPrevStmt = stmt_set_current(jc, jStmt);
rc = sqlite3_step(pStmt);
- (void)stmt_set_current(jc, jPrevStmt);
}
return rc;
}
jobject jPUnref = NULL /* potentially a local ref to jP */;
S3JniEnvCache * const jc = S3JniGlobal_env_cache(env);
int rc;
+ int createStmt = 0;
switch(traceflag){
case SQLITE_TRACE_STMT:
jX = s3jni_utf8_to_jstring(jc, (const char *)pX, -1);
if(!jX) return SQLITE_NOMEM;
/*MARKER(("TRACE_STMT@%p SQL=%p / %s\n", pP, jX, (const char *)pX));*/
- jP = jc->currentStmt;
+ createStmt = 1;
break;
case SQLITE_TRACE_PROFILE:
jX = (*env)->NewObject(env, jc->g.cLong, jc->g.ctorLong1,
(jlong)*((sqlite3_int64*)pX));
// hmm. ^^^ (*pX) really is zero.
// MARKER(("profile time = %llu\n", *((sqlite3_int64*)pX)));
- jP = jc->currentStmt;
- if(!jP){
- // This will be the case during prepare() b/c we don't have the
- // pointer in time to wrap it before tracing is triggered.
- jP = jPUnref = new_sqlite3_stmt_wrapper(env, pP);
- if(!jP){
- UNREF_L(jX);
- return SQLITE_NOMEM;
- }
- }
+ if(!jX) return SQLITE_NOMEM;
+ createStmt = 1;
break;
case SQLITE_TRACE_ROW:
- jP = jc->currentStmt;
+ createStmt = 1;
break;
case SQLITE_TRACE_CLOSE:
jP = ps->jDb;
assert(!"cannot happen - unkown trace flag");
return SQLITE_ERROR;
}
+ if( createStmt ){
+ jP = jPUnref = new_sqlite3_stmt_wrapper(env, pP);
+ if(!jP){
+ UNREF_L(jX);
+ return SQLITE_NOMEM;
+ }
+ }
assert(jP);
rc = (int)(*env)->CallIntMethod(env, ps->trace.jObj,
ps->trace.midCallback,
-C Adapt\sJNI\sbuild\sto\sbe\sbuildable\swith\sor\swithout\sSQLTester.
-D 2023-08-08T21:22:56.734
+C Remove\sthe\scurrent-statement\stracking\sfrom\sthe\sJNI\sinternals\sbecause\sit\swill\sbreak\sdown\sin\sthe\sface\sof\sclient-side\smixed-mode\snative/java\scode,\se.g.\sin\scases\slike\sSQLTester.\sThis\smakes\stracing\sof\ssqlite3_stmt\sa\smicron\sslower\sbut\salso\sreliably\scorrect.
+D 2023-08-08T22:10:27.484
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
F ext/jni/GNUmakefile 52f402abb8c4695a58f734d20455cf1a5afaaa10ceacc47bcbf1b06a8d5d27e8
F ext/jni/README.md e965674505e105626127ad45e628e4d19fcd379cdafc4d23c814c1ac2c55681d
-F ext/jni/src/c/sqlite3-jni.c dc1e8678a6acf182c7933cecba2664d760507abbc9af43201d3ac2c14fc64ea0
+F ext/jni/src/c/sqlite3-jni.c 07871efe50bb090023259c95df8b851c617917f762b60a3460c9778b2ae6356b
F ext/jni/src/c/sqlite3-jni.h ec38592e88d32f09ba4bde13f2e135bb7cf8712356b807df521b3fc99edeab32
F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892
F ext/jni/src/org/sqlite/jni/AutoExtension.java 3409ad8954d6466bf772e6be9379e0e337312b446b668287062845755a16844d
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 0dba3073f44685a51a5db7ff8886295fe04dfd43f69cbf53ad3d5afce741076b
-R 2cf9a6c26ac6b2b58530b5684e479d7d
+P adae7d78692af73e770a9cc0a4264ab32ecc18a5c0deb64f3c1e790d959bab43
+R a655364567e3dc78a32998da5ce271ea
U stephan
-Z 17c788afc9fee2046b5ea5feb4663dee
+Z 4250ef5d2c5cf8abb783ee5c1cb8e821
# Remove this line to create a well-formed Fossil manifest.