mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Improve internal error handling in the JNI create_function() impl.
FossilOrigin-Name: 2c88390faa108a60c8fb1eb7aad05d90f3daf4cfef14ca73987597aaf7be83c9
This commit is contained in:
@ -1797,14 +1797,12 @@ static jint create_function(JNIEnv * env, jobject jDb, jstring jFuncName,
|
||||
s = UDFState_alloc(env, jFunctor);
|
||||
if( !s ) return SQLITE_NOMEM;
|
||||
else if( UDF_UNKNOWN_TYPE==s->type ){
|
||||
UDFState_free(s);
|
||||
rc = s3jni_db_error(pDb, SQLITE_MISUSE,
|
||||
"Cannot unambiguously determine function type.");
|
||||
"Cannot unambiguously determine function type.");
|
||||
goto error_cleanup;
|
||||
}
|
||||
zFuncName = JSTR_TOC(jFuncName);
|
||||
if(!zFuncName){
|
||||
UDFState_free(s);
|
||||
rc = SQLITE_NOMEM;
|
||||
goto error_cleanup;
|
||||
}
|
||||
@ -1824,12 +1822,15 @@ static jint create_function(JNIEnv * env, jobject jDb, jstring jFuncName,
|
||||
xFinal = udf_xFinal;
|
||||
}
|
||||
rc = sqlite3_create_function_v2(pDb, zFuncName, nArg, eTextRep, s,
|
||||
xFunc, xStep, xFinal,
|
||||
UDFState_finalizer);
|
||||
xFunc, xStep, xFinal, UDFState_finalizer);
|
||||
}
|
||||
s->zFuncName = sqlite3_mprintf("%s", zFuncName);
|
||||
if(!s->zFuncName){
|
||||
rc = SQLITE_NOMEM;
|
||||
if( 0==rc ){
|
||||
s->zFuncName = sqlite3_mprintf("%s", zFuncName);
|
||||
if( !s->zFuncName ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
if( 0!=rc ){
|
||||
UDFState_free(s);
|
||||
}
|
||||
error_cleanup:
|
||||
|
@ -288,6 +288,11 @@ public final class SQLite3Jni {
|
||||
int eTextRep,
|
||||
@NotNull Collation col);
|
||||
|
||||
//Potential TODO, if we can sensibly map the lower-level bits to Java:
|
||||
//public static native int sqlite3_create_fts5_function(@NotNull sqlite3 db,
|
||||
// @NotNull String functionName,
|
||||
// @NotNull Fts5Function func);
|
||||
|
||||
/**
|
||||
The Java counterpart to the C-native sqlite3_create_function(),
|
||||
sqlite3_create_function_v2(), and
|
||||
|
Reference in New Issue
Block a user