Expose sqlite3_get/set_auxdata() to JNI.

FossilOrigin-Name: 0de3271717e0298070097d7ea0ecb996d2e95cf65384e494515a554d0a1dffed
This commit is contained in:
stephan 2023-09-03 11:58:33 +00:00
parent e30436b605
commit 83a8b6dd82
5 changed files with 73 additions and 35 deletions

View File

@ -1654,9 +1654,9 @@ static const char * const ResultJavaValuePtrStr = "org.sqlite.jni.ResultJavaVal"
/*
** If v is not NULL, it must be a jobject global reference. Its
** reference is relinquished and v is freed.
** reference is relinquished.
*/
static void ResultJavaValue_finalizer(void *v){
static void S3Jni_jobject_finalizer(void *v){
if( v ){
S3JniDeclLocal_env;
S3JniUnrefGlobal((jobject)v);
@ -2351,7 +2351,7 @@ S3JniApi(sqlite3_bind_java_object(),jint,1bind_1java_1object)(
jobject const rv = val ? S3JniRefGlobal(val) : 0;
if( rv ){
rc = sqlite3_bind_pointer(pStmt, ndx, rv, ResultJavaValuePtrStr,
ResultJavaValue_finalizer);
S3Jni_jobject_finalizer);
}else if(val){
rc = SQLITE_NOMEM;
}
@ -3333,6 +3333,12 @@ S3JniApi(sqlite3_finalize(),jint,1finalize)(
return rc;
}
S3JniApi(sqlite3_get_auxdata(),jobject,1get_1auxdata)(
JniArgsEnvClass, jobject jCx, jint n
){
return sqlite3_get_auxdata(PtrGet_sqlite3_context(jCx), (int)n);
}
S3JniApi(sqlite3_initialize(),jint,1initialize)(
JniArgsEnvClass
){
@ -4063,7 +4069,7 @@ S3JniApi(sqlite3_result_java_object(),void,1result_1java_1object)(
jobject const rjv = S3JniRefGlobal(v);
if( rjv ){
sqlite3_result_pointer(PtrGet_sqlite3_context(jpCx), rjv,
ResultJavaValuePtrStr, ResultJavaValue_finalizer);
ResultJavaValuePtrStr, S3Jni_jobject_finalizer);
}else{
sqlite3_result_error_nomem(PtrGet_sqlite3_context(jpCx));
}
@ -4193,6 +4199,12 @@ S3JniApi(sqlite3_set_authorizer(),jint,1set_1authorizer)(
return rc;
}
S3JniApi(sqlite3_set_auxdata(),void,1set_1auxdata)(
JniArgsEnvClass, jobject jCx, jint n, jobject jAux
){
sqlite3_set_auxdata(PtrGet_sqlite3_context(jCx), (int)n,
S3JniRefGlobal(jAux), S3Jni_jobject_finalizer);
}
S3JniApi(sqlite3_set_last_insert_rowid(),void,1set_1last_1insert_1rowid)(
JniArgsEnvClass, jobject jpDb, jlong rowId

View File

@ -1283,6 +1283,22 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1db_1status
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errcode
(JNIEnv *, jclass, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_errmsg
* Signature: (Lorg/sqlite/jni/sqlite3;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errmsg
(JNIEnv *, jclass, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_errstr
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errstr
(JNIEnv *, jclass, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_expanded_sql
@ -1307,22 +1323,6 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1extended_1errcode
JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1extended_1result_1codes
(JNIEnv *, jclass, jobject, jboolean);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_errmsg
* Signature: (Lorg/sqlite/jni/sqlite3;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errmsg
(JNIEnv *, jclass, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_errstr
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errstr
(JNIEnv *, jclass, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_get_autocommit
@ -1331,6 +1331,14 @@ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errstr
JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1get_1autocommit
(JNIEnv *, jclass, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_get_auxdata
* Signature: (Lorg/sqlite/jni/sqlite3_context;I)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1get_1auxdata
(JNIEnv *, jclass, jobject, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_error_offset
@ -1691,6 +1699,14 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1rollback_1hook
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1set_1authorizer
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_set_auxdata
* Signature: (Lorg/sqlite/jni/sqlite3_context;ILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1set_1auxdata
(JNIEnv *, jclass, jobject, jint, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_set_last_insert_rowid

View File

@ -665,6 +665,12 @@ public final class SQLite3Jni {
@Canonical
public static native int sqlite3_errcode(@NotNull sqlite3 db);
@Canonical
public static native String sqlite3_errmsg(@NotNull sqlite3 db);
@Canonical
public static native String sqlite3_errstr(int resultCode);
@Canonical
public static native String sqlite3_expanded_sql(@NotNull sqlite3_stmt stmt);
@ -676,15 +682,14 @@ public final class SQLite3Jni {
@NotNull sqlite3 db, boolean onoff
);
@Canonical
public static native String sqlite3_errmsg(@NotNull sqlite3 db);
@Canonical
public static native String sqlite3_errstr(int resultCode);
@Canonical
public static native boolean sqlite3_get_autocommit(@NotNull sqlite3 db);
@Canonical
public static native Object sqlite3_get_auxdata(
@NotNull sqlite3_context cx, int n
);
/**
Note that the returned byte offset values assume UTF-8-encoded
inputs, so won't always match character offsets in Java Strings.
@ -1365,6 +1370,11 @@ public final class SQLite3Jni {
@NotNull sqlite3 db, @Nullable AuthorizerCallback auth
);
@Canonical
public static native void sqlite3_set_auxdata(
@NotNull sqlite3_context cx, int n, @Nullable Object data
);
@Canonical
public static native void sqlite3_set_last_insert_rowid(
@NotNull sqlite3 db, long rowid

View File

@ -1,5 +1,5 @@
C Expose\ssqlite3_get_autocommit()\sto\sJNI.
D 2023-09-03T11:16:48.124
C Expose\ssqlite3_get/set_auxdata()\sto\sJNI.
D 2023-09-03T11:58:33.070
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -237,8 +237,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3
F ext/jni/GNUmakefile 7bd7f0c28d664b71b08f9d8ff507eb8329f1f3e7b5d88f774f90a1a5259a3fe8
F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9
F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa
F ext/jni/src/c/sqlite3-jni.c 33db80b56070ce82722f981dce36a5435d99b507d4090ef9ce6c70b6c2c8b6ed
F ext/jni/src/c/sqlite3-jni.h d4b4533a298519d112be91aec6ca858043f03b490cef06fb6b0b304bb779230d
F ext/jni/src/c/sqlite3-jni.c 649b305d2281d350067b63b1d077410a38ae9a06366634ee5e22131ba070c1ef
F ext/jni/src/c/sqlite3-jni.h c95632356c61ccc5975c41bf35e5bc79d24fd1e8375d068731ea0b2f625b51f7
F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436
F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4
F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38
@ -262,7 +262,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c
F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86
F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4
F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 9060a509eb15e94cf56fead3c1987cae327c5f325526ad2058dde03191371e88
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java e84f456b5f1636f45c50f1d532247631a1569c99a3a504d04c9ed4f4ed3fbf02
F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c
F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab
F ext/jni/src/org/sqlite/jni/Tester1.java 0c37badac93c948d340688967fa205062fa70d6fd1c72730b5ececc1419319cd
@ -2117,8 +2117,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P c7f9bbbbf0252c9749450e3ec994bf5ac945bd62428657ddff469291a0fd4b0d
R 15dd68606e4abb0a87ecc7f9abf4f88a
P 67391c6588c71af411767d1e4b63c5041a8a9e669102da318e3482ccfc9d9bb9
R 85fc08c8b7dbbee0a10820fd8df0b1f2
U stephan
Z 0078f656620477114933b33a92cabf9c
Z d25cca227f7f4f43edfdc564cc64fc9b
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
67391c6588c71af411767d1e4b63c5041a8a9e669102da318e3482ccfc9d9bb9
0de3271717e0298070097d7ea0ecb996d2e95cf65384e494515a554d0a1dffed