From 98cab2c0389f500e976148912316c042847a4a0e Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Sat, 1 Sep 2007 05:57:49 +0000 Subject: [PATCH] Call sqlite3OsDlError to obtain error information after DlOpen or DlSym fail. (CVS 4358) FossilOrigin-Name: 3d74256c9123e8434c68e6a0c5b61686b34a4328 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/loadext.c | 17 +++++++++++++---- test/loadext.test | 34 ++++++++++++++++++++++------------ test/sqllimits1.test | 9 +++++++-- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index cac117d23f..1c991da801 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\swindows\stempfile\sname\sgenerator\sso\sthat\sit\suses\s119\sbits\nof\srandomness\sand\sdoes\snot\sbother\sto\scheck\sto\ssee\sif\sthe\sfile\salready\nexists.\s\sTicket\s#2608.\s\s(Unable\sto\stest\sfrom\sthis\smachine,\sbut\sthe\nchanges\sare\ssimple\sand\sisolated.\s\sHope\sit\sworks.)\s(CVS\s4357) -D 2007-09-01T02:13:11 +C Call\ssqlite3OsDlError\sto\sobtain\serror\sinformation\safter\sDlOpen\sor\sDlSym\sfail.\s(CVS\s4358) +D 2007-09-01T05:57:50 F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -98,7 +98,7 @@ F src/insert.c b11e5ca0d68bf2a7a56f47a052a0ee67dd4e2f89 F src/journal.c 2e0fb96d5e407a28b756b4a8b3694f2dccabe7f8 F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35 -F src/loadext.c d8a41422b7c2a79d4cf89a62da404d6b786704cf +F src/loadext.c 6894dbbf1666577d957922811620375d6c2f058d F src/main.c 00a894cd348d8d3651097bb8136f03e53afa644b F src/malloc.c de4e77fe70a9a0ac47a1c3a874422b107231bf31 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 @@ -338,7 +338,7 @@ F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51 F test/laststmtchanges.test 18ead86c8a87ade949a1d5658f6dc4bb111d1b02 F test/like.test 9b8eb634d2c34b36b365c1baae115c9bd6e56674 F test/limit.test 2a87b9cb2165abb49ca0ddcf5cb43cf24074581f -F test/loadext.test 9ab2cb0226329c1a62dd45d204be95158a872201 +F test/loadext.test ea04ac20e20e3f42514f55487ef9a9d6fda51bd1 F test/loadext2.test 95ca7e2cb03fd3e068de97c3a2fe58dbdfd769e1 F test/lock.test 6825aea0b5885578b1b63a3b178803842c4ee9f1 F test/lock2.test 5f9557b775662c2a5ee435378f39e10d64f65cb3 @@ -411,7 +411,7 @@ F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded F test/speed3.test 55e039b34d505aa442cee415f83c451ae28b3123 -F test/sqllimits1.test cd2069518d1a1d7b5406b8f26fc8436aa87268e8 +F test/sqllimits1.test 6974f124d9333510bb2c3e796012b5ec48844db3 F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797 F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4 F test/substr.test 9f26cfca74397b26ab217fb838c3d0549eb4bcf3 @@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 8f73ebc6e30467d2c594701e0aa45b53147ef2ef -R 47873120abe0056067c2bbb673058814 -U drh -Z 9ba63200ed790f0c99661e3e7809f71e +P ca6c1e3f44d8b9d9b76a0efe53ea6a6ad5e14d57 +R bc8176723b1b67ea3809dd5ad6b3d1c7 +U danielk1977 +Z 3bc8cc7848a229a5523b979148fa9e5d diff --git a/manifest.uuid b/manifest.uuid index 950be95903..6e2e9837f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca6c1e3f44d8b9d9b76a0efe53ea6a6ad5e14d57 \ No newline at end of file +3d74256c9123e8434c68e6a0c5b61686b34a4328 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 2ae3aabe89..191c2ddf75 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -327,7 +327,12 @@ static int sqlite3LoadExtension( handle = sqlite3OsDlOpen(pVfs, zFile); if( handle==0 ){ if( pzErrMsg ){ - *pzErrMsg = sqlite3_mprintf("unable to open shared library [%s]", zFile); + char zErr[256]; + zErr[sizeof(zErr)-1] = '\0'; + sqlite3_snprintf(sizeof(zErr)-1, zErr, + "unable to open shared library [%s]", zFile); + sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr); + *pzErrMsg = sqlite3DbStrDup(db, zErr); } return SQLITE_ERROR; } @@ -335,10 +340,14 @@ static int sqlite3LoadExtension( sqlite3OsDlSym(pVfs, handle, zProc); if( xInit==0 ){ if( pzErrMsg ){ - *pzErrMsg = sqlite3_mprintf("no entry point [%s] in shared library [%s]", - zProc, zFile); + char zErr[256]; + zErr[sizeof(zErr)-1] = '\0'; + sqlite3_snprintf(sizeof(zErr)-1, zErr, + "no entry point [%s] in shared library [%s]", zProc,zFile); + sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr); + *pzErrMsg = sqlite3DbStrDup(db, zErr); + sqlite3OsDlClose(pVfs, handle); } - sqlite3OsDlClose(pVfs, handle); return SQLITE_ERROR; }else if( xInit(db, &zErrmsg, &sqlite3_apis) ){ if( pzErrMsg ){ diff --git a/test/loadext.test b/test/loadext.test index 7a646f2c26..2b90cc03ff 100644 --- a/test/loadext.test +++ b/test/loadext.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is extension loading. # -# $Id: loadext.test,v 1.9 2007/04/06 21:42:22 drh Exp $ +# $Id: loadext.test,v 1.10 2007/09/01 05:57:50 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -29,6 +29,23 @@ if {$::tcl_platform(platform) eq "windows"} { set testextension ./libtestloadext.so } +# The error messages tested by this file are operating system dependent +# (because they are returned by sqlite3OsDlError()). For now, they only +# work with UNIX (and probably only certain kinds of UNIX). +# +# When a shared-object cannot be opened, we expect the error message to +# be: +# +# [format $dlerror_cantopen ] +# +# When a symbol cannot be found within an open shared-object, the error +# message should be: +# +# [format $dlerror_nosymbol ] +# +set dlerror_cantopen {%s: file too short} +set dlerror_nosymbol {%s: undefined symbol: %s} + # Make sure the test extension actually exists. If it does not # exist, try to create it. If unable to create it, then skip this # test file. @@ -99,9 +116,7 @@ do_test loadext-2.1 { sqlite3_load_extension db "${testextension}xx" } msg] list $rc $msg -} [list 1 [subst -nocommands \ - {unable to open shared library [${testextension}xx]} -]] +} [list 1 [format $dlerror_cantopen ${testextension}xx]] # Try to load an extension for which the file is not a shared object # @@ -113,9 +128,7 @@ do_test loadext-2.2 { sqlite3_load_extension db "${testextension}xx" } msg] list $rc $msg -} [list 1 [subst -nocommands \ - {unable to open shared library [${testextension}xx]} -]] +} [list 1 [format $dlerror_cantopen ${testextension}xx]] # Try to load an extension for which the file is present but the # entry point is not. @@ -125,9 +138,7 @@ do_test loadext-2.3 { sqlite3_load_extension db $testextension icecream } msg] list $rc $msg -} [list 1 [subst -nocommands \ - {no entry point [icecream] in shared library [$testextension]} -]] +} [list 1 [format $dlerror_nosymbol $testextension icecream]] # Try to load an extension for which the entry point fails (returns non-zero) # @@ -154,8 +165,7 @@ do_test loadext-3.2 { catchsql { SELECT load_extension($::testextension) } -} [list 1 "no entry point \[sqlite3_extension_init\]\ - in shared library \[$testextension\]"] +} [list 1 [format $dlerror_nosymbol $testextension sqlite3_extension_init]] do_test loadext-3.3 { catchsql { SELECT load_extension($::testextension,'testloadext_init') diff --git a/test/sqllimits1.test b/test/sqllimits1.test index 1ce97ab38e..1572a038dc 100644 --- a/test/sqllimits1.test +++ b/test/sqllimits1.test @@ -12,7 +12,7 @@ # This file contains tests to verify that the limits defined in # sqlite source file limits.h are enforced. # -# $Id: sqllimits1.test,v 1.11 2007/08/31 17:42:48 danielk1977 Exp $ +# $Id: sqllimits1.test,v 1.12 2007/09/01 05:57:50 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -38,7 +38,7 @@ source $testdir/tester.tcl # sqllimits-12.*: SQLITE_MAX_PAGE_COUNT (sqlite todo) # -set SQLITE_MAX_LENGTH 1000000 +set SQLITE_MAX_LENGTH 100000 set SQLITE_MAX_COLUMN set SQLITE_MAX_SQL_LENGTH 100000 set SQLITE_MAX_EXPR_DEPTH 1000 @@ -91,6 +91,11 @@ do_test sqllimits-1.9 { catchsql { SELECT replace($::str, 'A', $::rep) } } {1 {string or blob too big}} +do_test sqllimits-1.10 { + set ::str [string repeat %J 2100] + catchsql { SELECT strftime($::str, '2003-10-31') } +} {1 {string or blob too big}} + #-------------------------------------------------------------------- # Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit # is enforced. -- 2.47.3