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

Adapt JNI sqlite3_bind_...() bindings to the new pointer-passing method and correct the mapping of sqlite3_bind_zeroblob64() to use zeroblob64() instead of zeroblob(). Related internal API renaming.

FossilOrigin-Name: 980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869
This commit is contained in:
stephan
2023-09-27 11:01:32 +00:00
parent 9afd67cce7
commit a917ee7056
5 changed files with 200 additions and 127 deletions

View File

@ -1435,13 +1435,6 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph,
** will work, despite the incorrect macro name, so long as the
** argument is a Java sqlite3 object, as this operation only has void
** pointers to work with.
**
** PtrCast_T(X,Y) variant expects X to be an unqualified sqlite3
** struct type name and Y to be a native pointer to such an object in
** the form of a jlong value. The jlong is simply cast to (X*). This
** approach is, as of 2023-09-27, supplanting the former approach. We
** now do the native pointer extraction in the Java side, rather than
** the C side, because it's reportedly significantly faster.
*/
#define PtrGet_T(T,OBJ) (T*)NativePointerHolder_get(OBJ, S3JniNph(T))
#define PtrGet_sqlite3(OBJ) PtrGet_T(sqlite3, OBJ)
@ -1450,7 +1443,18 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph,
#define PtrGet_sqlite3_context(OBJ) PtrGet_T(sqlite3_context, OBJ)
#define PtrGet_sqlite3_stmt(OBJ) PtrGet_T(sqlite3_stmt, OBJ)
#define PtrGet_sqlite3_value(OBJ) PtrGet_T(sqlite3_value, OBJ)
#define PtrCast_T(T,JLongPtr) (T*)(JLongPtr)
/*
** S3JniLongPtr_T(X,Y) expects X to be an unqualified sqlite3
** struct type name and Y to be a native pointer to such an object in
** the form of a jlong value. The jlong is simply cast to (X*). This
** approach is, as of 2023-09-27, supplanting the former approach. We
** now do the native pointer extraction in the Java side, rather than
** the C side, because it's reportedly significantly faster.
*/
#define S3JniLongPtr_T(T,JLongPtr) (T*)(JLongPtr)
#define S3JniLongPtr_sqlite3(JLongPtr) S3JniLongPtr_T(sqlite3,JLongPtr)
#define S3JniLongPtr_sqlite3_backup(JLongPtr) S3JniLongPtr_T(sqlite3_backup,JLongPtr)
#define S3JniLongPtr_sqlite3_stmt(JLongPtr) S3JniLongPtr_T(sqlite3_stmt,JLongPtr)
/*
** Extracts the new S3JniDb instance from the free-list, or allocates
@ -2031,7 +2035,6 @@ static void udf_xInverse(sqlite3_context* cx, int argc,
return (jint)CName(PtrGet_sqlite3_value(jpSValue)); \
}
WRAP_INT_STMT(1bind_1parameter_1count, sqlite3_bind_parameter_count)
WRAP_INT_DB(1changes, sqlite3_changes)
WRAP_INT64_DB(1changes64, sqlite3_changes64)
WRAP_INT_STMT(1clear_1bindings, sqlite3_clear_bindings)
@ -2235,7 +2238,7 @@ S3JniApi(sqlite3_backup_finish(),jint,1backup_1finish)(
){
int rc = 0;
if( jpBack!=0 ){
rc = sqlite3_backup_finish( PtrCast_T(sqlite3_backup,jpBack) );
rc = sqlite3_backup_finish( S3JniLongPtr_sqlite3_backup(jpBack) );
}
return rc;
}
@ -2244,8 +2247,8 @@ S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)(
JniArgsEnvClass, jlong jpDbDest, jstring jTDest,
jlong jpDbSrc, jstring jTSrc
){
sqlite3 * const pDest = PtrCast_T(sqlite3,jpDbDest);
sqlite3 * const pSrc = PtrCast_T(sqlite3,jpDbSrc);
sqlite3 * const pDest = S3JniLongPtr_sqlite3(jpDbDest);
sqlite3 * const pSrc = S3JniLongPtr_sqlite3(jpDbSrc);
char * const zDest = s3jni_jstring_to_utf8(jTDest, 0);
char * const zSrc = s3jni_jstring_to_utf8(jTSrc, 0);
jobject rv = 0;
@ -2268,64 +2271,65 @@ S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)(
S3JniApi(sqlite3_backup_pagecount(),jint,1backup_1pagecount)(
JniArgsEnvClass, jlong jpBack
){
return sqlite3_backup_pagecount(PtrCast_T(sqlite3_backup,jpBack));
return sqlite3_backup_pagecount(S3JniLongPtr_sqlite3_backup(jpBack));
}
S3JniApi(sqlite3_backup_remaining(),jint,1backup_1remaining)(
JniArgsEnvClass, jlong jpBack
){
return sqlite3_backup_remaining(PtrCast_T(sqlite3_backup,jpBack));
return sqlite3_backup_remaining(S3JniLongPtr_sqlite3_backup(jpBack));
}
S3JniApi(sqlite3_backup_step(),jint,1backup_1step)(
JniArgsEnvClass, jlong jpBack, jint nPage
){
return sqlite3_backup_step(PtrCast_T(sqlite3_backup,jpBack), (int)nPage);
return sqlite3_backup_step(S3JniLongPtr_sqlite3_backup(jpBack), (int)nPage);
}
S3JniApi(sqlite3_bind_blob(),jint,1bind_1blob)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax
JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax
){
jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0;
int rc;
if( pBuf ){
rc = sqlite3_bind_blob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx,
rc = sqlite3_bind_blob(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx,
pBuf, (int)nMax, SQLITE_TRANSIENT);
s3jni_jbyteArray_release(baData, pBuf);
}else{
rc = baData
? SQLITE_NOMEM
: sqlite3_bind_null( PtrGet_sqlite3_stmt(jpStmt), ndx );
: sqlite3_bind_null( S3JniLongPtr_sqlite3_stmt(jpStmt), ndx );
}
return (jint)rc;
}
S3JniApi(sqlite3_bind_double(),jint,1bind_1double)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jdouble val
JniArgsEnvClass, jlong jpStmt, jint ndx, jdouble val
){
return (jint)sqlite3_bind_double(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (double)val);
return (jint)sqlite3_bind_double(S3JniLongPtr_sqlite3_stmt(jpStmt),
(int)ndx, (double)val);
}
S3JniApi(sqlite3_bind_int(),jint,1bind_1int)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jint val
JniArgsEnvClass, jlong jpStmt, jint ndx, jint val
){
return (jint)sqlite3_bind_int(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (int)val);
return (jint)sqlite3_bind_int(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, (int)val);
}
S3JniApi(sqlite3_bind_int64(),jint,1bind_1int64)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jlong val
JniArgsEnvClass, jlong jpStmt, jint ndx, jlong val
){
return (jint)sqlite3_bind_int64(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_int64)val);
return (jint)sqlite3_bind_int64(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_int64)val);
}
/*
** Bind a new global ref to Object `val` using sqlite3_bind_pointer().
*/
S3JniApi(sqlite3_bind_java_object(),jint,1bind_1java_1object)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jobject val
JniArgsEnvClass, jlong jpStmt, jint ndx, jobject val
){
sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jpStmt);
int rc = 0;
sqlite3_stmt * const pStmt = S3JniLongPtr_sqlite3_stmt(jpStmt);
int rc = SQLITE_MISUSE;
if(pStmt){
jobject const rv = val ? S3JniRefGlobal(val) : 0;
@ -2334,26 +2338,32 @@ S3JniApi(sqlite3_bind_java_object(),jint,1bind_1java_1object)(
S3Jni_jobject_finalizer);
}else if(val){
rc = SQLITE_NOMEM;
}else{
rc = sqlite3_bind_null(pStmt, ndx);
}
}else{
rc = SQLITE_MISUSE;
}
return rc;
}
S3JniApi(sqlite3_bind_null(),jint,1bind_1null)(
JniArgsEnvClass, jobject jpStmt, jint ndx
JniArgsEnvClass, jlong jpStmt, jint ndx
){
return (jint)sqlite3_bind_null(PtrGet_sqlite3_stmt(jpStmt), (int)ndx);
return (jint)sqlite3_bind_null(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx);
}
S3JniApi(sqlite3_bind_parameter_count(),jint,1bind_1parameter_1count)(
JniArgsEnvClass, jlong jpStmt
){
return (jint)sqlite3_bind_parameter_count(S3JniLongPtr_sqlite3_stmt(jpStmt));
}
S3JniApi(sqlite3_bind_parameter_index(),jint,1bind_1parameter_1index)(
JniArgsEnvClass, jobject jpStmt, jbyteArray jName
JniArgsEnvClass, jlong jpStmt, jbyteArray jName
){
int rc = 0;
jbyte * const pBuf = s3jni_jbyteArray_bytes(jName);
if( pBuf ){
rc = sqlite3_bind_parameter_index(PtrGet_sqlite3_stmt(jpStmt),
rc = sqlite3_bind_parameter_index(S3JniLongPtr_sqlite3_stmt(jpStmt),
(const char *)pBuf);
s3jni_jbyteArray_release(jName, pBuf);
}
@ -2361,23 +2371,18 @@ S3JniApi(sqlite3_bind_parameter_index(),jint,1bind_1parameter_1index)(
}
S3JniApi(sqlite3_bind_parameter_name(),jstring,1bind_1parameter_1name)(
JniArgsEnvClass, jobject jpStmt, jint ndx
JniArgsEnvClass, jlong jpStmt, jint ndx
){
jstring rv = 0;
const char *z =
sqlite3_bind_parameter_name(PtrGet_sqlite3_stmt(jpStmt), (int)ndx);
if( z ){
rv = s3jni_utf8_to_jstring(z, -1);
}
return rv;
sqlite3_bind_parameter_name(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx);
return z ? s3jni_utf8_to_jstring(z, -1) : 0;
}
S3JniApi(sqlite3_bind_text(),jint,1bind_1text)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax
JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax
){
jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0;
int const rc = sqlite3_bind_text(PtrGet_sqlite3_stmt(jpStmt), (int)ndx,
int const rc = sqlite3_bind_text(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx,
(const char *)pBuf,
(int)nMax, SQLITE_TRANSIENT);
s3jni_jbyteArray_release(baData, pBuf);
@ -2385,25 +2390,27 @@ S3JniApi(sqlite3_bind_text(),jint,1bind_1text)(
}
S3JniApi(sqlite3_bind_text16(),jint,1bind_1text16)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax
JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax
){
jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0;
int const rc = sqlite3_bind_text16(PtrGet_sqlite3_stmt(jpStmt), (int)ndx,
int const rc = sqlite3_bind_text16(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx,
pBuf, (int)nMax, SQLITE_TRANSIENT);
s3jni_jbyteArray_release(baData, pBuf);
return (jint)rc;
}
S3JniApi(sqlite3_bind_zeroblob(),jint,1bind_1zeroblob)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jint n
JniArgsEnvClass, jlong jpStmt, jint ndx, jint n
){
return (jint)sqlite3_bind_zeroblob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (int)n);
return (jint)sqlite3_bind_zeroblob(S3JniLongPtr_sqlite3_stmt(jpStmt),
(int)ndx, (int)n);
}
S3JniApi(sqlite3_bind_zeroblob(),jint,1bind_1zeroblob64)(
JniArgsEnvClass, jobject jpStmt, jint ndx, jlong n
S3JniApi(sqlite3_bind_zeroblob64(),jint,1bind_1zeroblob64)(
JniArgsEnvClass, jlong jpStmt, jint ndx, jlong n
){
return (jint)sqlite3_bind_zeroblob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_uint64)n);
return (jint)sqlite3_bind_zeroblob64(S3JniLongPtr_sqlite3_stmt(jpStmt),
(int)ndx, (sqlite3_uint64)n);
}
S3JniApi(sqlite3_blob_bytes(),jint,1blob_1bytes)(
@ -3408,7 +3415,7 @@ S3JniApi(sqlite3_finalize(),jint,1finalize)(
JniArgsEnvClass, jlong jpStmt
){
return jpStmt
? sqlite3_finalize(PtrCast_T(sqlite3_stmt,jpStmt))
? sqlite3_finalize(S3JniLongPtr_sqlite3_stmt(jpStmt))
: 0;
}
@ -3649,13 +3656,13 @@ jint sqlite3_jni_prepare_v123( int prepVersion, JNIEnv * const env, jclass self,
goto end;
}
switch( prepVersion ){
case 1: rc = sqlite3_prepare(PtrCast_T(sqlite3,jpDb), (const char *)pBuf,
case 1: rc = sqlite3_prepare(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf,
(int)nMax, &pStmt, &zTail);
break;
case 2: rc = sqlite3_prepare_v2(PtrCast_T(sqlite3,jpDb), (const char *)pBuf,
case 2: rc = sqlite3_prepare_v2(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf,
(int)nMax, &pStmt, &zTail);
break;
case 3: rc = sqlite3_prepare_v3(PtrCast_T(sqlite3,jpDb), (const char *)pBuf,
case 3: rc = sqlite3_prepare_v3(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf,
(int)nMax, (unsigned int)prepFlags,
&pStmt, &zTail);
break;

View File

@ -854,106 +854,106 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1step
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_blob
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I
* Signature: (JI[BI)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1blob
(JNIEnv *, jclass, jobject, jint, jbyteArray, jint);
(JNIEnv *, jclass, jlong, jint, jbyteArray, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_double
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;ID)I
* Signature: (JID)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1double
(JNIEnv *, jclass, jobject, jint, jdouble);
(JNIEnv *, jclass, jlong, jint, jdouble);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_int
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;II)I
* Signature: (JII)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1int
(JNIEnv *, jclass, jobject, jint, jint);
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_int64
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;IJ)I
* Signature: (JIJ)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1int64
(JNIEnv *, jclass, jobject, jint, jlong);
(JNIEnv *, jclass, jlong, jint, jlong);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_java_object
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;ILjava/lang/Object;)I
* Signature: (JILjava/lang/Object;)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1java_1object
(JNIEnv *, jclass, jobject, jint, jobject);
(JNIEnv *, jclass, jlong, jint, jobject);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_null
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1null
(JNIEnv *, jclass, jobject, jint);
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_parameter_count
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1count
(JNIEnv *, jclass, jobject);
(JNIEnv *, jclass, jlong);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_parameter_index
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;[B)I
* Signature: (J[B)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1index
(JNIEnv *, jclass, jobject, jbyteArray);
(JNIEnv *, jclass, jlong, jbyteArray);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_parameter_name
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String;
* Signature: (JI)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1name
(JNIEnv *, jclass, jobject, jint);
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_text
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I
* Signature: (JI[BI)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1text
(JNIEnv *, jclass, jobject, jint, jbyteArray, jint);
(JNIEnv *, jclass, jlong, jint, jbyteArray, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_text16
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I
* Signature: (JI[BI)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1text16
(JNIEnv *, jclass, jobject, jint, jbyteArray, jint);
(JNIEnv *, jclass, jlong, jint, jbyteArray, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_zeroblob
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;II)I
* Signature: (JII)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob
(JNIEnv *, jclass, jobject, jint, jint);
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_bind_zeroblob64
* Signature: (Lorg/sqlite/jni/sqlite3_stmt;IJ)I
* Signature: (JIJ)I
*/
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob64
(JNIEnv *, jclass, jobject, jint, jlong);
(JNIEnv *, jclass, jlong, jint, jlong);
/*
* Class: org_sqlite_jni_SQLite3Jni

View File

@ -207,55 +207,94 @@ public final class SQLite3Jni {
return sqlite3_backup_step(b.getNativePointer(), nPage);
}
@Canonical
private static native int sqlite3_bind_blob(
@NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int n
);
/**
Results are undefined if data is not null and n<0 || n>=data.length.
*/
@Canonical
public static native int sqlite3_bind_blob(
public static int sqlite3_bind_blob(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data, int n
);
){
return sqlite3_bind_blob(stmt.getNativePointer(), ndx, data, n);
}
public static int sqlite3_bind_blob(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data
){
return (null==data)
? sqlite3_bind_null(stmt, ndx)
: sqlite3_bind_blob(stmt, ndx, data, data.length);
? sqlite3_bind_null(stmt.getNativePointer(), ndx)
: sqlite3_bind_blob(stmt.getNativePointer(), ndx, data, data.length);
}
@Canonical
public static native int sqlite3_bind_double(
private static native int sqlite3_bind_double(
@NotNull long ptrToStmt, int ndx, double v
);
@Canonical
public static int sqlite3_bind_double(
@NotNull sqlite3_stmt stmt, int ndx, double v
){
return sqlite3_bind_double(stmt.getNativePointer(), ndx, v);
}
@Canonical
private static native int sqlite3_bind_int(
@NotNull long ptrToStmt, int ndx, int v
);
@Canonical
public static native int sqlite3_bind_int(
public static int sqlite3_bind_int(
@NotNull sqlite3_stmt stmt, int ndx, int v
){
return sqlite3_bind_int(stmt.getNativePointer(), ndx, v);
}
@Canonical
private static native int sqlite3_bind_int64(
@NotNull long ptrToStmt, int ndx, long v
);
@Canonical
public static native int sqlite3_bind_int64(
@NotNull sqlite3_stmt stmt, int ndx, long v
public static int sqlite3_bind_int64(@NotNull sqlite3_stmt stmt, int ndx, long v){
return sqlite3_bind_int64( stmt.getNativePointer(), ndx, v );
}
private static native int sqlite3_bind_java_object(
@NotNull long ptrToStmt, int ndx, @Nullable Object o
);
/**
Binds the given object at the given index.
Binds the given object at the given index. If o is null then this behaves like
sqlite3_bind_null().
@see #sqlite3_result_java_object
*/
public static native int sqlite3_bind_java_object(
@NotNull sqlite3_stmt cx, int ndx, @Nullable Object o
);
public static int sqlite3_bind_java_object(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable Object o
){
return sqlite3_bind_java_object(stmt.getNativePointer(), ndx, o);
}
@Canonical
public static native int sqlite3_bind_null(
@NotNull sqlite3_stmt stmt, int ndx
);
private static native int sqlite3_bind_null(@NotNull long ptrToStmt, int ndx);
@Canonical
public static native int sqlite3_bind_parameter_count(
@NotNull sqlite3_stmt stmt
);
public static int sqlite3_bind_null(@NotNull sqlite3_stmt stmt, int ndx){
return sqlite3_bind_null(stmt.getNativePointer(), ndx);
}
@Canonical
private static native int sqlite3_bind_parameter_count(@NotNull long ptrToStmt);
@Canonical
public static int sqlite3_bind_parameter_count(@NotNull sqlite3_stmt stmt){
return sqlite3_bind_parameter_count(stmt.getNativePointer());
}
/**
Requires that paramName be a NUL-terminated UTF-8 string.
@ -269,7 +308,7 @@ public final class SQLite3Jni {
*/
@Canonical
private static native int sqlite3_bind_parameter_index(
@NotNull sqlite3_stmt stmt, @NotNull byte[] paramName
@NotNull long ptrToStmt, @NotNull byte[] paramName
);
@Canonical
@ -277,12 +316,22 @@ public final class SQLite3Jni {
@NotNull sqlite3_stmt stmt, @NotNull String paramName
){
final byte[] utf8 = (paramName+"\0").getBytes(StandardCharsets.UTF_8);
return sqlite3_bind_parameter_index(stmt, utf8);
return sqlite3_bind_parameter_index(stmt.getNativePointer(), utf8);
}
@Canonical
public static native String sqlite3_bind_parameter_name(
@NotNull sqlite3_stmt stmt, int index
private static native String sqlite3_bind_parameter_name(
@NotNull long ptrToStmt, int index
);
@Canonical
public static String sqlite3_bind_parameter_name(@NotNull sqlite3_stmt stmt, int index){
return sqlite3_bind_parameter_name(stmt.getNativePointer(), index);
}
@Canonical
private static native int sqlite3_bind_text(
@NotNull long ptrToStmt, int ndx, @Nullable byte[] utf8, int maxBytes
);
/**
@ -295,9 +344,11 @@ public final class SQLite3Jni {
undefined if data is not null and does not contain a NUL byte.
*/
@Canonical
public static native int sqlite3_bind_text(
public static int sqlite3_bind_text(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] utf8, int maxBytes
);
){
return sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, maxBytes);
}
/**
Converts data, if not null, to a UTF-8-encoded byte array and
@ -307,9 +358,9 @@ public final class SQLite3Jni {
public static int sqlite3_bind_text(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable String data
){
if(null == data) return sqlite3_bind_null(stmt, ndx);
if( null==data ) return sqlite3_bind_null(stmt.getNativePointer(), ndx);
final byte[] utf8 = data.getBytes(StandardCharsets.UTF_8);
return sqlite3_bind_text(stmt, ndx, utf8, utf8.length);
return sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, utf8.length);
}
/**
@ -319,19 +370,26 @@ public final class SQLite3Jni {
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] utf8
){
return (null == utf8)
? sqlite3_bind_null(stmt, ndx)
: sqlite3_bind_text(stmt, ndx, utf8, utf8.length);
? sqlite3_bind_null(stmt.getNativePointer(), ndx)
: sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, utf8.length);
}
@Canonical
private static native int sqlite3_bind_text16(
@NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int maxBytes
);
/**
Identical to the sqlite3_bind_text() overload with the same
signature but requires that its input be encoded in UTF-16 in
platform byte order.
*/
@Canonical
public static native int sqlite3_bind_text16(
public static int sqlite3_bind_text16(
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data, int maxBytes
);
){
return sqlite3_bind_text16(stmt.getNativePointer(), ndx, data, maxBytes);
}
/**
Converts its string argument to UTF-16 and binds it as such, returning
@ -343,7 +401,7 @@ public final class SQLite3Jni {
){
if(null == data) return sqlite3_bind_null(stmt, ndx);
final byte[] bytes = data.getBytes(StandardCharsets.UTF_16);
return sqlite3_bind_text16(stmt, ndx, bytes, bytes.length);
return sqlite3_bind_text16(stmt.getNativePointer(), ndx, bytes, bytes.length);
}
/**
@ -355,19 +413,27 @@ public final class SQLite3Jni {
@NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data
){
return (null == data)
? sqlite3_bind_null(stmt, ndx)
: sqlite3_bind_text16(stmt, ndx, data, data.length);
? sqlite3_bind_null(stmt.getNativePointer(), ndx)
: sqlite3_bind_text16(stmt.getNativePointer(), ndx, data, data.length);
}
@Canonical
public static native int sqlite3_bind_zeroblob(
@NotNull sqlite3_stmt stmt, int ndx, int n
private static native int sqlite3_bind_zeroblob(@NotNull long ptrToStmt, int ndx, int n);
@Canonical
public static int sqlite3_bind_zeroblob(@NotNull sqlite3_stmt stmt, int ndx, int n){
return sqlite3_bind_zeroblob(stmt.getNativePointer(), ndx, n);
}
@Canonical
private static native int sqlite3_bind_zeroblob64(
@NotNull long ptrToStmt, int ndx, long n
);
@Canonical
public static native int sqlite3_bind_zeroblob64(
@NotNull sqlite3_stmt stmt, int ndx, long n
);
public static int sqlite3_bind_zeroblob64(@NotNull sqlite3_stmt stmt, int ndx, long n){
return sqlite3_bind_zeroblob64(stmt.getNativePointer(), ndx, n);
}
@Canonical
public static native int sqlite3_blob_bytes(@NotNull sqlite3_blob blob);