/ Check-in [e47cd314]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Define the sqlite3ErrName() function only when necessary. More robust handling of unknown return codes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winOsTrace
Files: files | file ages | folders
SHA1: e47cd314371c2be6e00d96392b3892a7f3015f98
User & Date: mistachkin 2013-04-30 07:54:42
Context
2013-04-30
07:58
Add the #ifdefs for sqlite3ErrName() to sqliteInt.h as well. Closed-Leaf check-in: 400fc4c3 user: mistachkin tags: winOsTrace
07:54
Define the sqlite3ErrName() function only when necessary. More robust handling of unknown return codes. check-in: e47cd314 user: mistachkin tags: winOsTrace
2013-04-29
09:20
Merge mmap test fix from trunk. check-in: 95811877 user: mistachkin tags: winOsTrace
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  1029   1029     }
  1030   1030   }
  1031   1031   
  1032   1032   /*
  1033   1033   ** Return a static string containing the name corresponding to the error code
  1034   1034   ** specified in the argument.
  1035   1035   */
         1036  +#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) || \
         1037  +    defined(SQLITE_DEBUG_OS_TRACE)
  1036   1038   const char *sqlite3ErrName(int rc){
  1037   1039     const char *zName = 0;
  1038         -  int i;
         1040  +  int i, origRc = rc;
  1039   1041     for(i=0; i<2 && zName==0; i++, rc &= 0xff){
  1040   1042       switch( rc ){
  1041   1043         case SQLITE_OK:                 zName = "SQLITE_OK";                break;
  1042   1044         case SQLITE_ERROR:              zName = "SQLITE_ERROR";             break;
  1043   1045         case SQLITE_INTERNAL:           zName = "SQLITE_INTERNAL";          break;
  1044   1046         case SQLITE_PERM:               zName = "SQLITE_PERM";              break;
  1045   1047         case SQLITE_ABORT:              zName = "SQLITE_ABORT";             break;
................................................................................
  1118   1120         case SQLITE_NOTICE_RECOVER_WAL: zName = "SQLITE_NOTICE_RECOVER_WAL";break;
  1119   1121         case SQLITE_NOTICE_RECOVER_ROLLBACK:
  1120   1122                                   zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break;
  1121   1123         case SQLITE_WARNING:            zName = "SQLITE_WARNING";           break;
  1122   1124         case SQLITE_DONE:               zName = "SQLITE_DONE";              break;
  1123   1125       }
  1124   1126     }
  1125         -  if( zName==0 ) zName = "SQLITE_Unknown";
         1127  +  if( zName==0 ){
         1128  +    static char zBuf[50];
         1129  +    sqlite3_snprintf(sizeof(zBuf), zBuf, "SQLITE_UNKNOWN(%d)", origRc);
         1130  +    zName = zBuf;
         1131  +  }
  1126   1132     return zName;
  1127   1133   }
         1134  +#endif
  1128   1135   
  1129   1136   /*
  1130   1137   ** Return a static string that describes the kind of error specified in the
  1131   1138   ** argument.
  1132   1139   */
  1133   1140   const char *sqlite3ErrStr(int rc){
  1134   1141     static const char* const aMsg[] = {