From e5077c1211eba1a30995fb5fac43353c54cfad43 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 13 Dec 2011 04:08:36 +0000 Subject: [PATCH] When an sqlite3_auto_extension() function fails, report back its actual error code, not the generic SQLITE_ERROR. FossilOrigin-Name: ce55f250f56fa3a1ca864f81e9e86f911b981490 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/loadext.c | 5 +++-- src/main.c | 9 ++++++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 63d5302050..5d96461685 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sthe\smultiplexor\sFileSize\sprocedure\sfails\sto\sopen\sthe\sfile,\sassume\sthat\nthe\sfile\sis\szero\sbytes\sin\ssize. -D 2011-12-13T02:41:13.433 +C When\san\ssqlite3_auto_extension()\sfunction\sfails,\sreport\sback\sits\sactual\nerror\scode,\snot\sthe\sgeneric\sSQLITE_ERROR. +D 2011-12-13T04:08:36.892 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -146,8 +146,8 @@ F src/insert.c 8f283d6734dd837ed7531b26d7622fda70874390 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 -F src/loadext.c d0d2022a5a07274d408820b978b9e549189d314f -F src/main.c f6abb5b6e34cefce99e598a59da7f9282cb95476 +F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d +F src/main.c 8fc06b5ab42330f26d13fbd8f969eead1d214556 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 7456e2ca0524609ebc06a9befeda5289d4575ad4 @@ -976,7 +976,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c2ed86f5945662a4ddcdc7b303df3f64fb3bf17d -R 54dcfa200fabf4bee31d0ce1ef27bb67 +P dc8118cd89da71f2035c6ee07c0edb772bba2186 +R fcee0dd6fa555d5216e315a8c5784053 U drh -Z 12069cbcb91e3fccb976a5eab6a4fcac +Z 9d7ca46858b8a86804ab1862673e090c diff --git a/manifest.uuid b/manifest.uuid index 216e947580..1c74b293b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc8118cd89da71f2035c6ee07c0edb772bba2186 \ No newline at end of file +ce55f250f56fa3a1ca864f81e9e86f911b981490 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index e9c97adff3..3fcf5008cf 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -625,6 +625,7 @@ void sqlite3_reset_auto_extension(void){ void sqlite3AutoLoadExtensions(sqlite3 *db){ int i; int go = 1; + int rc; int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); wsdAutoextInit; @@ -647,8 +648,8 @@ void sqlite3AutoLoadExtensions(sqlite3 *db){ } sqlite3_mutex_leave(mutex); zErrmsg = 0; - if( xInit && xInit(db, &zErrmsg, &sqlite3Apis) ){ - sqlite3Error(db, SQLITE_ERROR, + if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){ + sqlite3Error(db, rc, "automatic extension loading failed: %s", zErrmsg); go = 0; } diff --git a/src/main.c b/src/main.c index 95f2e96872..229af8607c 100644 --- a/src/main.c +++ b/src/main.c @@ -2250,10 +2250,13 @@ static int openDatabase( /* Load automatic extensions - extensions that have been registered ** using the sqlite3_automatic_extension() API. */ - sqlite3AutoLoadExtensions(db); rc = sqlite3_errcode(db); - if( rc!=SQLITE_OK ){ - goto opendb_out; + if( rc==SQLITE_OK ){ + sqlite3AutoLoadExtensions(db); + rc = sqlite3_errcode(db); + if( rc!=SQLITE_OK ){ + goto opendb_out; + } } #ifdef SQLITE_ENABLE_FTS1