Expose context_db_handle() to the JNI wrapper1 API and clean up some related tests.
FossilOrigin-Name: c23123af7d40dea24a0848dff987fd58a6703ce04165060533544db85983d566
This commit is contained in:
parent
348e192ea8
commit
1b199243cb
@ -12,10 +12,6 @@
|
||||
** This file is part of the wrapper1 interface for sqlite3.
|
||||
*/
|
||||
package org.sqlite.jni.wrapper1;
|
||||
import org.sqlite.jni.capi.CApi;
|
||||
import org.sqlite.jni.annotation.*;
|
||||
import org.sqlite.jni.capi.sqlite3_context;
|
||||
import org.sqlite.jni.capi.sqlite3_value;
|
||||
|
||||
/**
|
||||
EXPERIMENTAL/INCOMPLETE/UNTESTED
|
||||
|
@ -56,7 +56,7 @@ public interface SqlFunction {
|
||||
*/
|
||||
Arguments(sqlite3_context cx, sqlite3_value args[]){
|
||||
this.cx = cx;
|
||||
this.args = args==null ? new sqlite3_value[0] : args;;
|
||||
this.args = args==null ? new sqlite3_value[0] : args;
|
||||
this.length = this.args.length;
|
||||
}
|
||||
|
||||
@ -76,6 +76,16 @@ public interface SqlFunction {
|
||||
//! Returns the underlying sqlite3_context for these arguments.
|
||||
sqlite3_context getContext(){return cx;}
|
||||
|
||||
/**
|
||||
Returns the Sqlite (db) object associated with this UDF call,
|
||||
or null if the UDF is somehow called without such an object or
|
||||
the db has been closed in an untimely manner (e.g. closed by a
|
||||
UDF call).
|
||||
*/
|
||||
public Sqlite getDb(){
|
||||
return Sqlite.fromNative( CApi.sqlite3_context_db_handle(cx) );
|
||||
}
|
||||
|
||||
public int getArgCount(){ return args.length; }
|
||||
|
||||
public int getInt(int argNdx){return CApi.sqlite3_value_int(valueAt(argNdx));}
|
||||
|
@ -781,7 +781,7 @@ public final class Sqlite implements AutoCloseable {
|
||||
Returns the Sqlite which prepared this statement, or null if
|
||||
this statement has been finalized.
|
||||
*/
|
||||
public Sqlite db(){ return this._db; }
|
||||
public Sqlite getDb(){ return this._db; }
|
||||
|
||||
/**
|
||||
Works like sqlite3_reset() but throws on error.
|
||||
|
@ -74,7 +74,7 @@ public final class SqliteException extends java.lang.RuntimeException {
|
||||
}
|
||||
|
||||
public SqliteException(Sqlite.Stmt stmt){
|
||||
this(stmt.db());
|
||||
this(stmt.getDb());
|
||||
}
|
||||
|
||||
public int errcode(){ return errCode; }
|
||||
|
@ -241,6 +241,7 @@ public class Tester2 implements Runnable {
|
||||
Sqlite.Stmt stmt = db.prepare("SELECT ?1");
|
||||
Exception e = null;
|
||||
affirm( null!=stmt.nativeHandle() );
|
||||
affirm( db == stmt.getDb() );
|
||||
affirm( 1==stmt.bindParameterCount() );
|
||||
affirm( "?1".equals(stmt.bindParameterName(1)) );
|
||||
affirm( null==stmt.bindParameterName(2) );
|
||||
@ -294,21 +295,30 @@ public class Tester2 implements Runnable {
|
||||
final ValueHolder<Integer> vh = new ValueHolder<>(0);
|
||||
final ScalarFunction f = new ScalarFunction(){
|
||||
public void xFunc(SqlFunction.Arguments args){
|
||||
affirm( db == args.getDb() );
|
||||
for( SqlFunction.Arguments.Arg arg : args ){
|
||||
vh.value += arg.getInt();
|
||||
}
|
||||
args.resultInt(vh.value);
|
||||
}
|
||||
public void xDestroy(){
|
||||
++xDestroyCalled.value;
|
||||
}
|
||||
};
|
||||
db.createFunction("myfunc", -1, f);
|
||||
execSql(db, "select myfunc(1,2,3)");
|
||||
Sqlite.Stmt q = db.prepare("select myfunc(1,2,3)");
|
||||
affirm( q.step() );
|
||||
affirm( 6 == vh.value );
|
||||
vh.value = 0;
|
||||
execSql(db, "select myfunc(-1,-2,-3)");
|
||||
affirm( -6 == vh.value );
|
||||
affirm( 6 == q.columnInt(0) );
|
||||
q.finalizeStmt();
|
||||
affirm( 0 == xDestroyCalled.value );
|
||||
vh.value = 0;
|
||||
q = db.prepare("select myfunc(-1,-2,-3)");
|
||||
affirm( q.step() );
|
||||
affirm( -6 == vh.value );
|
||||
affirm( -6 == q.columnInt(0) );
|
||||
affirm( 0 == xDestroyCalled.value );
|
||||
q.finalizeStmt();
|
||||
}
|
||||
affirm( 1 == xDestroyCalled.value );
|
||||
}
|
||||
|
@ -12,10 +12,6 @@
|
||||
** This file is part of the wrapper1 interface for sqlite3.
|
||||
*/
|
||||
package org.sqlite.jni.wrapper1;
|
||||
import org.sqlite.jni.capi.CApi;
|
||||
import org.sqlite.jni.annotation.*;
|
||||
import org.sqlite.jni.capi.sqlite3_context;
|
||||
import org.sqlite.jni.capi.sqlite3_value;
|
||||
|
||||
/**
|
||||
A SqlFunction implementation for window functions. The T type
|
||||
|
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C Rework\sthe\sJNI\swrapper1\svariants\sof\sstatus()\sand\sdb_status()\sto\sbe\smore\sJava-esque.
|
||||
D 2023-11-04T13:37:42.589
|
||||
C Expose\scontext_db_handle()\sto\sthe\sJNI\swrapper1\sAPI\sand\sclean\sup\ssome\srelated\stests.
|
||||
D 2023-11-04T16:01:13.004
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -293,14 +293,14 @@ F ext/jni/src/org/sqlite/jni/fts5/fts5_api.java a8e88c3783d21cec51b0748568a96653
|
||||
F ext/jni/src/org/sqlite/jni/fts5/fts5_extension_function.java 9e2b954d210d572552b28aca523b272fae14bd41e318921b22f65b728d5bf978
|
||||
F ext/jni/src/org/sqlite/jni/fts5/fts5_tokenizer.java 92bdaa3893bd684533004d64ade23d329843f809cd0d0f4f1a2856da6e6b4d90
|
||||
F ext/jni/src/org/sqlite/jni/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/AggregateFunction.java bbe60ac7fd8718edb215a23dc901771bcedb1df3b46d9cf6caff6f419828587f
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/AggregateFunction.java d5c108b02afd3c63c9e5e53f71f85273c1bfdc461ae526e0a0bb2b25e4df6483
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/ScalarFunction.java 43c43adfb7866098aadaaca1620028a6ec82d5193149970019b1cce9eb59fb03
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqlFunction.java 0b01b9058ef6737c85b505c6aa2490fb1dc1d974fb39d88a93269fed09553f9f
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Sqlite.java ab6bee53895e5f7345b57d32ef30e9cc9c9c09979a31211f63e60dcdea9a7ab1
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqliteException.java aa85b4b05fae240b14f3d332f9524a2f80c619fb03856be72b4adda866b63b72
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Tester2.java cbd087d3fcbfca384656fc2189a9b017e4afe70f0f17d8266d28c628ab97cada
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqlFunction.java e787f5f36d5832fe3c7a000a8609eb0629fb160b95f8f25566df13e72e6f5470
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Sqlite.java 3e813aa4a680948a1885a5df1537c9245b3b7362aaf6aa31f679640e81da020e
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqliteException.java 929a1e2ab4e135fbbae7f0d2d609f77cfbbc60bbec7ba789ce23d9c73bc6156e
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Tester2.java 96d7908da8bad591aff8f192cb83e038fd5861ef4601726eeda24905422718c9
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/ValueHolder.java 7b89a7391f771692c5b83b0a5b86266abe8d59f1c77d7a0eccc9b79f259d79af
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/WindowFunction.java 1a1afbafbd7406ff67e7d6405541c6347517c731de535a97d7a3df1d4db835b4
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/WindowFunction.java c7d1452f9ff26175b3c19bbf273116cc2846610af68e01756d755f037fe7319f
|
||||
F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43443408f3000139478c4dc745
|
||||
F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
|
||||
F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0
|
||||
@ -2142,8 +2142,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 b5cdcb9279d9276f24b67083839f463beecd731f46f2e8bf68fff716df0a3921
|
||||
R 9ee74b8e162e4e8a23028ccec92c6373
|
||||
P 40ad3920673561a06edf0b70a50a40be6cd20817fe22b87b63a9ac80cb2c9df8
|
||||
R f79739ffe6d4cd3ba58087c1ffb0d1f9
|
||||
U stephan
|
||||
Z ce3f2fb1a954c596b6cdbc560de71d23
|
||||
Z 05734d404abe66e6e03def34a1d0d490
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
40ad3920673561a06edf0b70a50a40be6cd20817fe22b87b63a9ac80cb2c9df8
|
||||
c23123af7d40dea24a0848dff987fd58a6703ce04165060533544db85983d566
|
Loading…
x
Reference in New Issue
Block a user