]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Bind sqlite3_status(64)() to JNI.
authorstephan <stephan@noemail.net>
Sat, 12 Aug 2023 10:06:59 +0000 (10:06 +0000)
committerstephan <stephan@noemail.net>
Sat, 12 Aug 2023 10:06:59 +0000 (10:06 +0000)
FossilOrigin-Name: cefb6614e65ca1764ec72702f92f801382e63aa9b221fc9c68719d497e7499fd

ext/jni/src/c/sqlite3-jni.c
ext/jni/src/c/sqlite3-jni.h
ext/jni/src/org/sqlite/jni/SQLite3Jni.java
ext/jni/src/org/sqlite/jni/Tester1.java
manifest
manifest.uuid

index fef6f0233ce082141c1faace979d27a0b0f2f2be..3c7dac6310ca64a69e3f10de7e7ff272b5f559af 100644 (file)
@@ -310,7 +310,9 @@ static const struct {
 #define JBA_TOC(ARG) (*env)->GetByteArrayElements(env,ARG, NULL)
 #define JBA_RELEASE(ARG,VAR) if(VAR) (*env)->ReleaseByteArrayElements(env, ARG, VAR, JNI_ABORT)
 
-/* Marker for code which needs(?) to be made thread-safe. */
+/* Marker for code which needs(?) to be made thread-safe.  REASON is a
+   terse reminder about why that function requires a mutex.
+*/
 #define FIXME_THREADING(REASON)
 
 enum {
@@ -1389,6 +1391,15 @@ static void OutputPointer_set_Int32(JNIEnv * const env, jobject const jOut, int
   EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int32.value");
 }
 
+/* Sets the value property of the OutputPointer.Int64 jOut object
+   to v. */
+static void OutputPointer_set_Int64(JNIEnv * const env, jobject const jOut, jlong v){
+  jfieldID setter = 0;
+  setupOutputPointer(env, S3JniClassNames.OutputPointer_Int64, "J", jOut, &setter);
+  (*env)->SetLongField(env, jOut, setter, v);
+  EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int64.value");
+}
+
 static void OutputPointer_set_sqlite3(JNIEnv * const env, jobject const jOut,
                               jobject jDb){
   jfieldID setter = 0;
@@ -1408,14 +1419,6 @@ static void OutputPointer_set_sqlite3_stmt(JNIEnv * const env, jobject const jOu
 }
 
 #ifdef SQLITE_ENABLE_FTS5
-/* Sets the value property of the OutputPointer.Int64 jOut object
-   to v. */
-static void OutputPointer_set_Int64(JNIEnv * const env, jobject const jOut, jlong v){
-  jfieldID setter = 0;
-  setupOutputPointer(env, S3JniClassNames.OutputPointer_Int64, "J", jOut, &setter);
-  (*env)->SetLongField(env, jOut, setter, v);
-  EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int64.value");
-}
 #if 0
 /* Sets the value property of the OutputPointer.ByteArray jOut object
    to v. */
@@ -3113,6 +3116,30 @@ JDECL(void,1set_1last_1insert_1rowid)(JENV_CSELF, jobject jpDb, jlong rowId){
                                 (sqlite3_int64)rowId);
 }
 
+FIXME_THREADING(nphCache)
+JDECL(jint,1status)(JENV_CSELF, jint op, jobject jOutCurrent, jobject jOutHigh,
+                    jboolean reset ){
+  int iCur = 0, iHigh = 0;
+  int rc = sqlite3_status( op, &iCur, &iHigh, reset );
+  if( 0==rc ){
+    OutputPointer_set_Int32(env, jOutCurrent, iCur);
+    OutputPointer_set_Int32(env, jOutHigh, iHigh);
+  }
+  return (jint)rc;
+}
+
+FIXME_THREADING(nphCache)
+JDECL(jint,1status64)(JENV_CSELF, jint op, jobject jOutCurrent, jobject jOutHigh,
+                      jboolean reset ){
+  sqlite3_int64 iCur = 0, iHigh = 0;
+  int rc = sqlite3_status64( op, &iCur, &iHigh, reset );
+  if( 0==rc ){
+    OutputPointer_set_Int64(env, jOutCurrent, iCur);
+    OutputPointer_set_Int64(env, jOutHigh, iHigh);
+  }
+  return (jint)rc;
+}
+
 static int s3jni_strlike_glob(int isLike, JNIEnv *const env,
                               jbyteArray baG, jbyteArray baT, jint escLike){
   int rc = 0;
index d8e75cd7ba1f37cc9e1595296c16a91e7600ffe8..48720d0da8b10faff3f0f7bc0744e98b0c2e836b 100644 (file)
@@ -1419,6 +1419,22 @@ JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1result_1text
 JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1result_1text64
   (JNIEnv *, jclass, jobject, jbyteArray, jlong, jint);
 
+/*
+ * Class:     org_sqlite_jni_SQLite3Jni
+ * Method:    sqlite3_status
+ * Signature: (ILorg/sqlite/jni/OutputPointer/Int32;Lorg/sqlite/jni/OutputPointer/Int32;Z)I
+ */
+JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1status
+  (JNIEnv *, jclass, jint, jobject, jobject, jboolean);
+
+/*
+ * Class:     org_sqlite_jni_SQLite3Jni
+ * Method:    sqlite3_status64
+ * Signature: (ILorg/sqlite/jni/OutputPointer/Int64;Lorg/sqlite/jni/OutputPointer/Int64;Z)I
+ */
+JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1status64
+  (JNIEnv *, jclass, jint, jobject, jobject, jboolean);
+
 /*
  * Class:     org_sqlite_jni_SQLite3Jni
  * Method:    sqlite3_rollback_hook
index 46488a40a94c6b189c3549a2a45b2fde737d1333..d9508a9bad65fc446d031e91a6b1776fabf5d849 100644 (file)
@@ -937,14 +937,15 @@ public final class SQLite3Jni {
   );
 
 
-  // public static synchronized native int sqlite3_status(
-  //   int op, OutputPointer.Int32 pCurrent, OutputPointer.Int32 pHighwater,
-  //   boolean reset
-  // );
-  // public static synchronized native int sqlite3_status64(
-  //   int op, OutputPointer.Int64 pCurrent, OutputPointer.Int64 pHighwater,
-  //   boolean reset
-  // );
+  public static synchronized native int sqlite3_status(
+    int op, @NotNull OutputPointer.Int32 pCurrent,
+    @NotNull OutputPointer.Int32 pHighwater, boolean reset
+  );
+
+  public static synchronized native int sqlite3_status64(
+    int op, @NotNull OutputPointer.Int64 pCurrent,
+    @NotNull OutputPointer.Int64 pHighwater, boolean reset
+  );
 
   /**
      Sets the current UDF result to the given bytes, which are assumed
index be1fa3edc2307d41fd4f6c9a526cea0a56f1c793..1b9f7669590fb8b44e63d0d9f9792701157b06d1 100644 (file)
@@ -140,6 +140,17 @@ public class Tester1 {
     return rv;
   }
 
+  private static void testCompileOption(){
+    int i = 0;
+    String optName;
+    outln("compile options:");
+    for( ; null != (optName = sqlite3_compileoption_get(i)); ++i){
+      outln("\t"+optName+"\t (used="+
+            sqlite3_compileoption_used(optName)+")");
+    }
+
+  }
+
   private static void testOpenDb1(){
     final OutputPointer.sqlite3 out = new OutputPointer.sqlite3();
     int rc = sqlite3_open(":memory:", out);
@@ -155,17 +166,6 @@ public class Tester1 {
     affirm(0 == db.getNativePointer());
   }
 
-  private static void testCompileOption(){
-    int i = 0;
-    String optName;
-    outln("compile options:");
-    for( ; null != (optName = sqlite3_compileoption_get(i)); ++i){
-      outln("\t"+optName+"\t (used="+
-            sqlite3_compileoption_used(optName)+")");
-    }
-
-  }
-
   private static void testOpenDb2(){
     final OutputPointer.sqlite3 out = new OutputPointer.sqlite3();
     int rc = sqlite3_open_v2(":memory:", out,
@@ -488,6 +488,27 @@ public class Tester1 {
     affirm( 5 == ba.length /* as opposed to 6 in modified utf-8 */);
   }
 
+  private static void testStatus(){
+    final OutputPointer.Int64 cur64 = new OutputPointer.Int64();
+    final OutputPointer.Int64 high64 = new OutputPointer.Int64();
+    final OutputPointer.Int32 cur32 = new OutputPointer.Int32();
+    final OutputPointer.Int32 high32 = new OutputPointer.Int32();
+    final sqlite3 db = createNewDb();
+    execSql(db, "create table t(a)");
+    sqlite3_close_v2(db);
+
+    int rc = sqlite3_status(SQLITE_STATUS_MEMORY_USED, cur32, high32, false);
+    affirm( 0 == rc );
+    affirm( cur32.getValue() > 0 );
+    affirm( high32.getValue() >= cur32.getValue() );
+
+    rc = sqlite3_status64(SQLITE_STATUS_MEMORY_USED, cur64, high64, false);
+    affirm( 0 == rc );
+    affirm( cur64.getValue() > 0 );
+    affirm( high64.getValue() >= cur64.getValue() );
+
+  }
+
   private static void testUdf1(){
     final sqlite3 db = createNewDb();
     // These ValueHolders are just to confirm that the func did what we want...
@@ -1083,6 +1104,7 @@ public class Tester1 {
     testSql();
     testCollation();
     testToUtf8();
+    testStatus();
     testUdf1();
     testUdfJavaObject();
     testUdfAggregate();
index 092e3b47a65586a3d7200dd255f3b213fe5720ac..a256199706cb08f9470856839a00d21b4cc9b43d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stiming\sinfo\sto\sSQLTester.
-D 2023-08-11T21:25:33.877
+C Bind\ssqlite3_status(64)()\sto\sJNI.
+D 2023-08-12T10:06:59.356
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -234,8 +234,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3
 F ext/jni/GNUmakefile 6a6633f768431bc1195c1b64bcec162069e3ed02442808eef9bd173c59ed0ddd
 F ext/jni/README.md 7a614a2fa6c561205f7a53fd8626cf93a7b5711ff454fc1814517f796df398eb
 F ext/jni/jar-dist.make f90a553203a57934bf275bed86479485135a52f48ac5c1cfe6499ae07b0b35a4
-F ext/jni/src/c/sqlite3-jni.c 1b9fd402d507012b9c6f7f84f2a5998c77189048a893753790569b0329f76495
-F ext/jni/src/c/sqlite3-jni.h 8f9e03016fea584627219eb4a14c6b1a6ba9fffbd7bc0df9e14220a6af8cfe18
+F ext/jni/src/c/sqlite3-jni.c 5bb53c3f38486a79358737400d4e8a3ef66ae4ea58e7a5bd6e24a5816c2ad653
+F ext/jni/src/c/sqlite3-jni.h 7a51d1045ef78c2cb6929f6de5bd8242e9ebafe8abfe4a4255b67b62cfb4d2d5
 F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892
 F ext/jni/src/org/sqlite/jni/AutoExtension.java 18e83f6f463e306df60b2dceb65247d32af1f78af4bbbae9155411a8c6cdb093
 F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
@@ -254,8 +254,8 @@ F ext/jni/src/org/sqlite/jni/ProgressHandler.java 6f62053a828a572de809828b1ee495
 F ext/jni/src/org/sqlite/jni/ResultCode.java 7cdf993f2037ab7bd244c9a34dbaef2ace3beb5da5d7e7fda5c6f67634ceb647
 F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
 F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46
-F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 23dec2c267ef1882bb0bfc12a2c771e13e091885942344abbde90861f7b795fa
-F ext/jni/src/org/sqlite/jni/Tester1.java 62ba3f547800d6e35263f9e6caca9d82f6a087e6d02e1983d7acf5aab81115b6
+F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 21af88949fd4c909d43a511f51e352f51dab34bbd5c42eba885709b7001dad03
+F ext/jni/src/org/sqlite/jni/Tester1.java c7bb4747c2df2aa52cd00bcaf15ed8609df121d80f2af75b05cbf0f673a8be42
 F ext/jni/src/org/sqlite/jni/TesterFts5.java cf2d687baafffdeba219b77cf611fd47a0556248820ea794ae3e8259bfbdc5ee
 F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
 F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
@@ -2091,8 +2091,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 4f0aeeba0287e846908180eab6f7080ebe1323ebe49340771864d110e1ca5b2b
-R 83650742b7c53ba16249ac5a897c9107
+P b69b5facbf94e03e74d4a739ab85c5baac1c9ecbea8c330b2135d77e525b5d8a
+R b76030b5e4eb661dcf175e25776950a3
 U stephan
-Z e72133113955550d8ba2a524328196a9
+Z 02ed26d64128e71e5e4367d3108664ea
 # Remove this line to create a well-formed Fossil manifest.
index 355e8c53f9e4a3a48dd8106bad75bb3ff8e6fb0e..73cd2d3788d372700658e77fc5a0f7f383f45816 100644 (file)
@@ -1 +1 @@
-b69b5facbf94e03e74d4a739ab85c5baac1c9ecbea8c330b2135d77e525b5d8a
\ No newline at end of file
+cefb6614e65ca1764ec72702f92f801382e63aa9b221fc9c68719d497e7499fd
\ No newline at end of file