From: stephan Date: Mon, 9 Oct 2023 12:45:28 +0000 (+0000) Subject: Flesh out the error state captured by SqliteException.java. Doc additions. X-Git-Tag: version-3.44.0~141 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=66dacae4c3f818d0a9e94ecb4433c823a69a98aa;p=thirdparty%2Fsqlite.git Flesh out the error state captured by SqliteException.java. Doc additions. FossilOrigin-Name: 5c5397ff15543f4b3620244d9e57e15708eafcab1d42c9f87b4a60f0c01e8858 --- diff --git a/ext/jni/src/org/sqlite/jni/Sqlite.java b/ext/jni/src/org/sqlite/jni/Sqlite.java index 541c6c7c1e..23ceaa4b47 100644 --- a/ext/jni/src/org/sqlite/jni/Sqlite.java +++ b/ext/jni/src/org/sqlite/jni/Sqlite.java @@ -29,9 +29,14 @@ public final class Sqlite implements AutoCloseable { this.db = db; } - public static Sqlite open(String filename, int flags, String zVfs){ + /** + Returns a newly-opened db connection or throws SqliteException if + opening fails. All arguments are as documented for + sqlite3_open_v2(). + */ + public static Sqlite open(String filename, int flags, String vfsName){ final OutputPointer.sqlite3 out = new OutputPointer.sqlite3(); - final int rc = sqlite3_open_v2(filename, out, flags, zVfs); + final int rc = sqlite3_open_v2(filename, out, flags, vfsName); final sqlite3 n = out.take(); if( 0!=rc ){ if( null==n ) throw new SqliteException(rc); @@ -55,6 +60,10 @@ public final class Sqlite implements AutoCloseable { } } + /** + Returns this object's underlying native db handle, or null if + this instance has been closed. + */ sqlite3 dbHandle(){ return this.db; } } diff --git a/ext/jni/src/org/sqlite/jni/SqliteException.java b/ext/jni/src/org/sqlite/jni/SqliteException.java index 6eaf825dc3..3da5d8c583 100644 --- a/ext/jni/src/org/sqlite/jni/SqliteException.java +++ b/ext/jni/src/org/sqlite/jni/SqliteException.java @@ -21,22 +21,53 @@ import static org.sqlite.jni.CApi.*; and C via JNI. */ public final class SqliteException extends java.lang.RuntimeException { + int errCode = SQLITE_ERROR; + int xerrCode = SQLITE_ERROR; + int errOffset = -1; + int sysErrno = 0; + /** + Records the given error string and uses SQLITE_ERROR for both the + error code and extended error code. + */ public SqliteException(String msg){ super(msg); } + /** + Uses sqlite3_errstr(sqlite3ResultCode) for the error string and + sets both the error code and extended error code to the given + value. + */ public SqliteException(int sqlite3ResultCode){ super(sqlite3_errstr(sqlite3ResultCode)); + errCode = xerrCode = sqlite3ResultCode; } + /** + Records the current error state of db (which must not be null and + must refer to an opened db object) then closes it. + */ public SqliteException(sqlite3 db){ super(sqlite3_errmsg(db)); + errCode = sqlite3_errcode(db); + xerrCode = sqlite3_extended_errcode(db); + errOffset = sqlite3_error_offset(db); + sysErrno = sqlite3_system_errno(db); db.close(); } + /** + Records the current error state of db (which must not be null and must + refer to an open database) then closes it. + */ public SqliteException(Sqlite db){ this(db.dbHandle()); } + public int errcode(){ return errCode; } + public int extendedErrcode(){ return xerrCode; } + public int errorOffset(){ return errOffset; } + public int systemErrno(){ return sysErrno; } + } diff --git a/manifest b/manifest index 83fa2b3dc8..f7d7fb70fc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sin\sthe\stest\smodule\sfor\ssessions. -D 2023-10-09T12:39:59.903 +C Flesh\sout\sthe\serror\sstate\scaptured\sby\sSqliteException.java.\sDoc\sadditions. +D 2023-10-09T12:45:28.189 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -262,8 +262,8 @@ F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java ec6cd96bff5d3bc5af079cbf1 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c F ext/jni/src/org/sqlite/jni/SQLTester.java d246c67f93e2fa2603bd106dbb3246ea725c987dffd6e5d42214ae262f750c68 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c -F ext/jni/src/org/sqlite/jni/Sqlite.java 04c1efa37eda02e5695a890479f2de5cc54abdbec61042611419f0141e05f83b -F ext/jni/src/org/sqlite/jni/SqliteException.java cabf37b09f519b6b8aebecd100e7f66fffc1d244d3e46f62c2b12120b9e2a33c +F ext/jni/src/org/sqlite/jni/Sqlite.java 44b23a929e5d625b35c83fd49a80ada944bdd8b2bdece3ca7d400b33a2652fbd +F ext/jni/src/org/sqlite/jni/SqliteException.java f5d17a10202c0983fb074f66a0b48cf1e573b1da2eaeda679825e3edc1829706 F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java f7b85fe24cf6c3e43bdf7e390617657e8137359f804d76921829c2a8c41b6df1 F ext/jni/src/org/sqlite/jni/Tester2.java 75aa079e2baf8f73d95299da092e611656be0f6e12fe2fa051fdd984657857e2 @@ -2127,8 +2127,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 6acf52be7abce8dcf434c5ebf0d5e88859b033e6418077846247ecf00ccf9381 -R b6511d973ff6f4fe2616bdecdd85eae3 -U drh -Z a23b7d6675008bfc1be60599cdc88bc0 +P 3d5ec99397c183cfb8c5d31e1967e0df8a4d6edbea92bbdf728571e3a6a36d68 +R 3bc0c08a6ca17f2adf136645f965b46a +U stephan +Z a1ea6d2e83650fdb0f8b2c765c106868 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index db4a47bea3..c10b55961a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d5ec99397c183cfb8c5d31e1967e0df8a4d6edbea92bbdf728571e3a6a36d68 \ No newline at end of file +5c5397ff15543f4b3620244d9e57e15708eafcab1d42c9f87b4a60f0c01e8858 \ No newline at end of file