From: mistachkin Date: Tue, 11 Sep 2012 02:00:25 +0000 (+0000) Subject: Added sqlite3_errstr API to translate a result code to the corresponding error message. X-Git-Tag: version-3.7.15~146 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5dac84323351d847aa818d87a345309bc3e84b68;p=thirdparty%2Fsqlite.git Added sqlite3_errstr API to translate a result code to the corresponding error message. FossilOrigin-Name: bf8a9ca5b58404112a8af666f5840b462b7bbfe1 --- diff --git a/manifest b/manifest index 42bc0d99d9..a88fd0f6b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\stwo\sduplicated\stest\snames. -D 2012-09-10T23:44:12.573 +C Added\ssqlite3_errstr\sAPI\sto\stranslate\sa\sresult\scode\sto\sthe\scorresponding\serror\smessage. +D 2012-09-11T02:00:25.116 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 02255cf1da50956c5427c469abddb15bccc4ba09 +F src/main.c 259472ec0c694fe6a4fb6e8781be7fd8feacb09c F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -178,14 +178,14 @@ F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c f843c872a97baa1594c2cc3d4c003409a7bd03af F src/shell.c 87953c5d9c73d9494db97d1607e2e2280418f261 -F src/sqlite.h.in 39ddd714b62c651bfb5646440c594ca7ff6c7453 +F src/sqlite.h.in 193c0496be6046604d1b8aa518012d3cf411f57f F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 053e03a532beb909ead2df0721db67cdb4c48ae8 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e -F src/tclsqlite.c f6bc566b5a52128759d6eb954b53930a6353ed58 +F src/tclsqlite.c e4de2458b3ef38fdd0498bc4e5ea5367a241b0f3 F src/test1.c 3d70f7c5987f186884cfebbfa7151a7d3d67d86e F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d @@ -1014,7 +1014,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P c2ad691174b8af2e8b158d8840cfc93f75d7db71 -R 01a5d1c903c9a5a720ae8b76fe55d59d +P ced49974a969f11e5ebe2280bd7eec20b059e501 +R 96b0793061802196b5e5b329338c3e20 U mistachkin -Z 8f15859569cbba9d92e0949a6ba62979 +Z 09221de0840bfda8cdeb1fd3b6a60ff7 diff --git a/manifest.uuid b/manifest.uuid index 0542b3d17d..6f8cf23f11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ced49974a969f11e5ebe2280bd7eec20b059e501 \ No newline at end of file +bf8a9ca5b58404112a8af666f5840b462b7bbfe1 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 16294a6199..cc19f78a81 100644 --- a/src/main.c +++ b/src/main.c @@ -1767,6 +1767,15 @@ int sqlite3_extended_errcode(sqlite3 *db){ return db->errCode; } +/* +** Return a string that describes the kind of error specified in the +** argument. For now, this simply calls the internal sqlite3ErrStr() +** function. +*/ +const char *sqlite3_errstr(int rc){ + return sqlite3ErrStr(rc); +} + /* ** Create a new collating function for database "db". The name is zName ** and the encoding is enc. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e66dcc72b3..3729ae6dcb 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2747,6 +2747,11 @@ sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ ** +** ^The sqlite3_errstr() interface returns the English-language text +** that describes the [result code], as UTF-8. +** ^(Memory to hold the error message string is managed internally +** and must not be freed by the application)^. +** ** When the serialized [threading mode] is in use, it might be the ** case that a second error occurs on a separate thread in between ** the time of the first error and the call to these interfaces. @@ -2765,6 +2770,7 @@ int sqlite3_errcode(sqlite3 *db); int sqlite3_extended_errcode(sqlite3 *db); const char *sqlite3_errmsg(sqlite3*); const void *sqlite3_errmsg16(sqlite3*); +const char *sqlite3_errstr(int); /* ** CAPI3REF: SQL Statement Object diff --git a/src/tclsqlite.c b/src/tclsqlite.c index abec51e67a..0a586e489f 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -41,14 +41,6 @@ #endif #include -/* -** This function is used to translate a return code into an error -** message. -*/ -#ifndef USE_SYSTEM_SQLITE -const char *sqlite3ErrStr(int rc); -#endif - /* * Windows needs to know which symbols to export. Unix does not. * BUILD_sqlite should be undefined for Unix. @@ -2566,7 +2558,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey); rc = sqlite3_rekey(pDb->db, pKey, nKey); if( rc ){ - Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0); + Tcl_AppendResult(interp, sqlite3_errstr(rc), 0); rc = TCL_ERROR; } #endif @@ -3044,19 +3036,15 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename); rc = sqlite3_open_v2(zFile, &p->db, flags, zVfs); Tcl_DStringFree(&translatedFilename); -#ifndef USE_SYSTEM_SQLITE if( p->db ){ -#endif if( SQLITE_OK!=sqlite3_errcode(p->db) ){ zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(p->db)); sqlite3_close(p->db); p->db = 0; } -#ifndef USE_SYSTEM_SQLITE }else{ - zErrMsg = sqlite3_mprintf("%s", sqlite3ErrStr(rc)); + zErrMsg = sqlite3_mprintf("%s", sqlite3_errstr(rc)); } -#endif #ifdef SQLITE_HAS_CODEC if( p->db ){ sqlite3_key(p->db, pKey, nKey);