it seems that some unexpected regression is affecting load_extension()
on Linux when using the most recent versions of SQLite (3.22 and 3.23).

my test configuration:
- sqlite3 installed on the current directory
- extension module installed on /usr/local/lib
  (/usr/local/lib/mod_spatialite.so)

$ export "LD_LIBRARY_PATH=/usr/local/lib"
$ ./sqlite3
sqlite> SELECT load_extension('mod_spatialite');

- the extension module is successfully loaded when using 3.20.1
- but it fails when using 3.22.0 or 3.23.1

digging into the code I was finally able to reestablish the expected
behavior of load_extension() after applying the following patch:

sqlite3.c (v.3.23.1) - line 115917 - sqlite3LoadExtension()
-----------------------------------------------------------
handle = sqlite3OsDlOpen(pVfs, zFile);
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
    char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
    int bExists = 0;
    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
/*
    sqlite3OsAccess(pVfs, zAltFile, SQLITE_ACCESS_EXISTS, &bExists);
    if( bExists )
*/
    handle = sqlite3OsDlOpen(pVfs, zAltFile);
    sqlite3_free(zAltFile);
  }
#endif
-----------------------------------------------------------

it seems that sqlite3OsAccess() fails to correctly locate the
module to be loaded because it checks just the current working
directory whilst sqlite3OsDlOpen() correctly searches more
directories, as the additional ones defined by LD_LIBRARY_PATH.

bye
Sandro Furieri (developer and maintainer of SpatiaLite)
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to