1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

Let create_function unregister an existing function

This commit is contained in:
Kenichi Ishigaki 2021-12-02 01:32:01 +09:00
parent 7848525aeb
commit 8bf916dbd7
2 changed files with 9 additions and 3 deletions

View file

@ -1859,14 +1859,16 @@ sqlite_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func, i
}
/* Copy the function reference */
if (SvOK(func)) {
func_sv = newSVsv(func);
av_push( imp_dbh->functions, func_sv );
}
croak_if_db_is_null();
/* warn("create_function %s with %d args\n", name, argc); */
rc = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8|flags,
func_sv,
SvOK(func) ? func_sv : NULL,
_FUNC_DISPATCHER[imp_dbh->string_mode],
NULL, NULL );
if ( rc != SQLITE_OK ) {

View file

@ -150,6 +150,10 @@ foreach my $call_func (@CALL_FUNCS) { for my $flags (@function_flags) {
$result = $dbh->selectrow_arrayref( "SELECT typeof(md5_blob('my_blob'))" );
is_deeply( $result, [ 'blob' ], "SELECT typeof(md5_blob('my_blob'))" );
ok($dbh->$call_func( "md5_blob", 1, undef, defined $flags ? $flags : (), "create_function" ));
$result = $dbh->selectrow_arrayref( "SELECT md5_blob('my_blob')" );
is_deeply( $result, undef, "SELECT md5_blob('my_blob')" );
$dbh->disconnect;
}}