mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Make JNI binding of sqlite3_value_frombind() return boolean instead of int and add tests for it.
FossilOrigin-Name: 906e2ed3e9647f5c2355e9fea2beee141767cae7016da9fa1fe88283726b9369
This commit is contained in:
@ -2036,6 +2036,12 @@ static void udf_xInverse(sqlite3_context* cx, int argc,
|
||||
JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jlong jpSValue){ \
|
||||
return (jint)CName(S3JniLongPtr_sqlite3_value(jpSValue)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (boolean CName(sqlite3_value*)). */
|
||||
#define WRAP_BOOL_SVALUE(JniNameSuffix,CName) \
|
||||
JniDecl(jboolean,JniNameSuffix)(JniArgsEnvClass, jlong jpSValue){ \
|
||||
return (jint)CName(S3JniLongPtr_sqlite3_value(jpSValue)) \
|
||||
? JNI_TRUE : JNI_FALSE; \
|
||||
}
|
||||
|
||||
WRAP_INT_DB(1changes, sqlite3_changes)
|
||||
WRAP_INT64_DB(1changes64, sqlite3_changes64)
|
||||
@ -2075,7 +2081,7 @@ WRAP_INT64_DB(1total_1changes64, sqlite3_total_changes64)
|
||||
WRAP_INT_SVALUE(1value_1bytes, sqlite3_value_bytes)
|
||||
WRAP_INT_SVALUE(1value_1bytes16, sqlite3_value_bytes16)
|
||||
WRAP_INT_SVALUE(1value_1encoding, sqlite3_value_encoding)
|
||||
WRAP_INT_SVALUE(1value_1frombind, sqlite3_value_frombind)
|
||||
WRAP_BOOL_SVALUE(1value_1frombind, sqlite3_value_frombind)
|
||||
WRAP_INT_SVALUE(1value_1nochange, sqlite3_value_nochange)
|
||||
WRAP_INT_SVALUE(1value_1numeric_1type, sqlite3_value_numeric_type)
|
||||
WRAP_INT_SVALUE(1value_1subtype, sqlite3_value_subtype)
|
||||
@ -2083,6 +2089,7 @@ WRAP_INT_SVALUE(1value_1type, sqlite3_value_type)
|
||||
|
||||
#undef WRAP_BOOL_DB
|
||||
#undef WRAP_BOOL_STMT
|
||||
#undef WRAP_BOOL_SVALUE
|
||||
#undef WRAP_INT64_DB
|
||||
#undef WRAP_INT_DB
|
||||
#undef WRAP_INT_INT
|
||||
|
@ -2022,9 +2022,9 @@ JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1free
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_value_frombind
|
||||
* Signature: (J)I
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1frombind
|
||||
JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1frombind
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
|
@ -2105,10 +2105,10 @@ final class SQLite3Jni {
|
||||
}
|
||||
|
||||
@Canonical
|
||||
static native int sqlite3_value_frombind(@NotNull long ptrToValue);
|
||||
static native boolean sqlite3_value_frombind(@NotNull long ptrToValue);
|
||||
|
||||
@Canonical
|
||||
public static int sqlite3_value_frombind(@NotNull sqlite3_value v){
|
||||
public static boolean sqlite3_value_frombind(@NotNull sqlite3_value v){
|
||||
return sqlite3_value_frombind(v.getNativePointer());
|
||||
}
|
||||
|
||||
|
@ -399,6 +399,16 @@ public class Tester1 implements Runnable {
|
||||
affirm( !sqlite3_stmt_busy(stmt) );
|
||||
sqlite3_finalize(stmt);
|
||||
affirm(total1 == total2);
|
||||
|
||||
// sqlite3_value_frombind() checks...
|
||||
stmt = prepare(db, "SELECT 1, ?");
|
||||
sqlite3_bind_int(stmt, 1, 2);
|
||||
rc = sqlite3_step(stmt);
|
||||
affirm( SQLITE_ROW==rc );
|
||||
affirm( !sqlite3_value_frombind(sqlite3_column_value(stmt, 0)) );
|
||||
affirm( sqlite3_value_frombind(sqlite3_column_value(stmt, 1)) );
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close_v2(db);
|
||||
affirm(0 == db.getNativePointer());
|
||||
}
|
||||
|
Reference in New Issue
Block a user