]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the sqlite3_load_extension() so that when the entry point is
authordrh <>
Thu, 18 Dec 2025 14:01:43 +0000 (14:01 +0000)
committerdrh <>
Thu, 18 Dec 2025 14:01:43 +0000 (14:01 +0000)
not specified, after trying sqlite3_extension_init() and
sqlite3_X_init() where X is the alphabetic part of the base filename,
if neither or found it tries again with X as the alpha*numeric* part
of the base filename.  Hence, a shared library named "vt02.so" can be
loaded with just ".load vt02" and without having to specify the entry
point separately.

FossilOrigin-Name: acc95f24cc034408de1e9225aef4dae8bf76beec812c152bea32db95f7d2b854

manifest
manifest.uuid
src/loadext.c
src/sqlite.h.in

index 07625c36924b2a296afd724c0e618efdc109b4d2..07dd2b2bbb40f52a6285baa96c6b9e11cdb89dec 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\sthe\svt02.c\stest\svirtual\stable\swith\sthe\sability\sto\sprocess\nORDER\sBY\sDESC.
-D 2025-12-18T12:49:44.221
+C Enhance\sthe\ssqlite3_load_extension()\sso\sthat\swhen\sthe\sentry\spoint\sis\nnot\sspecified,\safter\strying\ssqlite3_extension_init()\sand\nsqlite3_X_init()\swhere\sX\sis\sthe\salphabetic\spart\sof\sthe\sbase\sfilename,\nif\sneither\sor\sfound\sit\stries\sagain\swith\sX\sas\sthe\salpha*numeric*\spart\nof\sthe\sbase\sfilename.\s\sHence,\sa\sshared\slibrary\snamed\s"vt02.so"\scan\sbe\nloaded\swith\sjust\s".load\svt02"\sand\swithout\shaving\sto\sspecify\sthe\sentry\npoint\sseparately.
+D 2025-12-18T14:01:43.153
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -699,7 +699,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
 F src/insert.c dfd311b0ac2d4f6359e62013db67799757f4d2cc56cca5c10f4888acfbbfa3fd
 F src/json.c fb031340edee159c07ad37dbe668ffe945ed86f525b0eb3822e4a67cbc498a72
 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
-F src/loadext.c 4747f72084dc80520a2d23e5bb0bc0760672208a81a2b115ce0b657acd65edf4
+F src/loadext.c c72b7e01702be21ea1acb68bc23a604f4235f97e13ccda3efa251aa323e35a98
 F src/main.c 21fb86045bbf6b6329251a0ce6771735b6c71287cc9fcda1f2005d4ac5f25b52
 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
@@ -738,7 +738,7 @@ F src/resolve.c 47aa7fdc9ec4c19b103ac5e79d7887d30119b5675309facf5eed1118391c868b
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c 344518c1bba9c4636bf651b7642304abd2e7075ba35feb4bae42a51e5efe991f
 F src/shell.c.in c4b775c664c339ac0351549a998b5f8816bf2496af5385e3937050c1fb5688fe
-F src/sqlite.h.in 706cacea5308b0244fb6cec92e08310fb427a125375c64137cc1f878ae4cf5c0
+F src/sqlite.h.in b7d0e99d1384e73882f3157d86e0cd886d0c510d8db2b288b1d17631d6f26089
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 5d5330f5f8461f5ce74960436ddcfa53ecd09c2b8b23901e22ae38aec3243998
 F src/sqliteInt.h af67bc95fa6b66cd3c7f3d18d2d040ad386e4cbb02965ee318cc721ee9d5fa45
@@ -2187,8 +2187,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d017ae8640f24543ad5bf37a3e514c1e919730b8c686255c61890448ba22b3e1
-R faaecd2038048c73b75d6f197dafc3f9
+P 35461a8d5a103e373e5b38b3974a3bb1074e914e862825108713b36bef04b6bd
+R 03be37b2ca34a6c5aca4479a28799054
 U drh
-Z 1008e4c9d6dee7b8022617033f94919d
+Z 612207cbf12a182bbf761ed84fdbf21d
 # Remove this line to create a well-formed Fossil manifest.
index 806c5eb9bbe593827f05e5495a65d7e47e712664..b6fc4f94d650ab245ab1f432bcd0a18bfcbc1386 100644 (file)
@@ -1 +1 @@
-35461a8d5a103e373e5b38b3974a3bb1074e914e862825108713b36bef04b6bd
+acc95f24cc034408de1e9225aef4dae8bf76beec812c152bea32db95f7d2b854
index d8bf4726ce21ea3f3a82b7b8eeb915617f66af82..835627a66a5b71b9b82ae8e9226dfc103df1d196 100644 (file)
@@ -627,33 +627,42 @@ static int sqlite3LoadExtension(
   ** entry point name "sqlite3_extension_init" was not found, then
   ** construct an entry point name "sqlite3_X_init" where the X is
   ** replaced by the lowercase value of every ASCII alphabetic 
-  ** character in the filename after the last "/" upto the first ".",
-  ** and eliding the first three characters if they are "lib".  
+  ** character in the filename after the last "/" up to the first ".",
+  ** and skipping the first three characters if they are "lib".  
   ** Examples:
   **
   **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init
   **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init
+  **
+  ** If that still finds no entry point, repeat a second time but this
+  ** time include both alphabetic and numeric characters up to the first
+  ** ".".  Example:
+  **
+  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example5_init
   */
   if( xInit==0 && zProc==0 ){
     int iFile, iEntry, c;
     int ncFile = sqlite3Strlen30(zFile);
+    int cnt = 0;
     zAltEntry = sqlite3_malloc64(ncFile+30);
     if( zAltEntry==0 ){
       sqlite3OsDlClose(pVfs, handle);
       return SQLITE_NOMEM_BKPT;
     }
-    memcpy(zAltEntry, "sqlite3_", 8);
-    for(iFile=ncFile-1; iFile>=0 && !DirSep(zFile[iFile]); iFile--){}
-    iFile++;
-    if( sqlite3_strnicmp(zFile+iFile, "lib", 3)==0 ) iFile += 3;
-    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){
-      if( sqlite3Isalpha(c) ){
-        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
+    do{
+      memcpy(zAltEntry, "sqlite3_", 8);
+      for(iFile=ncFile-1; iFile>=0 && !DirSep(zFile[iFile]); iFile--){}
+      iFile++;
+      if( sqlite3_strnicmp(zFile+iFile, "lib", 3)==0 ) iFile += 3;
+      for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){
+        if( sqlite3Isalpha(c) || (cnt && sqlite3Isdigit(c)) ){
+          zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
+        }
       }
-    }
-    memcpy(zAltEntry+iEntry, "_init", 6);
-    zEntry = zAltEntry;
-    xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
+      memcpy(zAltEntry+iEntry, "_init", 6);
+      zEntry = zAltEntry;
+      xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
+    }while( xInit==0 && (++cnt)<2 );
   }
   if( xInit==0 ){
     if( pzErrMsg ){
index 017520c370056f187cb863f3cac6e4e68019e8bd..8d50c206068b9c82fda307b75dd46ad2c1a5bbf0 100644 (file)
@@ -7427,7 +7427,7 @@ int sqlite3_table_column_metadata(
 ** ^The sqlite3_load_extension() interface attempts to load an
 ** [SQLite extension] library contained in the file zFile.  If
 ** the file cannot be loaded directly, attempts are made to load
-** with various operating-system specific extensions added.
+** with various operating-system specific filename extensions added.
 ** So for example, if "samplelib" cannot be loaded, then names like
 ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
 ** be tried also.
@@ -7435,10 +7435,10 @@ int sqlite3_table_column_metadata(
 ** ^The entry point is zProc.
 ** ^(zProc may be 0, in which case SQLite will try to come up with an
 ** entry point name on its own.  It first tries "sqlite3_extension_init".
-** If that does not work, it constructs a name "sqlite3_X_init" where
-** X consists of the lower-case equivalent of all ASCII alphabetic
-** characters in the filename from the last "/" to the first following
-** "." and omitting any initial "lib".)^
+** If that does not work, it tries names of the form "sqlite3_X_init"
+** where X consists of the lower-case equivalent of all ASCII alphabetic
+** characters or all ASCII alphanumeric characters in the filename from
+** the last "/" to the first following "." and omitting any initial "lib".)^
 ** ^The sqlite3_load_extension() interface returns
 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
 ** ^If an error occurs and pzErrMsg is not 0, then the