mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Replace all of the JNI XyzHook/Handler classes with snake_cased ones which follow unified naming conventions to make them easier to apply.
FossilOrigin-Name: 76e62a381249b3b4262b22bdffe7fc2816c820115c9df266956ab8817b127aca
This commit is contained in:
@ -519,7 +519,7 @@ struct S3JniGlobalType {
|
||||
} metrics;
|
||||
/**
|
||||
The list of bound auto-extensions (Java-side:
|
||||
org.sqlite.jni.AutoExtension objects).
|
||||
org.sqlite.jni.auto_extension objects).
|
||||
*/
|
||||
struct {
|
||||
S3JniAutoExtension *pExt /* Head of the auto-extension list */;
|
||||
@ -925,7 +925,7 @@ static void S3JniDb_set_aside_unlocked(JNIEnv * env, S3JniDb * const s){
|
||||
UNHOOK(preUpdate, 0);
|
||||
#endif
|
||||
UNHOOK(collation, 1);
|
||||
UNHOOK(collationNeeded, 1);
|
||||
UNHOOK(collationNeeded, 0);
|
||||
UNHOOK(busyHandler, 1);
|
||||
#undef UNHOOK
|
||||
UNREF_G(s->jDb);
|
||||
@ -1158,12 +1158,12 @@ static int S3JniAutoExtension_init(JNIEnv *const env,
|
||||
jobject const jAutoExt){
|
||||
jclass const klazz = (*env)->GetObjectClass(env, jAutoExt);
|
||||
|
||||
ax->midFunc = (*env)->GetMethodID(env, klazz, "xEntryPoint",
|
||||
ax->midFunc = (*env)->GetMethodID(env, klazz, "call",
|
||||
"(Lorg/sqlite/jni/sqlite3;)I");
|
||||
UNREF_L(klazz);
|
||||
S3JniExceptionWarnIgnore;
|
||||
if( !ax->midFunc ){
|
||||
MARKER(("Error getting xEntryPoint(sqlite3) from AutoExtension object."));
|
||||
MARKER(("Error getting call(sqlite3) from AutoExtension object.\n"));
|
||||
S3JniAutoExtension_clear(env, ax);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
@ -2025,7 +2025,7 @@ S3JniApi(sqlite3_busy_handler(),jint,1busy_1handler)(
|
||||
S3JniHook_unref(env, pHook, 1);
|
||||
pHook->jObj = REF_G(jBusy);
|
||||
klazz = (*env)->GetObjectClass(env, jBusy);
|
||||
pHook->midCallback = (*env)->GetMethodID(env, klazz, "xCallback", "(I)I");
|
||||
pHook->midCallback = (*env)->GetMethodID(env, klazz, "call", "(I)I");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
S3JniHook_unref(env, pHook, 0);
|
||||
@ -2164,7 +2164,7 @@ S3JniApi(sqlite3_collation_needed(),jint,1collation_1needed)(
|
||||
return 0;
|
||||
}
|
||||
klazz = (*env)->GetObjectClass(env, jHook);
|
||||
xCallback = (*env)->GetMethodID(env, klazz, "xCollationNeeded",
|
||||
xCallback = (*env)->GetMethodID(env, klazz, "call",
|
||||
"(Lorg/sqlite/jni/sqlite3;ILjava/lang/String;)I");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
@ -2289,8 +2289,7 @@ static jobject s3jni_commit_rollback_hook(int isCommit, JNIEnv * const env,
|
||||
return pOld;
|
||||
}
|
||||
klazz = (*env)->GetObjectClass(env, jHook);
|
||||
xCallback = (*env)->GetMethodID(env, klazz,
|
||||
isCommit ? "xCommitHook" : "xRollbackHook",
|
||||
xCallback = (*env)->GetMethodID(env, klazz, "call",
|
||||
isCommit ? "()I" : "()V");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
@ -2400,7 +2399,7 @@ S3JniApi(sqlite3_config(/* for SQLLOG */),
|
||||
return 0;
|
||||
}
|
||||
klazz = (*env)->GetObjectClass(env, jLog);
|
||||
hook->midCallback = (*env)->GetMethodID(env, klazz, "xSqllog",
|
||||
hook->midCallback = (*env)->GetMethodID(env, klazz, "call",
|
||||
"(Lorg/sqlite/jni/sqlite3;"
|
||||
"Ljava/lang/String;"
|
||||
"I)V");
|
||||
@ -2444,7 +2443,7 @@ S3JniApi(sqlite3_create_collation() sqlite3_create_collation_v2(),
|
||||
|
||||
if( !pHook ) return SQLITE_MISUSE;
|
||||
klazz = (*env)->GetObjectClass(env, oCollation);
|
||||
pHook->midCallback = (*env)->GetMethodID(env, klazz, "xCompare",
|
||||
pHook->midCallback = (*env)->GetMethodID(env, klazz, "call",
|
||||
"([B[B)I");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew{
|
||||
@ -3055,13 +3054,13 @@ static jobject s3jni_updatepre_hook(JNIEnv * env, int isPre, jobject jDb, jobjec
|
||||
}
|
||||
klazz = (*env)->GetObjectClass(env, jHook);
|
||||
xCallback = isPre
|
||||
? (*env)->GetMethodID(env, klazz, "xPreUpdate",
|
||||
? (*env)->GetMethodID(env, klazz, "call",
|
||||
"(Lorg/sqlite/jni/sqlite3;"
|
||||
"I"
|
||||
"Ljava/lang/String;"
|
||||
"Ljava/lang/String;"
|
||||
"JJ)V")
|
||||
: (*env)->GetMethodID(env, klazz, "xUpdateHook",
|
||||
: (*env)->GetMethodID(env, klazz, "call",
|
||||
"(ILjava/lang/String;Ljava/lang/String;J)V");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
@ -3167,7 +3166,7 @@ S3JniApi(sqlite3_progress_handler(),void,1progress_1handler)(
|
||||
return;
|
||||
}
|
||||
klazz = (*env)->GetObjectClass(env, jProgress);
|
||||
xCallback = (*env)->GetMethodID(env, klazz, "xCallback", "()I");
|
||||
xCallback = (*env)->GetMethodID(env, klazz, "call", "()I");
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
S3JniExceptionClear;
|
||||
@ -3476,7 +3475,7 @@ S3JniApi(sqlite3_set_authorizer(),jint,1set_1authorizer)(
|
||||
pHook->jObj = REF_G(jHook);
|
||||
klazz = (*env)->GetObjectClass(env, jHook);
|
||||
pHook->midCallback = (*env)->GetMethodID(env, klazz,
|
||||
"xAuth",
|
||||
"call",
|
||||
"(I"
|
||||
"Ljava/lang/String;"
|
||||
"Ljava/lang/String;"
|
||||
@ -3667,25 +3666,26 @@ S3JniApi(sqlite3_trace_v2(),jint,1trace_1v2)(
|
||||
JniArgsEnvClass,jobject jDb, jint traceMask, jobject jTracer
|
||||
){
|
||||
S3JniDb * const ps = S3JniDb_for_db(env, jDb, 0);
|
||||
S3JniHook * const pHook = ps ? &ps->hooks.trace : 0;
|
||||
jclass klazz;
|
||||
|
||||
if( !traceMask || !jTracer ){
|
||||
if( ps ){
|
||||
S3JniHook_unref(env, &ps->hooks.trace, 0);
|
||||
}
|
||||
if( !ps ) return SQLITE_MISUSE;
|
||||
else if( !traceMask || !jTracer ){
|
||||
S3JniHook_unref(env, pHook, 0);
|
||||
return (jint)sqlite3_trace_v2(ps->pDb, 0, 0, 0);
|
||||
}
|
||||
if( !ps ) return SQLITE_NOMEM;
|
||||
klazz = (*env)->GetObjectClass(env, jTracer);
|
||||
ps->hooks.trace.midCallback = (*env)->GetMethodID(env, klazz, "xCallback",
|
||||
"(ILjava/lang/Object;Ljava/lang/Object;)I");
|
||||
pHook->midCallback = (*env)->GetMethodID(
|
||||
env, klazz, "call", "(ILjava/lang/Object;Ljava/lang/Object;)I"
|
||||
);
|
||||
UNREF_L(klazz);
|
||||
S3JniIfThrew {
|
||||
S3JniExceptionClear;
|
||||
S3JniHook_unref(env, pHook, 0);
|
||||
return s3jni_db_error(ps->pDb, SQLITE_ERROR,
|
||||
"Cannot not find matching xCallback() on Tracer object.");
|
||||
}
|
||||
ps->hooks.trace.jObj = REF_G(jTracer);
|
||||
pHook->jObj = REF_G(jTracer);
|
||||
return sqlite3_trace_v2(ps->pDb, (unsigned)traceMask, s3jni_trace_impl, ps);
|
||||
}
|
||||
|
||||
|
@ -782,7 +782,7 @@ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1aggregate_1conte
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_auto_extension
|
||||
* Signature: (Lorg/sqlite/jni/AutoExtension;)I
|
||||
* Signature: (Lorg/sqlite/jni/auto_extension_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1auto_1extension
|
||||
(JNIEnv *, jclass, jobject);
|
||||
@ -878,7 +878,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob64
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_busy_handler
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/BusyHandler;)I
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/busy_handler_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1busy_1handler
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -894,7 +894,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1busy_1timeout
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_cancel_auto_extension
|
||||
* Signature: (Lorg/sqlite/jni/AutoExtension;)Z
|
||||
* Signature: (Lorg/sqlite/jni/auto_extension_callback;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1cancel_1auto_1extension
|
||||
(JNIEnv *, jclass, jobject);
|
||||
@ -1062,7 +1062,7 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1value
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_collation_needed
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/CollationNeeded;)I
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/collation_needed_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1collation_1needed
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -1078,7 +1078,7 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1context_1db_1h
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_commit_hook
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/CommitHook;)Lorg/sqlite/jni/CommitHook;
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/commit_hook_callback;)Lorg/sqlite/jni/commit_hook_callback;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1commit_1hook
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -1110,15 +1110,15 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1config__I
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_config
|
||||
* Signature: (Lorg/sqlite/jni/SQLLog;)I
|
||||
* Signature: (Lorg/sqlite/jni/config_sqllog_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1config__Lorg_sqlite_jni_SQLLog_2
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1config__Lorg_sqlite_jni_config_1sqllog_1callback_2
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_create_collation
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Ljava/lang/String;ILorg/sqlite/jni/Collation;)I
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Ljava/lang/String;ILorg/sqlite/jni/collation_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1create_1collation
|
||||
(JNIEnv *, jclass, jobject, jstring, jint, jobject);
|
||||
@ -1350,7 +1350,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1depth
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_preupdate_hook
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/PreUpdateHook;)Lorg/sqlite/jni/PreUpdateHook;
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/preupdate_hook_callback;)Lorg/sqlite/jni/preupdate_hook_callback;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1hook
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -1374,7 +1374,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1old
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_progress_handler
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/ProgressHandler;)V
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/progress_handler_callback;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1progress_1handler
|
||||
(JNIEnv *, jclass, jobject, jint, jobject);
|
||||
@ -1550,7 +1550,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1status64
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_rollback_hook
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/RollbackHook;)Lorg/sqlite/jni/RollbackHook;
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/rollback_hook_callback;)Lorg/sqlite/jni/rollback_hook_callback;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1rollback_1hook
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -1558,7 +1558,7 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1rollback_1hook
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_set_authorizer
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/Authorizer;)I
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/authorizer_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1set_1authorizer
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
@ -1646,7 +1646,7 @@ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1total_1changes64
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_trace_v2
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/Tracer;)I
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/trace_v2_callback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1trace_1v2
|
||||
(JNIEnv *, jclass, jobject, jint, jobject);
|
||||
@ -1654,7 +1654,7 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1trace_1v2
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_update_hook
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/UpdateHook;)Lorg/sqlite/jni/UpdateHook;
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/update_hook_callback;)Lorg/sqlite/jni/update_hook_callback;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1update_1hook
|
||||
(JNIEnv *, jclass, jobject, jobject);
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
** 2023-08-23
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
A callback for use with sqlite3_preupdate_hook().
|
||||
*/
|
||||
public interface PreUpdateHook {
|
||||
/**
|
||||
Must function as described for the sqlite3_preupdate_hook().
|
||||
callback, with the slight signature change.
|
||||
|
||||
Must not throw. Any exceptions may emit debugging messages and
|
||||
will be suppressed.
|
||||
*/
|
||||
void xPreUpdate(sqlite3 db, int op, String dbName, String dbTable,
|
||||
long iKey1, long iKey2 );
|
||||
}
|
@ -20,8 +20,9 @@ import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
/**
|
||||
This class contains the entire sqlite3 JNI API binding. For
|
||||
client-side use, a static import is recommended:
|
||||
This class contains the entire C-style sqlite3 JNI API binding,
|
||||
minus a few bits and pieces declared in other files. For client-side
|
||||
use, a static import is recommended:
|
||||
|
||||
<pre>{@code
|
||||
import static org.sqlite.jni.SQLite3Jni.*;
|
||||
@ -36,8 +37,8 @@ import java.lang.annotation.ElementType;
|
||||
|
||||
<p><a href="https://sqlite.org/c3ref/intro.html">https://sqlite.org/c3ref/intro.html</a>
|
||||
|
||||
<p>A handful of Java-specific APIs have been added.
|
||||
|
||||
<p>A handful of Java-specific APIs have been added which are documented
|
||||
here.
|
||||
|
||||
<p>Notes regarding Java's Modified UTF-8 vs standard UTF-8:
|
||||
|
||||
@ -147,7 +148,7 @@ public final class SQLite3Jni {
|
||||
|
||||
<p>See the AutoExtension class docs for more information.
|
||||
*/
|
||||
public static native int sqlite3_auto_extension(@NotNull AutoExtension callback);
|
||||
public static native int sqlite3_auto_extension(@NotNull auto_extension_callback callback);
|
||||
|
||||
/**
|
||||
Results are undefined if data is not null and n<0 || n>=data.length.
|
||||
@ -259,7 +260,7 @@ public final class SQLite3Jni {
|
||||
/**
|
||||
Requires that data be null or in UTF-16 encoding in platform byte
|
||||
order. Returns the result of the C-level sqlite3_bind_null() or
|
||||
sqlite3_bind_text().
|
||||
sqlite3_bind_text16().
|
||||
*/
|
||||
public static int sqlite3_bind_text16(
|
||||
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data
|
||||
@ -278,12 +279,12 @@ public final class SQLite3Jni {
|
||||
);
|
||||
|
||||
/**
|
||||
As for the C-level function of the same name, with a BusyHandler
|
||||
As for the C-level function of the same name, with a busy_handler_callback
|
||||
instance in place of a callback function. Pass it a null handler
|
||||
to clear the busy handler.
|
||||
*/
|
||||
public static native int sqlite3_busy_handler(
|
||||
@NotNull sqlite3 db, @Nullable BusyHandler handler
|
||||
@NotNull sqlite3 db, @Nullable busy_handler_callback handler
|
||||
);
|
||||
|
||||
public static native int sqlite3_busy_timeout(
|
||||
@ -291,7 +292,7 @@ public final class SQLite3Jni {
|
||||
);
|
||||
|
||||
public static native boolean sqlite3_cancel_auto_extension(
|
||||
@NotNull AutoExtension ax
|
||||
@NotNull auto_extension_callback ax
|
||||
);
|
||||
|
||||
public static native int sqlite3_changes(
|
||||
@ -457,7 +458,7 @@ public final class SQLite3Jni {
|
||||
Java's string type is compatible with that interface.
|
||||
*/
|
||||
public static native int sqlite3_collation_needed(
|
||||
@NotNull sqlite3 db, @Nullable CollationNeeded callback
|
||||
@NotNull sqlite3 db, @Nullable collation_needed_callback callback
|
||||
);
|
||||
|
||||
/**
|
||||
@ -468,8 +469,8 @@ public final class SQLite3Jni {
|
||||
@NotNull sqlite3_context cx
|
||||
);
|
||||
|
||||
public static native CommitHook sqlite3_commit_hook(
|
||||
@NotNull sqlite3 db, @Nullable CommitHook hook
|
||||
public static native commit_hook_callback sqlite3_commit_hook(
|
||||
@NotNull sqlite3 db, @Nullable commit_hook_callback hook
|
||||
);
|
||||
|
||||
public static native String sqlite3_compileoption_get(
|
||||
@ -503,11 +504,11 @@ public final class SQLite3Jni {
|
||||
** If not built with SQLITE_ENABLE_SQLLOG defined, this returns
|
||||
** SQLITE_MISUSE.
|
||||
*/
|
||||
public static native int sqlite3_config( @Nullable SQLLog logger );
|
||||
public static native int sqlite3_config( @Nullable config_sqllog_callback logger );
|
||||
|
||||
public static native int sqlite3_create_collation(
|
||||
@NotNull sqlite3 db, @NotNull String name, int eTextRep,
|
||||
@NotNull Collation col
|
||||
@NotNull collation_callback col
|
||||
);
|
||||
|
||||
/**
|
||||
@ -826,8 +827,9 @@ public final class SQLite3Jni {
|
||||
acts as a proxy for C's sqlite3_preupdate_hook(), else it returns null
|
||||
with no side effects.
|
||||
*/
|
||||
public static native PreUpdateHook sqlite3_preupdate_hook(@NotNull sqlite3 db,
|
||||
@Nullable PreUpdateHook hook);
|
||||
public static native preupdate_hook_callback sqlite3_preupdate_hook(
|
||||
@NotNull sqlite3 db, @Nullable preupdate_hook_callback hook
|
||||
);
|
||||
|
||||
/**
|
||||
If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined,
|
||||
@ -866,11 +868,9 @@ public final class SQLite3Jni {
|
||||
}
|
||||
|
||||
public static native void sqlite3_progress_handler(
|
||||
@NotNull sqlite3 db, int n, @Nullable ProgressHandler h
|
||||
@NotNull sqlite3 db, int n, @Nullable progress_handler_callback h
|
||||
);
|
||||
|
||||
//TODO??? void *sqlite3_preupdate_hook(...) and friends
|
||||
|
||||
public static native int sqlite3_reset(@NotNull sqlite3_stmt stmt);
|
||||
|
||||
/**
|
||||
@ -1156,13 +1156,13 @@ public final class SQLite3Jni {
|
||||
}
|
||||
}
|
||||
|
||||
public static native RollbackHook sqlite3_rollback_hook(
|
||||
@NotNull sqlite3 db, @Nullable RollbackHook hook
|
||||
public static native rollback_hook_callback sqlite3_rollback_hook(
|
||||
@NotNull sqlite3 db, @Nullable rollback_hook_callback hook
|
||||
);
|
||||
|
||||
//! Sets or unsets (if auth is null) the current authorizer.
|
||||
public static native int sqlite3_set_authorizer(
|
||||
@NotNull sqlite3 db, @Nullable Authorizer auth
|
||||
@NotNull sqlite3 db, @Nullable authorizer_callback auth
|
||||
);
|
||||
|
||||
public static native void sqlite3_set_last_insert_rowid(
|
||||
@ -1229,11 +1229,11 @@ public final class SQLite3Jni {
|
||||
cannot be processed propertly (i.e. an internal error).
|
||||
*/
|
||||
public static native int sqlite3_trace_v2(
|
||||
@NotNull sqlite3 db, int traceMask, @Nullable Tracer tracer
|
||||
@NotNull sqlite3 db, int traceMask, @Nullable trace_v2_callback tracer
|
||||
);
|
||||
|
||||
public static native UpdateHook sqlite3_update_hook(
|
||||
sqlite3 db, UpdateHook hook
|
||||
public static native update_hook_callback sqlite3_update_hook(
|
||||
sqlite3 db, update_hook_callback hook
|
||||
);
|
||||
|
||||
public static native byte[] sqlite3_value_blob(@NotNull sqlite3_value v);
|
||||
|
@ -489,12 +489,12 @@ public class Tester1 implements Runnable {
|
||||
final sqlite3 db = createNewDb();
|
||||
execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')");
|
||||
final ValueHolder<Boolean> xDestroyCalled = new ValueHolder<>(false);
|
||||
final Collation myCollation = new Collation() {
|
||||
final collation_callback myCollation = new collation_callback() {
|
||||
private String myState =
|
||||
"this is local state. There is much like it, but this is mine.";
|
||||
@Override
|
||||
// Reverse-sorts its inputs...
|
||||
public int xCompare(byte[] lhs, byte[] rhs){
|
||||
public int call(byte[] lhs, byte[] rhs){
|
||||
int len = lhs.length > rhs.length ? rhs.length : lhs.length;
|
||||
int c = 0, i = 0;
|
||||
for(i = 0; i < len; ++i){
|
||||
@ -513,8 +513,9 @@ public class Tester1 implements Runnable {
|
||||
xDestroyCalled.value = true;
|
||||
}
|
||||
};
|
||||
final CollationNeeded collLoader = new CollationNeeded(){
|
||||
public int xCollationNeeded(sqlite3 dbArg, int eTextRep, String collationName){
|
||||
final collation_needed_callback collLoader = new collation_needed_callback(){
|
||||
@Override
|
||||
public int call(sqlite3 dbArg, int eTextRep, String collationName){
|
||||
affirm(dbArg == db/* as opposed to a temporary object*/);
|
||||
return sqlite3_create_collation(dbArg, "reversi", eTextRep, myCollation);
|
||||
}
|
||||
@ -877,11 +878,11 @@ public class Tester1 implements Runnable {
|
||||
from Java to sqlite3 and back to Java. (At no small efficiency
|
||||
penalty.) */
|
||||
final String nonBmpChar = "😃";
|
||||
sqlite3_trace_v2(
|
||||
int rc = sqlite3_trace_v2(
|
||||
db, SQLITE_TRACE_STMT | SQLITE_TRACE_PROFILE
|
||||
| SQLITE_TRACE_ROW | SQLITE_TRACE_CLOSE,
|
||||
new Tracer(){
|
||||
public int xCallback(int traceFlag, Object pNative, Object x){
|
||||
new trace_v2_callback(){
|
||||
@Override public int call(int traceFlag, Object pNative, Object x){
|
||||
++counter.value;
|
||||
//outln("TRACE "+traceFlag+" pNative = "+pNative.getClass().getName());
|
||||
switch(traceFlag){
|
||||
@ -912,6 +913,7 @@ public class Tester1 implements Runnable {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
affirm( 0==rc );
|
||||
execSql(db, "SELECT coalesce(null,null,'"+nonBmpChar+"'); "+
|
||||
"SELECT 'w"+nonBmpChar+"orld'");
|
||||
affirm( 6 == counter.value );
|
||||
@ -940,8 +942,8 @@ public class Tester1 implements Runnable {
|
||||
|
||||
final ValueHolder<Boolean> xDestroyed = new ValueHolder<>(false);
|
||||
final ValueHolder<Integer> xBusyCalled = new ValueHolder<>(0);
|
||||
BusyHandler handler = new BusyHandler(){
|
||||
@Override public int xCallback(int n){
|
||||
busy_handler_callback handler = new busy_handler_callback(){
|
||||
@Override public int call(int n){
|
||||
//outln("busy handler #"+n);
|
||||
return n > 2 ? 0 : ++xBusyCalled.value;
|
||||
}
|
||||
@ -974,8 +976,8 @@ public class Tester1 implements Runnable {
|
||||
private void testProgress(){
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
sqlite3_progress_handler(db, 1, new ProgressHandler(){
|
||||
public int xCallback(){
|
||||
sqlite3_progress_handler(db, 1, new progress_handler_callback(){
|
||||
@Override public int call(){
|
||||
++counter.value;
|
||||
return 0;
|
||||
}
|
||||
@ -993,13 +995,13 @@ public class Tester1 implements Runnable {
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
final ValueHolder<Integer> hookResult = new ValueHolder<>(0);
|
||||
final CommitHook theHook = new CommitHook(){
|
||||
public int xCommitHook(){
|
||||
final commit_hook_callback theHook = new commit_hook_callback(){
|
||||
@Override public int call(){
|
||||
++counter.value;
|
||||
return hookResult.value;
|
||||
}
|
||||
};
|
||||
CommitHook oldHook = sqlite3_commit_hook(db, theHook);
|
||||
commit_hook_callback oldHook = sqlite3_commit_hook(db, theHook);
|
||||
affirm( null == oldHook );
|
||||
execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')");
|
||||
affirm( 2 == counter.value );
|
||||
@ -1020,8 +1022,8 @@ public class Tester1 implements Runnable {
|
||||
execSql(db, "BEGIN; update t set a='g' where a='f'; COMMIT;");
|
||||
affirm( 4 == counter.value );
|
||||
|
||||
final CommitHook newHook = new CommitHook(){
|
||||
public int xCommitHook(){return 0;}
|
||||
final commit_hook_callback newHook = new commit_hook_callback(){
|
||||
@Override public int call(){return 0;}
|
||||
};
|
||||
oldHook = sqlite3_commit_hook(db, newHook);
|
||||
affirm( null == oldHook );
|
||||
@ -1042,17 +1044,16 @@ public class Tester1 implements Runnable {
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
final ValueHolder<Integer> expectedOp = new ValueHolder<>(0);
|
||||
final UpdateHook theHook = new UpdateHook(){
|
||||
@SuppressWarnings("unchecked")
|
||||
final update_hook_callback theHook = new update_hook_callback(){
|
||||
@Override
|
||||
public void xUpdateHook(int opId, String dbName, String tableName, long rowId){
|
||||
public void call(int opId, String dbName, String tableName, long rowId){
|
||||
++counter.value;
|
||||
if( 0!=expectedOp.value ){
|
||||
affirm( expectedOp.value == opId );
|
||||
}
|
||||
}
|
||||
};
|
||||
UpdateHook oldHook = sqlite3_update_hook(db, theHook);
|
||||
update_hook_callback oldHook = sqlite3_update_hook(db, theHook);
|
||||
affirm( null == oldHook );
|
||||
expectedOp.value = SQLITE_INSERT;
|
||||
execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')");
|
||||
@ -1072,8 +1073,8 @@ public class Tester1 implements Runnable {
|
||||
oldHook = sqlite3_update_hook(db, null);
|
||||
affirm( null == oldHook );
|
||||
|
||||
final UpdateHook newHook = new UpdateHook(){
|
||||
public void xUpdateHook(int opId, String dbName, String tableName, long rowId){
|
||||
final update_hook_callback newHook = new update_hook_callback(){
|
||||
@Override public void call(int opId, String dbName, String tableName, long rowId){
|
||||
}
|
||||
};
|
||||
oldHook = sqlite3_update_hook(db, newHook);
|
||||
@ -1100,11 +1101,10 @@ public class Tester1 implements Runnable {
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
final ValueHolder<Integer> expectedOp = new ValueHolder<>(0);
|
||||
final PreUpdateHook theHook = new PreUpdateHook(){
|
||||
@SuppressWarnings("unchecked")
|
||||
final preupdate_hook_callback theHook = new preupdate_hook_callback(){
|
||||
@Override
|
||||
public void xPreUpdate(sqlite3 db, int opId, String dbName, String dbTable,
|
||||
long iKey1, long iKey2 ){
|
||||
public void call(sqlite3 db, int opId, String dbName, String dbTable,
|
||||
long iKey1, long iKey2 ){
|
||||
++counter.value;
|
||||
switch( opId ){
|
||||
case SQLITE_UPDATE:
|
||||
@ -1126,7 +1126,7 @@ public class Tester1 implements Runnable {
|
||||
}
|
||||
}
|
||||
};
|
||||
PreUpdateHook oldHook = sqlite3_preupdate_hook(db, theHook);
|
||||
preupdate_hook_callback oldHook = sqlite3_preupdate_hook(db, theHook);
|
||||
affirm( null == oldHook );
|
||||
expectedOp.value = SQLITE_INSERT;
|
||||
execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')");
|
||||
@ -1146,10 +1146,10 @@ public class Tester1 implements Runnable {
|
||||
oldHook = sqlite3_preupdate_hook(db, null);
|
||||
affirm( null == oldHook );
|
||||
|
||||
final PreUpdateHook newHook = new PreUpdateHook(){
|
||||
final preupdate_hook_callback newHook = new preupdate_hook_callback(){
|
||||
@Override
|
||||
public void xPreUpdate(sqlite3 db, int opId, String dbName,
|
||||
String tableName, long iKey1, long iKey2){
|
||||
public void call(sqlite3 db, int opId, String dbName,
|
||||
String tableName, long iKey1, long iKey2){
|
||||
}
|
||||
};
|
||||
oldHook = sqlite3_preupdate_hook(db, newHook);
|
||||
@ -1168,20 +1168,20 @@ public class Tester1 implements Runnable {
|
||||
private void testRollbackHook(){
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
final RollbackHook theHook = new RollbackHook(){
|
||||
public void xRollbackHook(){
|
||||
final rollback_hook_callback theHook = new rollback_hook_callback(){
|
||||
@Override public void call(){
|
||||
++counter.value;
|
||||
}
|
||||
};
|
||||
RollbackHook oldHook = sqlite3_rollback_hook(db, theHook);
|
||||
rollback_hook_callback oldHook = sqlite3_rollback_hook(db, theHook);
|
||||
affirm( null == oldHook );
|
||||
execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')");
|
||||
affirm( 0 == counter.value );
|
||||
execSql(db, false, "BEGIN; SELECT 1; SELECT 2; ROLLBACK;");
|
||||
affirm( 1 == counter.value /* contra to commit hook, is invoked if no changes are made */ );
|
||||
|
||||
final RollbackHook newHook = new RollbackHook(){
|
||||
public void xRollbackHook(){return;}
|
||||
final rollback_hook_callback newHook = new rollback_hook_callback(){
|
||||
@Override public void call(){return;}
|
||||
};
|
||||
oldHook = sqlite3_rollback_hook(db, newHook);
|
||||
affirm( theHook == oldHook );
|
||||
@ -1237,8 +1237,8 @@ public class Tester1 implements Runnable {
|
||||
final sqlite3 db = createNewDb();
|
||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||
final ValueHolder<Integer> authRc = new ValueHolder<>(0);
|
||||
final Authorizer auth = new Authorizer(){
|
||||
public int xAuth(int op, String s0, String s1, String s2, String s3){
|
||||
final authorizer_callback auth = new authorizer_callback(){
|
||||
public int call(int op, String s0, String s1, String s2, String s3){
|
||||
++counter.value;
|
||||
//outln("xAuth(): "+s0+" "+s1+" "+s2+" "+s3);
|
||||
return authRc.value;
|
||||
@ -1260,8 +1260,8 @@ public class Tester1 implements Runnable {
|
||||
private synchronized void testAutoExtension(){
|
||||
final ValueHolder<Integer> val = new ValueHolder<>(0);
|
||||
final ValueHolder<String> toss = new ValueHolder<>(null);
|
||||
final AutoExtension ax = new AutoExtension(){
|
||||
public synchronized int xEntryPoint(sqlite3 db){
|
||||
final auto_extension_callback ax = new auto_extension_callback(){
|
||||
@Override public synchronized int call(sqlite3 db){
|
||||
++val.value;
|
||||
if( null!=toss.value ){
|
||||
throw new RuntimeException(toss.value);
|
||||
@ -1300,7 +1300,7 @@ public class Tester1 implements Runnable {
|
||||
rc = sqlite3_auto_extension( ax );
|
||||
affirm( 0==rc );
|
||||
Exception err = null;
|
||||
toss.value = "Throwing from AutoExtension.";
|
||||
toss.value = "Throwing from auto_extension.";
|
||||
try{
|
||||
sqlite3_close(createNewDb());
|
||||
}catch(Exception e){
|
||||
@ -1311,8 +1311,8 @@ public class Tester1 implements Runnable {
|
||||
toss.value = null;
|
||||
|
||||
val.value = 0;
|
||||
final AutoExtension ax2 = new AutoExtension(){
|
||||
public synchronized int xEntryPoint(sqlite3 db){
|
||||
final auto_extension_callback ax2 = new auto_extension_callback(){
|
||||
@Override public synchronized int call(sqlite3 db){
|
||||
++val.value;
|
||||
return 0;
|
||||
}
|
||||
@ -1507,8 +1507,8 @@ public class Tester1 implements Runnable {
|
||||
|
||||
if( sqlLog ){
|
||||
if( sqlite3_compileoption_used("ENABLE_SQLLOG") ){
|
||||
int rc = sqlite3_config( new SQLLog() {
|
||||
@Override public void xSqllog(sqlite3 db, String msg, int op){
|
||||
int rc = sqlite3_config( new config_sqllog_callback() {
|
||||
@Override public void call(sqlite3 db, String msg, int op){
|
||||
switch(op){
|
||||
case 0: outln("Opening db: ",db); break;
|
||||
case 1: outln(db,": ",msg); break;
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_update_hook().
|
||||
*/
|
||||
public interface UpdateHook {
|
||||
/**
|
||||
Works as documented for the sqlite3_update_hook() callback.
|
||||
Must not throw.
|
||||
*/
|
||||
void xUpdateHook(int opId, String dbName, String tableName, long rowId);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-08-05
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,15 +14,16 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
A callback for use with sqlite3_set_authorizer().
|
||||
Callback for use with sqlite3_set_authorizer().
|
||||
*/
|
||||
public interface Authorizer {
|
||||
public interface authorizer_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Must function as described for the sqlite3_set_authorizer()
|
||||
callback.
|
||||
Must function as described for the C-level
|
||||
sqlite3_set_authorizer() callback.
|
||||
|
||||
Must not throw.
|
||||
*/
|
||||
int xAuth(int opId, @Nullable String s1, @Nullable String s2,
|
||||
@Nullable String s3, @Nullable String s4);
|
||||
int call(int opId, @Nullable String s1, @Nullable String s2,
|
||||
@Nullable String s3, @Nullable String s4);
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-08-05
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -17,24 +17,25 @@ package org.sqlite.jni;
|
||||
A callback for use with the sqlite3_auto_extension() family of
|
||||
APIs.
|
||||
*/
|
||||
public interface AutoExtension {
|
||||
public interface auto_extension_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Must function as described for a sqlite3_auto_extension()
|
||||
callback, with the caveat that the signature is shorter.
|
||||
Must function as described for a C-level
|
||||
sqlite3_auto_extension() callback, with the caveat that the
|
||||
signature is shorter.
|
||||
|
||||
AutoExtensions may throw and the exception's error message
|
||||
will be set as the db's error string.
|
||||
This callback may throw and the exception's error message will
|
||||
be set as the db's error string.
|
||||
|
||||
Tips for implementations:
|
||||
|
||||
- Opening a database from an auto-extension handler will lead to
|
||||
an endless recursion of the auto-handler triggering itself
|
||||
indirectly for each newly-opened database.
|
||||
an endless recursion of the auto-handler triggering itself
|
||||
indirectly for each newly-opened database.
|
||||
|
||||
- If this routine is stateful, it may be useful to make the
|
||||
overridden method synchronized.
|
||||
overridden method synchronized.
|
||||
|
||||
- Results are undefined if db is closed by an auto-extension.
|
||||
*/
|
||||
int xEntryPoint(sqlite3 db);
|
||||
int call(sqlite3 db);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -13,33 +13,35 @@
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_busy_handler().
|
||||
Callback for use with sqlite3_busy_handler()
|
||||
*/
|
||||
public abstract class BusyHandler {
|
||||
public abstract class busy_handler_callback
|
||||
implements sqlite3_callback_proxy, sqlite3_xDestroy_callback {
|
||||
/**
|
||||
Must function as documented for the sqlite3_busy_handler()
|
||||
callback argument, minus the (void*) argument the C-level
|
||||
function requires.
|
||||
Must function as documented for the C-level
|
||||
sqlite3_busy_handler() callback argument, minus the (void*)
|
||||
argument the C-level function requires.
|
||||
|
||||
Any exceptions thrown by this callback are suppressed in order to
|
||||
retain the C-style API semantics of the JNI bindings.
|
||||
*/
|
||||
public abstract int xCallback(int n);
|
||||
public abstract int call(int n);
|
||||
|
||||
/**
|
||||
Optionally override to perform any cleanup when this busy
|
||||
handler is destroyed. It is destroyed when:
|
||||
|
||||
- The associated db is passed to sqlite3_close() or
|
||||
sqlite3_close_v2().
|
||||
sqlite3_close_v2().
|
||||
|
||||
- sqlite3_busy_handler() is called to replace the handler,
|
||||
whether it's passed a null handler or any other instance of
|
||||
this class.
|
||||
whether it's passed a null handler or any other instance of
|
||||
this class.
|
||||
|
||||
- sqlite3_busy_timeout() is called, which implicitly installs
|
||||
a busy handler.
|
||||
a busy handler.
|
||||
*/
|
||||
public void xDestroy(){}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,15 +14,18 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback for use with sqlite3_create_collation()
|
||||
*/
|
||||
public abstract class Collation {
|
||||
public abstract class collation_callback
|
||||
implements sqlite3_callback_proxy, sqlite3_xDestroy_callback {
|
||||
/**
|
||||
Must compare the given byte arrays using memcmp() semantics.
|
||||
*/
|
||||
public abstract int xCompare(byte[] lhs, byte[] rhs);
|
||||
public abstract int call(byte[] lhs, byte[] rhs);
|
||||
|
||||
/**
|
||||
Called by SQLite when the collation is destroyed. If a Collation
|
||||
Called by SQLite when the collation is destroyed. If a collation
|
||||
requires custom cleanup, override this method.
|
||||
*/
|
||||
public void xDestroy() {}
|
||||
public void xDestroy(){}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-30
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,15 +14,15 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_collation_needed().
|
||||
Callback for use with sqlite3_collation_needed().
|
||||
*/
|
||||
public interface CollationNeeded {
|
||||
public interface collation_needed_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Has the same semantics as the C-level sqlite3_create_collation()
|
||||
callback.
|
||||
|
||||
If it throws, the exception message is passed on to the db and
|
||||
<p>If it throws, the exception message is passed on to the db and
|
||||
the exception is suppressed.
|
||||
*/
|
||||
int xCollationNeeded(sqlite3 db, int eTextRep, String collationName);
|
||||
int call(sqlite3 db, int eTextRep, String collationName);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,12 +14,12 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_commit_hook().
|
||||
Callback for use with sqlite3_commit_hook()
|
||||
*/
|
||||
public interface CommitHook {
|
||||
public interface commit_hook_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Works as documented for the sqlite3_commit_hook() callback.
|
||||
Must not throw.
|
||||
Works as documented for the C-level sqlite3_commit_hook()
|
||||
callback. Must not throw.
|
||||
*/
|
||||
int xCommitHook();
|
||||
int call();
|
||||
}
|
@ -14,12 +14,12 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
A callback for use with sqlite3_config(SQLLog).
|
||||
A callback for use with sqlite3_config().
|
||||
*/
|
||||
public interface SQLLog {
|
||||
public interface config_sqllog_callback {
|
||||
/**
|
||||
Must function as described for sqlite3_config(SQLITE_CONFIG_SQLLOG)
|
||||
callback, with the slight signature change.
|
||||
*/
|
||||
void xSqllog(sqlite3 db, String msg, int msgType );
|
||||
void call(sqlite3 db, String msg, int msgType );
|
||||
}
|
26
ext/jni/src/org/sqlite/jni/preupdate_hook_callback.java
Normal file
26
ext/jni/src/org/sqlite/jni/preupdate_hook_callback.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback for use with sqlite3_preupdate_hook().
|
||||
*/
|
||||
public interface preupdate_hook_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Must function as described for the C-level sqlite3_preupdate_hook()
|
||||
callback. Must not throw.
|
||||
*/
|
||||
void call(sqlite3 db, int op, String dbName, String dbTable,
|
||||
long iKey1, long iKey2 );
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,14 +14,14 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_progress_handler().
|
||||
Callback for use with sqlite3_progress_handler()
|
||||
*/
|
||||
public interface ProgressHandler {
|
||||
public interface progress_handler_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Works as documented for the sqlite3_progress_handler() callback.
|
||||
Works as documented for the C-level sqlite3_progress_handler() callback.
|
||||
|
||||
If it throws, the exception message is passed on to the db and
|
||||
the exception is suppressed.
|
||||
*/
|
||||
int xCallback();
|
||||
int call();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -14,12 +14,12 @@
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback proxy for use with sqlite3_rollback_hook().
|
||||
Callback for use with sqlite3_rollback_hook()
|
||||
*/
|
||||
public interface RollbackHook {
|
||||
public interface rollback_hook_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Works as documented for the sqlite3_rollback_hook() callback.
|
||||
Must not throw.
|
||||
Works as documented for the C-level sqlite3_rollback_hook()
|
||||
callback. Must not throw.
|
||||
*/
|
||||
void xRollbackHook();
|
||||
void call();
|
||||
}
|
34
ext/jni/src/org/sqlite/jni/sqlite3_callback_proxy.java
Normal file
34
ext/jni/src/org/sqlite/jni/sqlite3_callback_proxy.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
/**
|
||||
This marker interface exists soley for use as a documentation and
|
||||
class-grouping tool. It should be applied to interfaces or
|
||||
classes which have a call() method implementing some specific
|
||||
callback interface on behalf of the C library.
|
||||
|
||||
<p>Callbacks of this style follow a common naming convention:
|
||||
|
||||
<p>1) They almost all have the same class or interface name as the
|
||||
C function they are proxying a callback for, minus the sqlite3_
|
||||
prefix, plus a _callback suffix. e.g. sqlite3_busy_handler()'s
|
||||
callback is named busy_handler_callback. Exceptions are made where
|
||||
that would potentially be ambiguous, e.g. config_sqllog_callback
|
||||
instead of config_callback because the sqlite3_config() interface
|
||||
may need to support more callback types in the future.
|
||||
|
||||
<p>2) They all have a call() method but its signature is
|
||||
callback-specific.
|
||||
*/
|
||||
public interface sqlite3_callback_proxy {}
|
28
ext/jni/src/org/sqlite/jni/sqlite3_xDestroy_callback.java
Normal file
28
ext/jni/src/org/sqlite/jni/sqlite3_xDestroy_callback.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
** 2023-07-21
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file declares JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback for a hook called by SQLite when certain client-provided
|
||||
state are destroyed. It gets its name from the pervasive use of
|
||||
the symbol name xDestroy() for this purpose in the C API
|
||||
documentation.
|
||||
*/
|
||||
public interface sqlite3_xDestroy_callback {
|
||||
/**
|
||||
Must perform any cleanup required by this object. Must not
|
||||
throw.
|
||||
*/
|
||||
public void xDestroy();
|
||||
}
|
@ -609,9 +609,9 @@ public class SQLTester {
|
||||
}
|
||||
t.addTestScript(a);
|
||||
}
|
||||
final AutoExtension ax = new AutoExtension() {
|
||||
final auto_extension_callback ax = new auto_extension_callback() {
|
||||
private final SQLTester tester = t;
|
||||
public int xEntryPoint(sqlite3 db){
|
||||
@Override public int call(sqlite3 db){
|
||||
final String init = tester.getDbInitSql();
|
||||
if( !init.isEmpty() ){
|
||||
tester.execSql(db, true, ResultBufferMode.NONE, null, init);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** 2023-07-22
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
@ -16,18 +16,14 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback proxy for use with sqlite3_trace_v2().
|
||||
*/
|
||||
public interface Tracer {
|
||||
public interface trace_v2_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Achtung: this interface is subject to change because the current
|
||||
approach to mapping the passed-in natives back to Java is
|
||||
uncomfortably quirky.
|
||||
|
||||
Called by sqlite3 for various tracing operations, as per
|
||||
sqlite3_trace_v2(). Note that this interface elides the 2nd
|
||||
argument to the native trace callback, as that role is better
|
||||
filled by instance-local state.
|
||||
|
||||
The 2nd argument to this function, if non-0, will be a native
|
||||
<p>The 2nd argument to this function, if non-0, will be a native
|
||||
pointer to either an sqlite3 or sqlite3_stmt object, depending on
|
||||
the first argument (see below). Client code can pass it to the
|
||||
sqlite3 resp. sqlite3_stmt constructor to create a wrapping
|
||||
@ -36,27 +32,27 @@ public interface Tracer {
|
||||
each call is comparatively expensive, and the objects are
|
||||
probably only seldom useful.
|
||||
|
||||
The final argument to this function is the "X" argument
|
||||
<p>The final argument to this function is the "X" argument
|
||||
documented for sqlite3_trace() and sqlite3_trace_v2(). Its type
|
||||
depends on value of the first argument:
|
||||
|
||||
- SQLITE_TRACE_STMT: pNative is a sqlite3_stmt. pX is a string
|
||||
containing the prepared SQL, with one caveat: JNI only provides
|
||||
us with the ability to convert that string to MUTF-8, as
|
||||
opposed to standard UTF-8, and is cannot be ruled out that that
|
||||
difference may be significant for certain inputs. The
|
||||
alternative would be that we first convert it to UTF-16 before
|
||||
passing it on, but there's no readily-available way to do that
|
||||
without calling back into the db to peform the conversion
|
||||
(which would lead to further tracing).
|
||||
<p>- SQLITE_TRACE_STMT: pNative is a sqlite3_stmt. pX is a string
|
||||
containing the prepared SQL, with one caveat: JNI only provides
|
||||
us with the ability to convert that string to MUTF-8, as
|
||||
opposed to standard UTF-8, and is cannot be ruled out that that
|
||||
difference may be significant for certain inputs. The
|
||||
alternative would be that we first convert it to UTF-16 before
|
||||
passing it on, but there's no readily-available way to do that
|
||||
without calling back into the db to peform the conversion
|
||||
(which would lead to further tracing).
|
||||
|
||||
- SQLITE_TRACE_PROFILE: pNative is a sqlite3_stmt. pX is a Long
|
||||
holding an approximate number of nanoseconds the statement took
|
||||
to run.
|
||||
<p>- SQLITE_TRACE_PROFILE: pNative is a sqlite3_stmt. pX is a Long
|
||||
holding an approximate number of nanoseconds the statement took
|
||||
to run.
|
||||
|
||||
- SQLITE_TRACE_ROW: pNative is a sqlite3_stmt. pX is null.
|
||||
<p>- SQLITE_TRACE_ROW: pNative is a sqlite3_stmt. pX is null.
|
||||
|
||||
- SQLITE_TRACE_CLOSE: pNative is a sqlite3. pX is null.
|
||||
<p>- SQLITE_TRACE_CLOSE: pNative is a sqlite3. pX is null.
|
||||
*/
|
||||
int xCallback(int traceFlag, Object pNative, Object pX);
|
||||
int call(int traceFlag, Object pNative, Object pX);
|
||||
}
|
25
ext/jni/src/org/sqlite/jni/update_hook_callback.java
Normal file
25
ext/jni/src/org/sqlite/jni/update_hook_callback.java
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
** 2023-08-25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||
*/
|
||||
package org.sqlite.jni;
|
||||
|
||||
/**
|
||||
Callback for use with sqlite3_update_hook().
|
||||
*/
|
||||
public interface update_hook_callback extends sqlite3_callback_proxy {
|
||||
/**
|
||||
Must function as described for the C-level sqlite3_update_hook()
|
||||
callback. Must not throw.
|
||||
*/
|
||||
void call(int opId, String dbName, String tableName, long rowId);
|
||||
}
|
Reference in New Issue
Block a user