1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Define the sqlite3ErrName() function only when necessary. More robust handling of unknown return codes.

FossilOrigin-Name: e47cd314371c2be6e00d96392b3892a7f3015f98
This commit is contained in:
mistachkin
2013-04-30 07:54:42 +00:00
parent a3514f1027
commit 10269dc676
3 changed files with 16 additions and 9 deletions

View File

@@ -1033,9 +1033,11 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){
** Return a static string containing the name corresponding to the error code
** specified in the argument.
*/
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) || \
defined(SQLITE_DEBUG_OS_TRACE)
const char *sqlite3ErrName(int rc){
const char *zName = 0;
int i;
int i, origRc = rc;
for(i=0; i<2 && zName==0; i++, rc &= 0xff){
switch( rc ){
case SQLITE_OK: zName = "SQLITE_OK"; break;
@@ -1122,9 +1124,14 @@ const char *sqlite3ErrName(int rc){
case SQLITE_DONE: zName = "SQLITE_DONE"; break;
}
}
if( zName==0 ) zName = "SQLITE_Unknown";
if( zName==0 ){
static char zBuf[50];
sqlite3_snprintf(sizeof(zBuf), zBuf, "SQLITE_UNKNOWN(%d)", origRc);
zName = zBuf;
}
return zName;
}
#endif
/*
** Return a static string that describes the kind of error specified in the