1
0
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:
stephan
2023-08-25 02:57:30 +00:00
parent 44b4b8260f
commit 5276552083
25 changed files with 353 additions and 296 deletions

View File

@ -59,29 +59,33 @@ $(bin.version-info): $(dir.tool)/version-info.c $(sqlite3.h) $(dir.top)/Makefile
# Be explicit about which Java files to compile so that we can work on
# in-progress files without requiring them to be in a compilable statae.
JAVA_FILES.main := $(patsubst %,$(dir.src.jni)/%,\
BusyHandler.java \
Collation.java \
CollationNeeded.java \
CommitHook.java \
authorizer_callback.java \
auto_extension_callback.java \
busy_handler_callback.java \
collation_callback.java \
collation_needed_callback.java \
commit_hook_callback.java \
config_sqllog_callback.java \
preupdate_hook_callback.java \
progress_handler_callback.java \
rollback_hook_callback.java \
trace_v2_callback.java \
update_hook_callback.java \
NativePointerHolder.java \
NotNull.java \
Nullable.java \
OutputPointer.java \
package-info.java \
ProgressHandler.java \
ResultCode.java \
RollbackHook.java \
SQLFunction.java \
SQLLog.java \
sqlite3_context.java \
sqlite3.java \
SQLite3Jni.java \
Tester1.java \
ValueHolder.java \
package-info.java \
sqlite3.java \
sqlite3_context.java \
sqlite3_stmt.java \
sqlite3_value.java \
Tester1.java \
Tracer.java \
UpdateHook.java \
ValueHolder.java \
sqlite3_xDestroy_callback.java \
)
ifeq (1,$(enable.fts5))
JAVA_FILES.main += $(patsubst %,$(dir.src.jni)/%,\

View File

@ -184,17 +184,6 @@ necessarily suppress any exceptions in order to maintain the C-style
semantics of the APIs.
Awkward Callback Names
------------------------------------------------------------------------
In places where the Java interface uses callbacks (see below), those
callbacks often have what might fairly be labeled as awkward names,
e.g. `sqlScalarFunction.xFunc()` and `preupdateHook.xPreUpdate()`.
Those names were chosen because they match the corresponding arguments
in the C-level API docs. If they were renamed to be more Java-esque,
documentation transparency would suffer.
Unwieldy Constructs are Re-mapped
------------------------------------------------------------------------
@ -246,18 +235,18 @@ follow that pattern use a slightly different Java interface:
```java
int sqlite3_create_collation(sqlite3 db, String name, int eTextRep,
Collation collation);
SomeCallbackType collation);
```
Where the `Collation` class has an abstract `xCompare()` method and
Where the `Collation` class has an abstract `call()` method and
no-op `xDestroy()` method which can be overridden if needed, leading to
a much more Java-esque usage:
```java
int rc = sqlite3_create_collation(db, "mycollation", SQLITE_UTF8, new Collation(){
int rc = sqlite3_create_collation(db, "mycollation", SQLITE_UTF8, new SomeCallbackType(){
// Required comparison function:
@Override public int xCompare(byte[] lhs, byte[] rhs){ ... }
@Override public int call(byte[] lhs, byte[] rhs){ ... }
// Optional finalizer function:
@Override public void xDestroy(){ ... }

View File

@ -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);
}

View File

@ -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);

View File

@ -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 );
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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(){}
}

View File

@ -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(){}
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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 );
}

View 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 );
}

View File

@ -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();
}

View File

@ -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();
}

View 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 {}

View 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();
}

View File

@ -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);

View File

@ -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);
}

View 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);
}

View File

@ -1,5 +1,5 @@
C javadoc\sadditions.
D 2023-08-25T00:27:28.089
C Replace\sall\sof\sthe\sJNI\sXyzHook/Handler\sclasses\swith\ssnake_cased\sones\swhich\sfollow\sunified\snaming\sconventions\sto\smake\sthem\seasier\sto\sapply.
D 2023-08-25T02:57:30.049
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -233,17 +233,11 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c
F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9
F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
F ext/jni/GNUmakefile 642624b421936807eeed2fe7d0f9df898837ad0e4be4d9e32af06b0e5ef2c5b6
F ext/jni/README.md 9d3caa2e038bfe5e8356a9e8ff66f93ca0647ac278339eeea296f10017f5cf35
F ext/jni/GNUmakefile fb73086e6f8ee40f3c79e32b8e0a27725b2680f9cf8ae41bde2556eb8e3fad2a
F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9
F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa
F ext/jni/src/c/sqlite3-jni.c e4bdcd17e8f8e825f206e1c6ab5adf7f507d70b64b0f795c0cde141077fb68b2
F ext/jni/src/c/sqlite3-jni.h 91c2eeee22d3594e6652d51edcce0cd94d258a768802fcfac13a78f900127b72
F ext/jni/src/org/sqlite/jni/Authorizer.java e6cbc6605d4d254be892d5197dea6290180efb7c5dbb3060f8487563bb11bb65
F ext/jni/src/org/sqlite/jni/AutoExtension.java bcc1849b2fccbe5e2d7ac9e9ac7f8d05a6d7088a8fedbaad90e39569745a61e6
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
F ext/jni/src/org/sqlite/jni/Collation.java 8dffbb00938007ad0967b2ab424d3c908413af1bbd3d212b9c9899910f1218d1
F ext/jni/src/org/sqlite/jni/CollationNeeded.java ad67843b6dd1c06b6b0a1dc72887b7c48e2a98042fcf6cacf14d42444037eab8
F ext/jni/src/org/sqlite/jni/CommitHook.java 87c6a8e5138c61a8eeff018fe16d23f29219150239746032687f245938baca1a
F ext/jni/src/c/sqlite3-jni.c 2e9cabce55f0a4c0a56b29bbaa367c133959e94a390ec0129b4054832d0421f9
F ext/jni/src/c/sqlite3-jni.h 3d8cdacce26d20fd967d67a2e8539d38fc2e9fe13598147399db4b2c303a89c8
F ext/jni/src/org/sqlite/jni/Fts5.java a45cd890202d72c3bfe8aea69b57b02b6dd588361af81d8b921954c37940b2f7
F ext/jni/src/org/sqlite/jni/Fts5Context.java 0a5a02047a6a1dd3e4a38b0e542a8dd2de365033ba30e6ae019a676305959890
F ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java 10cb2e0eb4dc5cf4241a7ccc0442a680f14a3ce6ecbb726552f2b5e026e521e0
@ -254,28 +248,36 @@ F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 564087036449a16df148dcf0a0
F ext/jni/src/org/sqlite/jni/NotNull.java a4016df436f454e8d6786dd8421484edd6fc604043cf7fd8ec94cf922ba61604
F ext/jni/src/org/sqlite/jni/Nullable.java b2f8755970e9dd0e917a505638d036ccc699c8422f1a69fe9d98c0804beaea17
F ext/jni/src/org/sqlite/jni/OutputPointer.java 8d7b2c865217d3b7a47dccaddc4a24748463b770eecca90873402a38c0b2d819
F ext/jni/src/org/sqlite/jni/PreUpdateHook.java dec00a706b58c67989f0ff56c4f0a703821d25b45c62dd7fed1b462049f15c26
F ext/jni/src/org/sqlite/jni/ProgressHandler.java 6f62053a828a572de809828b1ee495380677e87daa29a1c57a0e2c06b0a131dc
F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
F ext/jni/src/org/sqlite/jni/SQLFunction.java 4d6291fa14fcca1a040609378f9f00a193145d79c3abbda98ba32c340904cbeb
F ext/jni/src/org/sqlite/jni/SQLLog.java c60610b35208416940822e834d61f08fbbe5d6e06b374b541b49e41fd56c9798
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java af2d1a673f48bed8bb39ad9f7fe79c3d904cb2c6c875254a0e8c7e7db6539725
F ext/jni/src/org/sqlite/jni/Tester1.java e9b82c561ec8771b3e4ea537ebd7c16dd096928b6b8221967a4726104c7c6cb2
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java cb848377b214562c968934dc1749c5493d42254cbc825e44e2d2c34085c2ec5e
F ext/jni/src/org/sqlite/jni/Tester1.java 3bfbcbf0720f9b71e461eb016b8bc30289a7ceaab1aa5da13e319fd303bf19fd
F ext/jni/src/org/sqlite/jni/TesterFts5.java 6f135c60e24c89e8eecb9fe61dde0f3bb2906de668ca6c9186bcf34bdaf94629
F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
F ext/jni/src/org/sqlite/jni/ValueHolder.java f022873abaabf64f3dd71ab0d6037c6e71cece3b8819fa10bf26a5461dc973ee
F ext/jni/src/org/sqlite/jni/authorizer_callback.java 1d2d7fd584f917afa507820644d95504bcc9c5d7363a7afeb58de3b256851bfe w ext/jni/src/org/sqlite/jni/Authorizer.java
F ext/jni/src/org/sqlite/jni/auto_extension_callback.java c8754ffabe3b75bd8f209bf1451d6a180ec52e99b11c11b2e3642f1891eb2635 w ext/jni/src/org/sqlite/jni/AutoExtension.java
F ext/jni/src/org/sqlite/jni/busy_handler_callback.java c9b046631646a9c123f26f7b0056f274d1e85c02475981603271f6feefa9bfee w ext/jni/src/org/sqlite/jni/BusyHandler.java
F ext/jni/src/org/sqlite/jni/collation_callback.java 44ddecceafd1a099027a06bb53cbe825613255398990f58a57fcc9d9fb4c2ce2 w ext/jni/src/org/sqlite/jni/Collation.java
F ext/jni/src/org/sqlite/jni/collation_needed_callback.java 0d5cbac245db9ff22b67c92c06f2e31ed557cd018f1c4670ae970e6f16f22cee w ext/jni/src/org/sqlite/jni/CollationNeeded.java
F ext/jni/src/org/sqlite/jni/commit_hook_callback.java 88462783826026e61e522d9aae7a9b4cb0c30f7d56519e08a5de42213a0087bc w ext/jni/src/org/sqlite/jni/CommitHook.java
F ext/jni/src/org/sqlite/jni/config_sqllog_callback.java d8b9b4e0f9a522fd40a88b4f9f87308fff1be255523ad6cff8493bf3bbca2ec8 w ext/jni/src/org/sqlite/jni/SQLLog.java
F ext/jni/src/org/sqlite/jni/fts5_api.java 5198be71c162e3e0cb1f4962a7cdf0d7596e8af53f70c4af6db24aab8d53d9ba
F ext/jni/src/org/sqlite/jni/fts5_extension_function.java ac825035d7d83fc7fd960347abfa6803e1614334a21533302041823ad5fc894c
F ext/jni/src/org/sqlite/jni/fts5_tokenizer.java e530b36e6437fcc500e95d5d75fbffe272bdea20d2fac6be2e1336c578fba98b
F ext/jni/src/org/sqlite/jni/package-info.java 5652d1bcaaf3ccb06d26c174e6d0b60571a545a0a3354dd8303960677be05e14
F ext/jni/src/org/sqlite/jni/preupdate_hook_callback.java 2bcc61a9320a7af6be36e5a814d133dd610d8ead79622efd84e7444aabe25f6c w ext/jni/src/org/sqlite/jni/PreUpdateHook.java
F ext/jni/src/org/sqlite/jni/progress_handler_callback.java eae32bd36639b12552becf82a0481bb4c09d22655920007b62e49130ce97a850 w ext/jni/src/org/sqlite/jni/ProgressHandler.java
F ext/jni/src/org/sqlite/jni/rollback_hook_callback.java 25663dbad4f9da50019d0c68fc815d31155a04eaeb293f27fdc6f9b20a424760 w ext/jni/src/org/sqlite/jni/RollbackHook.java
F ext/jni/src/org/sqlite/jni/sqlite3.java 62b1b81935ccf3393472d17cb883dc5ff39c388ec3bc1de547f098a0217158fc
F ext/jni/src/org/sqlite/jni/sqlite3_callback_proxy.java 4b3369faab47d787594c0544000dbac751d69641cac866f82f9be0e13c4b2ce5
F ext/jni/src/org/sqlite/jni/sqlite3_context.java dca23e54f368f8ea37c112c1d2f74dc9522d5da2fdf67d6fd6b2ec9603d8514c
F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 78e6d1b95ac600a9475e9db4623f69449322b0c93d1bd4e1616e76ed547ed9fc
F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a
F ext/jni/src/org/sqlite/jni/tester/SQLTester.java bc3d6797a2f6cb7d443a0b72af84e5a45e0416b96af52e432d28e123db1970c3
F ext/jni/src/org/sqlite/jni/sqlite3_xDestroy_callback.java 90470ef3e901e8f4863adacf361b0afcd5c7633166ed6c747630a30659224c20
F ext/jni/src/org/sqlite/jni/tester/SQLTester.java e560303ada834363b615e5863050d1488bf5c83f0627b966fb1a0a6a4355029f
F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e
F ext/jni/src/org/sqlite/jni/trace_v2_callback.java b3365dbfa1c9b0d18541ae530055a8ff55fc5b8494d30c03a12eafd9c8cb4e8c w ext/jni/src/org/sqlite/jni/Tracer.java
F ext/jni/src/org/sqlite/jni/update_hook_callback.java 616dbc9f99bdfbde190af3d8a44a8ad418fdc5f8c63acb0a0d679bd063848da8 w ext/jni/src/org/sqlite/jni/UpdateHook.java
F ext/jni/src/tests/000-000-sanity.test cfe6dc1b950751d6096e3f5695becaadcdaa048bfe9567209d6eb676e693366d
F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9
@ -2098,8 +2100,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 7232b033954fae40df3db43e489e0e5a703c03308f500a1ae36fd9d707632d7f
R 2acb197dd02e88e8595f80978f7eae58
P bedf33d403677d243a1505ce549166850ab55671700b143278db5feb84883ab3
R 3d4d16fca03c716fac15f71f35ecf6fd
U stephan
Z c7c0446afbe0f68b470086328d8c934a
Z 276c090c642360abc3be58550d893d5e
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
bedf33d403677d243a1505ce549166850ab55671700b143278db5feb84883ab3
76e62a381249b3b4262b22bdffe7fc2816c820115c9df266956ab8817b127aca