1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Rename JNI sqlite3_errmsg() to sqlite3_errmsg16() for overall constency with the text()/text16() family of functions.

FossilOrigin-Name: c4a8d8a5711bd2abeaf1c31046784d1bccff4b98e96522250866d1ee8ec6a9fe
This commit is contained in:
stephan
2023-09-12 17:03:40 +00:00
parent 1110f8ffcd
commit 09d72e4a6e
7 changed files with 28 additions and 25 deletions

View File

@ -3361,11 +3361,14 @@ S3JniApi(sqlite3_errcode(),jint,1errcode)(
return pDb ? sqlite3_errcode(pDb) : SQLITE_MISUSE;
}
S3JniApi(sqlite3_errmsg(),jstring,1errmsg)(
S3JniApi(sqlite3_errmsg16(),jstring,1errmsg16)(
JniArgsEnvClass, jobject jpDb
){
sqlite3 * const pDb = PtrGet_sqlite3(jpDb);
return pDb ? s3jni_utf8_to_jstring( sqlite3_errmsg(pDb), -1) : 0;
return pDb ? s3jni_utf8_to_jstring( sqlite3_errmsg(pDb), -1) : 0
/* We don't use errmsg16() directly only because it would cause an
additional level of internal encoding in sqlite3. The end
effect should be identical to using errmsg16(), however. */;
}
S3JniApi(sqlite3_errstr(),jstring,1errstr)(

View File

@ -1341,10 +1341,10 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errcode
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_errmsg
* Method: sqlite3_errmsg16
* Signature: (Lorg/sqlite/jni/sqlite3;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errmsg
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errmsg16
(JNIEnv *, jclass, jobject);
/*

View File

@ -711,7 +711,7 @@ public final class SQLite3Jni {
public static native int sqlite3_errcode(@NotNull sqlite3 db);
@Canonical
public static native String sqlite3_errmsg(@NotNull sqlite3 db);
public static native String sqlite3_errmsg16(@NotNull sqlite3 db);
@Canonical
public static native String sqlite3_errstr(int resultCode);

View File

@ -146,7 +146,7 @@ public class Tester1 implements Runnable {
sqlite3 db = out.take();
if( 0!=rc ){
final String msg =
null==db ? sqlite3_errstr(rc) : sqlite3_errmsg(db);
null==db ? sqlite3_errstr(rc) : sqlite3_errmsg16(db);
sqlite3_close(db);
throw new RuntimeException("Opening db failed: "+msg);
}
@ -197,7 +197,7 @@ public class Tester1 implements Runnable {
if(SQLITE_ROW==rc || SQLITE_DONE==rc) rc = 0;
if( 0!=rc && throwOnError){
throw new RuntimeException("db op failed with rc="
+rc+": "+sqlite3_errmsg(db));
+rc+": "+sqlite3_errmsg16(db));
}
return rc;
}
@ -290,7 +290,7 @@ public class Tester1 implements Runnable {
affirm( db == sqlite3_db_handle(stmt) );
rc = sqlite3_step(stmt);
if( SQLITE_DONE != rc ){
outln("step failed ??? ",rc, " ",sqlite3_errmsg(db));
outln("step failed ??? ",rc, " ",sqlite3_errmsg16(db));
}
affirm(SQLITE_DONE == rc);
sqlite3_finalize(stmt);
@ -346,7 +346,7 @@ public class Tester1 implements Runnable {
stmt = sqlite3_prepare(db, "intentional error");
affirm( null==stmt );
affirm( 0!=sqlite3_errcode(db) );
affirm( 0==sqlite3_errmsg(db).indexOf("near \"intentional\"") );
affirm( 0==sqlite3_errmsg16(db).indexOf("near \"intentional\"") );
sqlite3_finalize(stmt);
stmt = sqlite3_prepare(db, "/* empty input*/\n-- comments only");
affirm( null==stmt );
@ -729,7 +729,7 @@ public class Tester1 implements Runnable {
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);
affirm( 0 != rc );
affirm( sqlite3_errmsg(db).indexOf("an xFinal") > 0 );
affirm( sqlite3_errmsg16(db).indexOf("an xFinal") > 0 );
SQLFunction funcSc = new ScalarFunction(){
@Override public void xFunc(sqlite3_context cx, sqlite3_value[] args){
@ -743,7 +743,7 @@ public class Tester1 implements Runnable {
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);
affirm( 0 != rc );
affirm( sqlite3_errmsg(db).indexOf("an xFunc") > 0 );
affirm( sqlite3_errmsg16(db).indexOf("an xFunc") > 0 );
rc = sqlite3_create_function(db, "mysca", 1, -1, funcSc);
affirm( SQLITE_FORMAT==rc, "invalid encoding value." );
sqlite3_close_v2(db);

View File

@ -71,7 +71,7 @@ class SQLTesterException extends RuntimeException {
class DbException extends SQLTesterException {
DbException(sqlite3 db, int rc, boolean closeDb){
super("DB error #"+rc+": "+sqlite3_errmsg(db),true);
super("DB error #"+rc+": "+sqlite3_errmsg16(db),true);
if( closeDb ) sqlite3_close_v2(db);
}
DbException(sqlite3 db, int rc){
@ -458,7 +458,7 @@ public class SQLTester {
private void appendDbErr(sqlite3 db, StringBuilder sb, int rc){
sb.append(org.sqlite.jni.ResultCode.getEntryForInt(rc)).append(' ');
final String msg = escapeSqlValue(sqlite3_errmsg(db));
final String msg = escapeSqlValue(sqlite3_errmsg16(db));
if( '{' == msg.charAt(0) ){
sb.append(msg);
}else{
@ -932,7 +932,7 @@ class RunCommand extends Command {
final int rc = t.execSql(db, false, ResultBufferMode.NONE,
ResultRowMode.ONELINE, sql);
if( 0!=rc && t.isVerbose() ){
String msg = sqlite3_errmsg(db);
String msg = sqlite3_errmsg16(db);
ts.verbose1(argv[0]," non-fatal command error #",rc,": ",
msg,"\nfor SQL:\n",sql);
}