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

Merge pull request #94 from d-lamb/patch-1

Clarify which method to use when loading extension
This commit is contained in:
Kenichi Ishigaki 2021-12-15 06:49:28 +09:00 committed by GitHub
commit f278c800b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2297,12 +2297,16 @@ Calling this method with a true value enables loading (external)
SQLite3 extensions. After the call, you can load extensions like this: SQLite3 extensions. After the call, you can load extensions like this:
$dbh->sqlite_enable_load_extension(1); $dbh->sqlite_enable_load_extension(1);
$sth = $dbh->prepare("select load_extension('libsqlitefunctions.so')") $sth = $dbh->prepare("select load_extension('libmemvfs.so')")
or die "Cannot prepare: " . $dbh->errstr(); or die "Cannot prepare: " . $dbh->errstr();
=head2 $dbh->sqlite_load_extension( $file, $proc ) =head2 $dbh->sqlite_load_extension( $file, $proc )
Loading an extension by a select statement (with the "load_extension" SQLite3 function like above) has some limitations. If you need to, say, create other functions from an extension, use this method. $file (a path to the extension) is mandatory, and $proc (an entry point name) is optional. You need to call C<sqlite_enable_load_extension> before calling C<sqlite_load_extension>. Loading an extension by a select statement (with the "load_extension" SQLite3 function like above) has some limitations. If the extension you want to use creates other functions that are not native to SQLite, use this method instead. $file (a path to the extension) is mandatory, and $proc (an entry point name) is optional. You need to call C<sqlite_enable_load_extension> before calling C<sqlite_load_extension>:
$dbh->sqlite_enable_load_extension(1);
$dbh->sqlite_load_extension('libsqlitefunctions.so')
or die "Cannot load extension: " . $dbh->errstr();
If the extension uses SQLite mutex functions like C<sqlite3_mutex_enter>, then If the extension uses SQLite mutex functions like C<sqlite3_mutex_enter>, then
the extension should be compiled with the same C<SQLITE_THREADSAFE> compile-time the extension should be compiled with the same C<SQLITE_THREADSAFE> compile-time