/ Check-in [05ba5e23]
Login

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

Overview
Comment:More refinements to Windows OSTRACE usage. Replace all usage of sqlite3TestErrorName() with sqlite3ErrName() and add missing return codes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winOsTrace
Files: files | file ages | folders
SHA1: 05ba5e23fcc5da416d47a8ad5e667ed6a0c7a34a
User & Date: mistachkin 2013-04-29 03:09:10
Context
2013-04-29
08:56
Merge updates from trunk. check-in: 3a245a83 user: mistachkin tags: winOsTrace
03:09
More refinements to Windows OSTRACE usage. Replace all usage of sqlite3TestErrorName() with sqlite3ErrName() and add missing return codes. check-in: 05ba5e23 user: mistachkin tags: winOsTrace
2013-04-28
01:44
Initial work on reforming usage of OSTRACE by the Windows VFS. check-in: b347b5d1 user: mistachkin tags: winOsTrace
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  1039   1039     for(i=0; i<2 && zName==0; i++, rc &= 0xff){
  1040   1040       switch( rc ){
  1041   1041         case SQLITE_OK:                 zName = "SQLITE_OK";                break;
  1042   1042         case SQLITE_ERROR:              zName = "SQLITE_ERROR";             break;
  1043   1043         case SQLITE_INTERNAL:           zName = "SQLITE_INTERNAL";          break;
  1044   1044         case SQLITE_PERM:               zName = "SQLITE_PERM";              break;
  1045   1045         case SQLITE_ABORT:              zName = "SQLITE_ABORT";             break;
         1046  +      case SQLITE_ABORT_ROLLBACK:     zName = "SQLITE_ABORT_ROLLBACK";    break;
  1046   1047         case SQLITE_BUSY:               zName = "SQLITE_BUSY";              break;
         1048  +      case SQLITE_BUSY_RECOVERY:      zName = "SQLITE_BUSY_RECOVERY";     break;
  1047   1049         case SQLITE_LOCKED:             zName = "SQLITE_LOCKED";            break;
  1048   1050         case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break;
  1049   1051         case SQLITE_NOMEM:              zName = "SQLITE_NOMEM";             break;
  1050   1052         case SQLITE_READONLY:           zName = "SQLITE_READONLY";          break;
         1053  +      case SQLITE_READONLY_RECOVERY:  zName = "SQLITE_READONLY_RECOVERY"; break;
         1054  +      case SQLITE_READONLY_CANTLOCK:  zName = "SQLITE_READONLY_CANTLOCK"; break;
         1055  +      case SQLITE_READONLY_ROLLBACK:  zName = "SQLITE_READONLY_ROLLBACK"; break;
  1051   1056         case SQLITE_INTERRUPT:          zName = "SQLITE_INTERRUPT";         break;
  1052   1057         case SQLITE_IOERR:              zName = "SQLITE_IOERR";             break;
         1058  +      case SQLITE_IOERR_READ:         zName = "SQLITE_IOERR_READ";        break;
         1059  +      case SQLITE_IOERR_SHORT_READ:   zName = "SQLITE_IOERR_SHORT_READ";  break;
         1060  +      case SQLITE_IOERR_WRITE:        zName = "SQLITE_IOERR_WRITE";       break;
         1061  +      case SQLITE_IOERR_FSYNC:        zName = "SQLITE_IOERR_FSYNC";       break;
         1062  +      case SQLITE_IOERR_DIR_FSYNC:    zName = "SQLITE_IOERR_DIR_FSYNC";   break;
         1063  +      case SQLITE_IOERR_TRUNCATE:     zName = "SQLITE_IOERR_TRUNCATE";    break;
         1064  +      case SQLITE_IOERR_FSTAT:        zName = "SQLITE_IOERR_FSTAT";       break;
         1065  +      case SQLITE_IOERR_UNLOCK:       zName = "SQLITE_IOERR_UNLOCK";      break;
         1066  +      case SQLITE_IOERR_RDLOCK:       zName = "SQLITE_IOERR_RDLOCK";      break;
         1067  +      case SQLITE_IOERR_DELETE:       zName = "SQLITE_IOERR_DELETE";      break;
         1068  +      case SQLITE_IOERR_BLOCKED:      zName = "SQLITE_IOERR_BLOCKED";     break;
         1069  +      case SQLITE_IOERR_NOMEM:        zName = "SQLITE_IOERR_NOMEM";       break;
         1070  +      case SQLITE_IOERR_ACCESS:       zName = "SQLITE_IOERR_ACCESS";      break;
         1071  +      case SQLITE_IOERR_CHECKRESERVEDLOCK:
         1072  +                                zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break;
         1073  +      case SQLITE_IOERR_LOCK:         zName = "SQLITE_IOERR_LOCK";        break;
         1074  +      case SQLITE_IOERR_CLOSE:        zName = "SQLITE_IOERR_CLOSE";       break;
         1075  +      case SQLITE_IOERR_DIR_CLOSE:    zName = "SQLITE_IOERR_DIR_CLOSE";   break;
         1076  +      case SQLITE_IOERR_SHMOPEN:      zName = "SQLITE_IOERR_SHMOPEN";     break;
         1077  +      case SQLITE_IOERR_SHMSIZE:      zName = "SQLITE_IOERR_SHMSIZE";     break;
         1078  +      case SQLITE_IOERR_SHMLOCK:      zName = "SQLITE_IOERR_SHMLOCK";     break;
         1079  +      case SQLITE_IOERR_SHMMAP:       zName = "SQLITE_IOERR_SHMMAP";      break;
         1080  +      case SQLITE_IOERR_SEEK:         zName = "SQLITE_IOERR_SEEK";        break;
         1081  +      case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
         1082  +      case SQLITE_IOERR_MMAP:         zName = "SQLITE_IOERR_MMAP";        break;
  1053   1083         case SQLITE_CORRUPT:            zName = "SQLITE_CORRUPT";           break;
         1084  +      case SQLITE_CORRUPT_VTAB:       zName = "SQLITE_CORRUPT_VTAB";      break;
  1054   1085         case SQLITE_NOTFOUND:           zName = "SQLITE_NOTFOUND";          break;
  1055   1086         case SQLITE_FULL:               zName = "SQLITE_FULL";              break;
  1056   1087         case SQLITE_CANTOPEN:           zName = "SQLITE_CANTOPEN";          break;
         1088  +      case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
         1089  +      case SQLITE_CANTOPEN_ISDIR:     zName = "SQLITE_CANTOPEN_ISDIR";    break;
         1090  +      case SQLITE_CANTOPEN_FULLPATH:  zName = "SQLITE_CANTOPEN_FULLPATH"; break;
  1057   1091         case SQLITE_PROTOCOL:           zName = "SQLITE_PROTOCOL";          break;
  1058   1092         case SQLITE_EMPTY:              zName = "SQLITE_EMPTY";             break;
  1059   1093         case SQLITE_SCHEMA:             zName = "SQLITE_SCHEMA";            break;
  1060   1094         case SQLITE_TOOBIG:             zName = "SQLITE_TOOBIG";            break;
  1061   1095         case SQLITE_CONSTRAINT:         zName = "SQLITE_CONSTRAINT";        break;
  1062   1096         case SQLITE_CONSTRAINT_UNIQUE:  zName = "SQLITE_CONSTRAINT_UNIQUE"; break;
  1063   1097         case SQLITE_CONSTRAINT_TRIGGER: zName = "SQLITE_CONSTRAINT_TRIGGER";break;
................................................................................
  1077   1111         case SQLITE_NOLFS:              zName = "SQLITE_NOLFS";             break;
  1078   1112         case SQLITE_AUTH:               zName = "SQLITE_AUTH";              break;
  1079   1113         case SQLITE_FORMAT:             zName = "SQLITE_FORMAT";            break;
  1080   1114         case SQLITE_RANGE:              zName = "SQLITE_RANGE";             break;
  1081   1115         case SQLITE_NOTADB:             zName = "SQLITE_NOTADB";            break;
  1082   1116         case SQLITE_ROW:                zName = "SQLITE_ROW";               break;
  1083   1117         case SQLITE_NOTICE:             zName = "SQLITE_NOTICE";            break;
         1118  +      case SQLITE_NOTICE_RECOVER_WAL: zName = "SQLITE_NOTICE_RECOVER_WAL";break;
         1119  +      case SQLITE_NOTICE_RECOVER_ROLLBACK:
         1120  +                                zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break;
  1084   1121         case SQLITE_WARNING:            zName = "SQLITE_WARNING";           break;
  1085   1122         case SQLITE_DONE:               zName = "SQLITE_DONE";              break;
  1086         -      case SQLITE_IOERR_READ:         zName = "SQLITE_IOERR_READ";        break;
  1087         -      case SQLITE_IOERR_SHORT_READ:   zName = "SQLITE_IOERR_SHORT_READ";  break;
  1088         -      case SQLITE_IOERR_WRITE:        zName = "SQLITE_IOERR_WRITE";       break;
  1089         -      case SQLITE_IOERR_FSYNC:        zName = "SQLITE_IOERR_FSYNC";       break;
  1090         -      case SQLITE_IOERR_DIR_FSYNC:    zName = "SQLITE_IOERR_DIR_FSYNC";   break;
  1091         -      case SQLITE_IOERR_TRUNCATE:     zName = "SQLITE_IOERR_TRUNCATE";    break;
  1092         -      case SQLITE_IOERR_FSTAT:        zName = "SQLITE_IOERR_FSTAT";       break;
  1093         -      case SQLITE_IOERR_UNLOCK:       zName = "SQLITE_IOERR_UNLOCK";      break;
  1094         -      case SQLITE_IOERR_RDLOCK:       zName = "SQLITE_IOERR_RDLOCK";      break;
  1095         -      case SQLITE_IOERR_DELETE:       zName = "SQLITE_IOERR_DELETE";      break;
  1096         -      case SQLITE_IOERR_BLOCKED:      zName = "SQLITE_IOERR_BLOCKED";     break;
  1097         -      case SQLITE_IOERR_NOMEM:        zName = "SQLITE_IOERR_NOMEM";       break;
  1098         -      case SQLITE_IOERR_ACCESS:       zName = "SQLITE_IOERR_ACCESS";      break;
  1099         -      case SQLITE_IOERR_CHECKRESERVEDLOCK:
  1100         -                                zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break;
  1101         -      case SQLITE_IOERR_LOCK:         zName = "SQLITE_IOERR_LOCK";        break;
  1102         -      case SQLITE_CORRUPT_VTAB:       zName = "SQLITE_CORRUPT_VTAB";      break;
  1103         -      case SQLITE_READONLY_RECOVERY:  zName = "SQLITE_READONLY_RECOVERY"; break;
  1104         -      case SQLITE_READONLY_CANTLOCK:  zName = "SQLITE_READONLY_CANTLOCK"; break;
  1105         -      case SQLITE_READONLY_ROLLBACK:  zName = "SQLITE_READONLY_ROLLBACK"; break;
  1106   1123       }
  1107   1124     }
  1108   1125     if( zName==0 ) zName = "SQLITE_Unknown";
  1109   1126     return zName;
  1110   1127   }
  1111   1128   
  1112   1129   /*

Changes to src/os_win.c.

  1519   1519         sqlite3EndBenignMalloc();
  1520   1520         /* free the system buffer allocated by FormatMessage */
  1521   1521         osLocalFree(zTemp);
  1522   1522       }
  1523   1523     }
  1524   1524   #endif
  1525   1525     if( 0 == dwLen ){
  1526         -    sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", lastErrno, lastErrno);
         1526  +    sqlite3_snprintf(nBuf, zBuf, "OsError 0x%lx (%lu)", lastErrno, lastErrno);
  1527   1527     }else{
  1528   1528       /* copy a maximum of nBuf chars to output buffer */
  1529   1529       sqlite3_snprintf(nBuf, zBuf, "%s", zOut);
  1530   1530       /* free the UTF8 buffer */
  1531   1531       sqlite3_free(zOut);
  1532   1532     }
  1533   1533     return 0;
................................................................................
  1562   1562     zMsg[0] = 0;
  1563   1563     getLastErrorMsg(lastErrno, sizeof(zMsg), zMsg);
  1564   1564     assert( errcode!=SQLITE_OK );
  1565   1565     if( zPath==0 ) zPath = "";
  1566   1566     for(i=0; zMsg[i] && zMsg[i]!='\r' && zMsg[i]!='\n'; i++){}
  1567   1567     zMsg[i] = 0;
  1568   1568     sqlite3_log(errcode,
  1569         -      "os_win.c:%d: (%d) %s(%s) - %s",
         1569  +      "os_win.c:%d: (%lu) %s(%s) - %s",
  1570   1570         iLine, lastErrno, zFunc, zPath, zMsg
  1571   1571     );
  1572   1572   
  1573   1573     return errcode;
  1574   1574   }
  1575   1575   
  1576   1576   /*
................................................................................
  2321   2321   static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  2322   2322     winFile *pFile = (winFile*)id;  /* File handle object */
  2323   2323     int rc = SQLITE_OK;             /* Return code for this function */
  2324   2324     DWORD lastErrno;
  2325   2325   
  2326   2326     assert( pFile );
  2327   2327     SimulateIOError(return SQLITE_IOERR_TRUNCATE);
  2328         -  OSTRACE(("TRUNCATE file=%d, size=%lld, lock=%d\n",
         2328  +  OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
  2329   2329              pFile->h, nByte, pFile->locktype));
  2330   2330   
  2331   2331     /* If the user has configured a chunk-size for this file, truncate the
  2332   2332     ** file so that it consists of an integer number of chunks (i.e. the
  2333   2333     ** actual file size after the operation may be larger than the requested
  2334   2334     ** size).
  2335   2335     */
................................................................................
  3085   3085     if( rc!= 0 ){
  3086   3086       rc = SQLITE_OK;
  3087   3087     }else{
  3088   3088       pFile->lastErrno =  osGetLastError();
  3089   3089       rc = SQLITE_BUSY;
  3090   3090     }
  3091   3091   
  3092         -  OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%d, rc=%s\n", pFile->hFile.h,
  3093         -           (lockType == _SHM_UNLCK) ? "winUnlockFile" : "winLockFile",
  3094         -           pFile->lastErrno, sqlite3ErrName(rc)));
         3092  +  OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
         3093  +           pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" :
         3094  +           "winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
  3095   3095   
  3096   3096     return rc;
  3097   3097   }
  3098   3098   
  3099   3099   /* Forward references to VFS methods */
  3100   3100   static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
  3101   3101   static int winDelete(sqlite3_vfs *,const char*,int);
................................................................................
  3107   3107   ** by VFS shared-memory methods.
  3108   3108   */
  3109   3109   static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){
  3110   3110     winShmNode **pp;
  3111   3111     winShmNode *p;
  3112   3112     BOOL bRc;
  3113   3113     assert( winShmMutexHeld() );
  3114         -  OSTRACE(("SHM-PURGE pid=%d, deleteFlag=%d\n",
  3115         -           (int)osGetCurrentProcessId(), deleteFlag));
         3114  +  OSTRACE(("SHM-PURGE pid=%lu, deleteFlag=%d\n",
         3115  +           osGetCurrentProcessId(), deleteFlag));
  3116   3116     pp = &winShmNodeList;
  3117   3117     while( (p = *pp)!=0 ){
  3118   3118       if( p->nRef==0 ){
  3119   3119         int i;
  3120   3120         if( p->mutex ) sqlite3_mutex_free(p->mutex);
  3121   3121         for(i=0; i<p->nRegion; i++){
  3122   3122           bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
  3123         -        OSTRACE(("SHM-PURGE-UNMAP pid=%d, region=%d, rc=%s\n",
  3124         -                 (int)osGetCurrentProcessId(), i,
  3125         -                 bRc ? "ok" : "failed"));
         3123  +        OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n",
         3124  +                 osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
  3126   3125           bRc = osCloseHandle(p->aRegion[i].hMap);
  3127         -        OSTRACE(("SHM-PURGE-CLOSE pid=%d, region=%d, rc=%s\n",
  3128         -                 (int)osGetCurrentProcessId(), i,
  3129         -                 bRc ? "ok" : "failed"));
         3126  +        OSTRACE(("SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\n",
         3127  +                 osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
  3130   3128         }
  3131   3129         if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){
  3132   3130           SimulateIOErrorBenign(1);
  3133   3131           winClose((sqlite3_file *)&p->hFile);
  3134   3132           SimulateIOErrorBenign(0);
  3135   3133         }
  3136   3134         if( deleteFlag ){
................................................................................
  3401   3399         if( rc==SQLITE_OK ){
  3402   3400           assert( (p->sharedMask & mask)==0 );
  3403   3401           p->exclMask |= mask;
  3404   3402         }
  3405   3403       }
  3406   3404     }
  3407   3405     sqlite3_mutex_leave(pShmNode->mutex);
  3408         -  OSTRACE(("SHM-LOCK pid=%d, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\n",
  3409         -           (int)osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,
         3406  +  OSTRACE(("SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\n",
         3407  +           osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,
  3410   3408              sqlite3ErrName(rc)));
  3411   3409     return rc;
  3412   3410   }
  3413   3411   
  3414   3412   /*
  3415   3413   ** Implement a memory barrier or memory fence on shared memory.  
  3416   3414   **
................................................................................
  3524   3522             NULL, PAGE_READWRITE, 0, nByte, NULL
  3525   3523         );
  3526   3524   #elif defined(SQLITE_WIN32_HAS_ANSI)
  3527   3525         hMap = osCreateFileMappingA(pShmNode->hFile.h, 
  3528   3526             NULL, PAGE_READWRITE, 0, nByte, NULL
  3529   3527         );
  3530   3528   #endif
  3531         -      OSTRACE(("SHM-MAP-CREATE pid=%d, region=%d, size=%d, rc=%s\n",
  3532         -               (int)osGetCurrentProcessId(), pShmNode->nRegion, nByte,
         3529  +      OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n",
         3530  +               osGetCurrentProcessId(), pShmNode->nRegion, nByte,
  3533   3531                  hMap ? "ok" : "failed"));
  3534   3532         if( hMap ){
  3535   3533           int iOffset = pShmNode->nRegion*szRegion;
  3536   3534           int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
  3537   3535   #if SQLITE_OS_WINRT
  3538   3536           pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ,
  3539   3537               iOffset - iOffsetShift, szRegion + iOffsetShift
  3540   3538           );
  3541   3539   #else
  3542   3540           pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,
  3543   3541               0, iOffset - iOffsetShift, szRegion + iOffsetShift
  3544   3542           );
  3545   3543   #endif
  3546         -        OSTRACE(("SHM-MAP-MAP pid=%d, region=%d, offset=%d, size=%d, rc=%s\n",
  3547         -                 (int)osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
         3544  +        OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
         3545  +                 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
  3548   3546                    szRegion, pMap ? "ok" : "failed"));
  3549   3547         }
  3550   3548         if( !pMap ){
  3551   3549           pShmNode->lastErrno = osGetLastError();
  3552   3550           rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
  3553   3551                    "winShmMap3", pDbFd->zPath);
  3554   3552           if( hMap ) osCloseHandle(hMap);
................................................................................
  3583   3581   
  3584   3582   /*
  3585   3583   ** Cleans up the mapped region of the specified file, if any.
  3586   3584   */
  3587   3585   #if SQLITE_MAX_MMAP_SIZE>0
  3588   3586   static int winUnmapfile(winFile *pFile){
  3589   3587     assert( pFile!=0 );
  3590         -  OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, hMap=%p, pMapRegion=%p, "
         3588  +  OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, pMapRegion=%p, "
  3591   3589              "mmapSize=%lld, mmapSizeActual=%lld, mmapSizeMax=%lld\n",
  3592         -           (int)osGetCurrentProcessId(), pFile, pFile->hMap,
  3593         -           pFile->pMapRegion, pFile->mmapSize, pFile->mmapSizeActual,
  3594         -           pFile->mmapSizeMax));
         3590  +           osGetCurrentProcessId(), pFile, pFile->hMap, pFile->pMapRegion,
         3591  +           pFile->mmapSize, pFile->mmapSizeActual, pFile->mmapSizeMax));
  3595   3592     if( pFile->pMapRegion ){
  3596   3593       if( !osUnmapViewOfFile(pFile->pMapRegion) ){
  3597   3594         pFile->lastErrno = osGetLastError();
  3598         -      OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, pMapRegion=%p, "
  3599         -               "rc=SQLITE_IOERR_MMAP\n", (int)osGetCurrentProcessId(),
  3600         -               pFile, pFile->pMapRegion));
         3595  +      OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, "
         3596  +               "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile,
         3597  +               pFile->pMapRegion));
  3601   3598         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3602   3599                            "winUnmap1", pFile->zPath);
  3603   3600       }
  3604   3601       pFile->pMapRegion = 0;
  3605   3602       pFile->mmapSize = 0;
  3606   3603       pFile->mmapSizeActual = 0;
  3607   3604     }
  3608   3605     if( pFile->hMap!=NULL ){
  3609   3606       if( !osCloseHandle(pFile->hMap) ){
  3610   3607         pFile->lastErrno = osGetLastError();
  3611         -      OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
  3612         -               (int)osGetCurrentProcessId(), pFile, pFile->hMap));
         3608  +      OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
         3609  +               osGetCurrentProcessId(), pFile, pFile->hMap));
  3613   3610         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3614   3611                            "winUnmap2", pFile->zPath);
  3615   3612       }
  3616   3613       pFile->hMap = NULL;
  3617   3614     }
  3618         -  OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, rc=SQLITE_OK\n",
  3619         -           (int)osGetCurrentProcessId(), pFile));
         3615  +  OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
         3616  +           osGetCurrentProcessId(), pFile));
  3620   3617     return SQLITE_OK;
  3621   3618   }
  3622   3619   
  3623   3620   /*
  3624   3621   ** Memory map or remap the file opened by file-descriptor pFd (if the file
  3625   3622   ** is already mapped, the existing mapping is replaced by the new). Or, if 
  3626   3623   ** there already exists a mapping for this file, and there are still 
................................................................................
  3637   3634   ** code otherwise.
  3638   3635   */
  3639   3636   static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
  3640   3637     sqlite3_int64 nMap = nByte;
  3641   3638     int rc;
  3642   3639   
  3643   3640     assert( nMap>=0 || pFd->nFetchOut==0 );
  3644         -  OSTRACE(("MAP-FILE pid=%d, pFile=%p, size=%lld\n",
  3645         -           (int)osGetCurrentProcessId(), pFd, nByte));
         3641  +  OSTRACE(("MAP-FILE pid=%lu, pFile=%p, size=%lld\n",
         3642  +           osGetCurrentProcessId(), pFd, nByte));
  3646   3643   
  3647   3644     if( pFd->nFetchOut>0 ) return SQLITE_OK;
  3648   3645   
  3649   3646     if( nMap<0 ){
  3650   3647       rc = winFileSize((sqlite3_file*)pFd, &nMap);
  3651   3648       if( rc ){
  3652         -      OSTRACE(("MAP-FILE pid=%d, pFile=%p, rc=SQLITE_IOERR_FSTAT\n",
  3653         -               (int)osGetCurrentProcessId(), pFd));
         3649  +      OSTRACE(("MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_IOERR_FSTAT\n",
         3650  +               osGetCurrentProcessId(), pFd));
  3654   3651         return SQLITE_IOERR_FSTAT;
  3655   3652       }
  3656   3653     }
  3657   3654     if( nMap>pFd->mmapSizeMax ){
  3658   3655       nMap = pFd->mmapSizeMax;
  3659   3656     }
  3660   3657     nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);
................................................................................
  3684   3681                                   (DWORD)(nMap & 0xffffffff), NULL);
  3685   3682   #endif
  3686   3683       if( pFd->hMap==NULL ){
  3687   3684         pFd->lastErrno = osGetLastError();
  3688   3685         rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3689   3686                          "winMapfile", pFd->zPath);
  3690   3687         /* Log the error, but continue normal operation using xRead/xWrite */
  3691         -      OSTRACE(("MAP-FILE-CREATE pid=%d, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
  3692         -               (int)osGetCurrentProcessId(), pFd));
         3688  +      OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
         3689  +               osGetCurrentProcessId(), pFd));
  3693   3690         return SQLITE_OK;
  3694   3691       }
  3695   3692       assert( (nMap % winSysInfo.dwPageSize)==0 );
  3696   3693   #if SQLITE_OS_WINRT
  3697   3694       pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
  3698   3695   #else
  3699   3696       assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
................................................................................
  3701   3698   #endif
  3702   3699       if( pNew==NULL ){
  3703   3700         osCloseHandle(pFd->hMap);
  3704   3701         pFd->hMap = NULL;
  3705   3702         pFd->lastErrno = osGetLastError();
  3706   3703         winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3707   3704                     "winMapfile", pFd->zPath);
  3708         -      OSTRACE(("MAP-FILE-MAP pid=%d, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
  3709         -               (int)osGetCurrentProcessId(), pFd));
         3705  +      OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
         3706  +               osGetCurrentProcessId(), pFd));
  3710   3707         return SQLITE_OK;
  3711   3708       }
  3712   3709       pFd->pMapRegion = pNew;
  3713   3710       pFd->mmapSize = nMap;
  3714   3711       pFd->mmapSizeActual = nMap;
  3715   3712     }
  3716   3713   
  3717         -  OSTRACE(("MAP-FILE pid=%d, pFile=%p, rc=SQLITE_OK\n",
  3718         -           (int)osGetCurrentProcessId(), pFd));
         3714  +  OSTRACE(("MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
         3715  +           osGetCurrentProcessId(), pFd));
  3719   3716     return SQLITE_OK;
  3720   3717   }
  3721   3718   #endif /* SQLITE_MAX_MMAP_SIZE>0 */
  3722   3719   
  3723   3720   /*
  3724   3721   ** If possible, return a pointer to a mapping of file fd starting at offset
  3725   3722   ** iOff. The mapping must be valid for at least nAmt bytes.
................................................................................
  3726   3723   **
  3727   3724   ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.
  3728   3725   ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.
  3729   3726   ** Finally, if an error does occur, return an SQLite error code. The final
  3730   3727   ** value of *pp is undefined in this case.
  3731   3728   **
  3732   3729   ** If this function does return a pointer, the caller must eventually 
  3733         -** release the reference by calling unixUnfetch().
         3730  +** release the reference by calling winUnfetch().
  3734   3731   */
  3735   3732   static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
  3736   3733   #if SQLITE_MAX_MMAP_SIZE>0
  3737   3734     winFile *pFd = (winFile*)fd;   /* The underlying database file */
  3738   3735   #endif
  3739   3736     *pp = 0;
  3740   3737   
  3741         -  OSTRACE(("FETCH pid=%d, pFile=%p, offset=%lld, amount=%d, pp=%p\n",
  3742         -           (int)osGetCurrentProcessId(), fd, iOff, nAmt, pp));
         3738  +  OSTRACE(("FETCH pid=%lu, pFile=%p, offset=%lld, amount=%d, pp=%p\n",
         3739  +           osGetCurrentProcessId(), fd, iOff, nAmt, pp));
  3743   3740   
  3744   3741   #if SQLITE_MAX_MMAP_SIZE>0
  3745   3742     if( pFd->mmapSizeMax>0 ){
  3746   3743       if( pFd->pMapRegion==0 ){
  3747   3744         int rc = winMapfile(pFd, -1);
  3748   3745         if( rc!=SQLITE_OK ){
  3749         -        OSTRACE(("FETCH pid=%d, pFile=%p, rc=%s\n",
  3750         -                 (int)osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
         3746  +        OSTRACE(("FETCH pid=%lu, pFile=%p, rc=%s\n",
         3747  +                 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
  3751   3748           return rc;
  3752   3749         }
  3753   3750       }
  3754   3751       if( pFd->mmapSize >= iOff+nAmt ){
  3755   3752         *pp = &((u8 *)pFd->pMapRegion)[iOff];
  3756   3753         pFd->nFetchOut++;
  3757   3754       }
  3758   3755     }
  3759   3756   #endif
  3760   3757   
  3761         -  OSTRACE(("FETCH pid=%d, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\n",
  3762         -           (int)osGetCurrentProcessId(), fd, pp, pp ? *pp : 0));
         3758  +  OSTRACE(("FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\n",
         3759  +           osGetCurrentProcessId(), fd, pp, *pp));
  3763   3760     return SQLITE_OK;
  3764   3761   }
  3765   3762   
  3766   3763   /*
  3767   3764   ** If the third argument is non-NULL, then this function releases a 
  3768         -** reference obtained by an earlier call to unixFetch(). The second
         3765  +** reference obtained by an earlier call to winFetch(). The second
  3769   3766   ** argument passed to this function must be the same as the corresponding
  3770         -** argument that was passed to the unixFetch() invocation. 
         3767  +** argument that was passed to the winFetch() invocation. 
  3771   3768   **
  3772   3769   ** Or, if the third argument is NULL, then this function is being called 
  3773   3770   ** to inform the VFS layer that, according to POSIX, any existing mapping 
  3774   3771   ** may now be invalid and should be unmapped.
  3775   3772   */
  3776   3773   static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
  3777   3774   #if SQLITE_MAX_MMAP_SIZE>0
................................................................................
  3781   3778     ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
  3782   3779     ** then there must be at least one outstanding.  */
  3783   3780     assert( (p==0)==(pFd->nFetchOut==0) );
  3784   3781   
  3785   3782     /* If p!=0, it must match the iOff value. */
  3786   3783     assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );
  3787   3784   
  3788         -  OSTRACE(("UNFETCH pid=%d, pFile=%p, offset=%lld, p=%p\n",
  3789         -           (int)osGetCurrentProcessId(), pFd, iOff, p));
         3785  +  OSTRACE(("UNFETCH pid=%lu, pFile=%p, offset=%lld, p=%p\n",
         3786  +           osGetCurrentProcessId(), pFd, iOff, p));
  3790   3787   
  3791   3788     if( p ){
  3792   3789       pFd->nFetchOut--;
  3793   3790     }else{
  3794   3791       /* FIXME:  If Windows truly always prevents truncating or deleting a
  3795   3792       ** file while a mapping is held, then the following winUnmapfile() call
  3796   3793       ** is unnecessary can can be omitted - potentially improving
................................................................................
  3797   3794       ** performance.  */
  3798   3795       winUnmapfile(pFd);
  3799   3796     }
  3800   3797   
  3801   3798     assert( pFd->nFetchOut>=0 );
  3802   3799   #endif
  3803   3800   
  3804         -  OSTRACE(("UNFETCH pid=%d, pFile=%p, rc=SQLITE_OK\n",
  3805         -           (int)osGetCurrentProcessId(), fd));
         3801  +  OSTRACE(("UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\n",
         3802  +           osGetCurrentProcessId(), fd));
  3806   3803     return SQLITE_OK;
  3807   3804   }
  3808   3805   
  3809   3806   /*
  3810   3807   ** Here ends the implementation of all sqlite3_file methods.
  3811   3808   **
  3812   3809   ********************** End sqlite3_file Methods *******************************
................................................................................
  4069   4066     ** temporary file name to use 
  4070   4067     */
  4071   4068     if( !zUtf8Name ){
  4072   4069       assert(isDelete && !isOpenJournal);
  4073   4070       memset(zTmpname, 0, MAX_PATH+2);
  4074   4071       rc = getTempname(MAX_PATH+2, zTmpname);
  4075   4072       if( rc!=SQLITE_OK ){
  4076         -      OSTRACE(("OPEN name=%s, rc=%s",
  4077         -               zUtf8Name, sqlite3ErrName(rc)));
         4073  +      OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
  4078   4074         return rc;
  4079   4075       }
  4080   4076       zUtf8Name = zTmpname;
  4081   4077     }
  4082   4078   
  4083   4079     /* Database filenames are double-zero terminated if they are not
  4084   4080     ** URIs with parameters.  Hence, they can always be passed into
................................................................................
  4207   4203     if( pOutFlags ){
  4208   4204       if( isReadWrite ){
  4209   4205         *pOutFlags = SQLITE_OPEN_READWRITE;
  4210   4206       }else{
  4211   4207         *pOutFlags = SQLITE_OPEN_READONLY;
  4212   4208       }
  4213   4209     }
         4210  +
         4211  +  OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
         4212  +           "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
         4213  +           *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
  4214   4214   
  4215   4215   #if SQLITE_OS_WINCE
  4216   4216     if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
  4217   4217          && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
  4218   4218     ){
  4219   4219       osCloseHandle(h);
  4220   4220       sqlite3_free(zConverted);

Changes to src/test1.c.

   109    109       *ppDb = p->db;
   110    110     }else{
   111    111       *ppDb = (sqlite3*)sqlite3TestTextToPtr(zA);
   112    112     }
   113    113     return TCL_OK;
   114    114   }
   115    115   
   116         -
   117         -const char *sqlite3TestErrorName(int rc){
   118         -  const char *zName = 0;
   119         -  int i;
   120         -  for(i=0; i<2 && zName==0; i++, rc &= 0xff){
   121         -    switch( rc ){
   122         -      case SQLITE_OK:                  zName = "SQLITE_OK";                break;
   123         -      case SQLITE_ERROR:               zName = "SQLITE_ERROR";             break;
   124         -      case SQLITE_INTERNAL:            zName = "SQLITE_INTERNAL";          break;
   125         -      case SQLITE_PERM:                zName = "SQLITE_PERM";              break;
   126         -      case SQLITE_ABORT:               zName = "SQLITE_ABORT";             break;
   127         -      case SQLITE_BUSY:                zName = "SQLITE_BUSY";              break;
   128         -      case SQLITE_LOCKED:              zName = "SQLITE_LOCKED";            break;
   129         -      case SQLITE_LOCKED_SHAREDCACHE:  zName = "SQLITE_LOCKED_SHAREDCACHE";break;
   130         -      case SQLITE_NOMEM:               zName = "SQLITE_NOMEM";             break;
   131         -      case SQLITE_READONLY:            zName = "SQLITE_READONLY";          break;
   132         -      case SQLITE_INTERRUPT:           zName = "SQLITE_INTERRUPT";         break;
   133         -      case SQLITE_IOERR:               zName = "SQLITE_IOERR";             break;
   134         -      case SQLITE_CORRUPT:             zName = "SQLITE_CORRUPT";           break;
   135         -      case SQLITE_NOTFOUND:            zName = "SQLITE_NOTFOUND";          break;
   136         -      case SQLITE_FULL:                zName = "SQLITE_FULL";              break;
   137         -      case SQLITE_CANTOPEN:            zName = "SQLITE_CANTOPEN";          break;
   138         -      case SQLITE_PROTOCOL:            zName = "SQLITE_PROTOCOL";          break;
   139         -      case SQLITE_EMPTY:               zName = "SQLITE_EMPTY";             break;
   140         -      case SQLITE_SCHEMA:              zName = "SQLITE_SCHEMA";            break;
   141         -      case SQLITE_TOOBIG:              zName = "SQLITE_TOOBIG";            break;
   142         -      case SQLITE_CONSTRAINT:          zName = "SQLITE_CONSTRAINT";        break;
   143         -      case SQLITE_CONSTRAINT_UNIQUE:   zName = "SQLITE_CONSTRAINT_UNIQUE"; break;
   144         -      case SQLITE_CONSTRAINT_TRIGGER:  zName = "SQLITE_CONSTRAINT_TRIGGER";break;
   145         -      case SQLITE_CONSTRAINT_FOREIGNKEY:
   146         -                                   zName = "SQLITE_CONSTRAINT_FOREIGNKEY"; break;
   147         -      case SQLITE_CONSTRAINT_CHECK:    zName = "SQLITE_CONSTRAINT_CHECK";  break;
   148         -      case SQLITE_CONSTRAINT_PRIMARYKEY:
   149         -                                   zName = "SQLITE_CONSTRAINT_PRIMARYKEY"; break;
   150         -      case SQLITE_CONSTRAINT_NOTNULL:  zName = "SQLITE_CONSTRAINT_NOTNULL";break;
   151         -      case SQLITE_CONSTRAINT_COMMITHOOK:
   152         -                                   zName = "SQLITE_CONSTRAINT_COMMITHOOK"; break;
   153         -      case SQLITE_CONSTRAINT_VTAB:     zName = "SQLITE_CONSTRAINT_VTAB";   break;
   154         -      case SQLITE_CONSTRAINT_FUNCTION: zName = "SQLITE_CONSTRAINT_FUNCTION";break;
   155         -      case SQLITE_MISMATCH:            zName = "SQLITE_MISMATCH";          break;
   156         -      case SQLITE_MISUSE:              zName = "SQLITE_MISUSE";            break;
   157         -      case SQLITE_NOLFS:               zName = "SQLITE_NOLFS";             break;
   158         -      case SQLITE_AUTH:                zName = "SQLITE_AUTH";              break;
   159         -      case SQLITE_FORMAT:              zName = "SQLITE_FORMAT";            break;
   160         -      case SQLITE_RANGE:               zName = "SQLITE_RANGE";             break;
   161         -      case SQLITE_NOTADB:              zName = "SQLITE_NOTADB";            break;
   162         -      case SQLITE_ROW:                 zName = "SQLITE_ROW";               break;
   163         -      case SQLITE_NOTICE:              zName = "SQLITE_NOTICE";            break;
   164         -      case SQLITE_WARNING:             zName = "SQLITE_WARNING";           break;
   165         -      case SQLITE_DONE:                zName = "SQLITE_DONE";              break;
   166         -      case SQLITE_IOERR_READ:          zName = "SQLITE_IOERR_READ";        break;
   167         -      case SQLITE_IOERR_SHORT_READ:    zName = "SQLITE_IOERR_SHORT_READ";  break;
   168         -      case SQLITE_IOERR_WRITE:         zName = "SQLITE_IOERR_WRITE";       break;
   169         -      case SQLITE_IOERR_FSYNC:         zName = "SQLITE_IOERR_FSYNC";       break;
   170         -      case SQLITE_IOERR_DIR_FSYNC:     zName = "SQLITE_IOERR_DIR_FSYNC";   break;
   171         -      case SQLITE_IOERR_TRUNCATE:      zName = "SQLITE_IOERR_TRUNCATE";    break;
   172         -      case SQLITE_IOERR_FSTAT:         zName = "SQLITE_IOERR_FSTAT";       break;
   173         -      case SQLITE_IOERR_UNLOCK:        zName = "SQLITE_IOERR_UNLOCK";      break;
   174         -      case SQLITE_IOERR_RDLOCK:        zName = "SQLITE_IOERR_RDLOCK";      break;
   175         -      case SQLITE_IOERR_DELETE:        zName = "SQLITE_IOERR_DELETE";      break;
   176         -      case SQLITE_IOERR_BLOCKED:       zName = "SQLITE_IOERR_BLOCKED";     break;
   177         -      case SQLITE_IOERR_NOMEM:         zName = "SQLITE_IOERR_NOMEM";       break;
   178         -      case SQLITE_IOERR_ACCESS:        zName = "SQLITE_IOERR_ACCESS";      break;
   179         -      case SQLITE_IOERR_CHECKRESERVEDLOCK:
   180         -                                 zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break;
   181         -      case SQLITE_IOERR_LOCK:          zName = "SQLITE_IOERR_LOCK";        break;
   182         -      case SQLITE_CORRUPT_VTAB:        zName = "SQLITE_CORRUPT_VTAB";      break;
   183         -      case SQLITE_READONLY_RECOVERY:   zName = "SQLITE_READONLY_RECOVERY"; break;
   184         -      case SQLITE_READONLY_CANTLOCK:   zName = "SQLITE_READONLY_CANTLOCK"; break;
   185         -      case SQLITE_READONLY_ROLLBACK:   zName = "SQLITE_READONLY_ROLLBACK"; break;
   186         -    }
   187         -  }
   188         -  if( zName==0 ) zName = "SQLITE_Unknown";
   189         -  return zName;
   190         -}
   191         -#define t1ErrorName sqlite3TestErrorName
          116  +extern const char *sqlite3ErrName(int);
          117  +#define t1ErrorName sqlite3ErrName
   192    118   
   193    119   /*
   194    120   ** Convert an sqlite3_stmt* into an sqlite3*.  This depends on the
   195    121   ** fact that the sqlite3* is the first field in the Vdbe structure.
   196    122   */
   197    123   #define StmtToDb(X)   sqlite3_db_handle(X)
   198    124   
................................................................................
  1729   1655     if( nByte>0 ){
  1730   1656       zBuf = (unsigned char *)Tcl_Alloc(nByte);
  1731   1657     }
  1732   1658     rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset);
  1733   1659     if( rc==SQLITE_OK ){
  1734   1660       Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zBuf, nByte));
  1735   1661     }else{
  1736         -    Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1662  +    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1737   1663     }
  1738   1664     Tcl_Free((char *)zBuf);
  1739   1665   
  1740   1666     return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);
  1741   1667   }
  1742   1668   
  1743   1669   /*
................................................................................
  1779   1705   
  1780   1706     zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf);
  1781   1707     if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){
  1782   1708       return TCL_ERROR;
  1783   1709     }
  1784   1710     rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset);
  1785   1711     if( rc!=SQLITE_OK ){
  1786         -    Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1712  +    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1787   1713     }
  1788   1714   
  1789   1715     return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);
  1790   1716   }
  1791   1717   
  1792   1718   static int test_blob_reopen(
  1793   1719     ClientData clientData, /* Not used */
................................................................................
  1805   1731     }
  1806   1732   
  1807   1733     if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
  1808   1734     if( Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ) return TCL_ERROR;
  1809   1735   
  1810   1736     rc = sqlite3_blob_reopen(pBlob, iRowid);
  1811   1737     if( rc!=SQLITE_OK ){
  1812         -    Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1738  +    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1813   1739     }
  1814   1740   
  1815   1741     return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);
  1816   1742   }
  1817   1743   
  1818   1744   #endif
  1819   1745   
................................................................................
  2015   1941         (p->pFunc ? cf2Func : 0),
  2016   1942         (p->pStep ? cf2Step : 0),
  2017   1943         (p->pFinal ? cf2Final : 0),
  2018   1944         cf2Destroy
  2019   1945     );
  2020   1946     if( rc!=SQLITE_OK ){
  2021   1947       Tcl_ResetResult(interp);
  2022         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
         1948  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
  2023   1949       return TCL_ERROR;
  2024   1950     }
  2025   1951     return TCL_OK;
  2026   1952   }
  2027   1953   
  2028   1954   /*
  2029   1955   ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC?
................................................................................
  2691   2617       }
  2692   2618       sqlite3ValueFree(pVal);
  2693   2619       sqlite3_mutex_leave(db->mutex);
  2694   2620     }
  2695   2621     if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
  2696   2622     
  2697   2623     if( rc!=SQLITE_OK ){
  2698         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
         2624  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
  2699   2625       return TCL_ERROR;
  2700   2626     }
  2701   2627     return TCL_OK;
  2702   2628   
  2703   2629   bad_args:
  2704   2630     Tcl_AppendResult(interp, "wrong # args: should be \"",
  2705   2631         Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0);
................................................................................
  3249   3175     if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
  3250   3176     value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes);
  3251   3177     if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;
  3252   3178   
  3253   3179     rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT);
  3254   3180     if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;
  3255   3181     if( rc!=SQLITE_OK ){
  3256         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
         3182  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
  3257   3183       return TCL_ERROR;
  3258   3184     }
  3259   3185   
  3260   3186     return TCL_OK;
  3261   3187   }
  3262   3188   
  3263   3189   /*
................................................................................
  3297   3223     if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR;
  3298   3224     value = (char*)Tcl_GetByteArrayFromObj(oString, 0);
  3299   3225     if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR;
  3300   3226   
  3301   3227     rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel);
  3302   3228     if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;
  3303   3229     if( rc!=SQLITE_OK ){
  3304         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
         3230  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
  3305   3231       return TCL_ERROR;
  3306   3232     }
  3307   3233   
  3308   3234   #endif /* SQLITE_OMIT_UTF16 */
  3309   3235     return TCL_OK;
  3310   3236   }
  3311   3237   
................................................................................
  4571   4497       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
  4572   4498           " DB", 0);
  4573   4499       return TCL_ERROR;
  4574   4500     }
  4575   4501     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
  4576   4502     if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR;
  4577   4503     rc = sqlite3_busy_timeout(db, ms);
  4578         -  Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
         4504  +  Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
  4579   4505     return TCL_OK;
  4580   4506   }
  4581   4507   
  4582   4508   /*
  4583   4509   ** Usage:  tcl_variable_type VARIABLENAME
  4584   4510   **
  4585   4511   ** Return the name of the internal representation for the
................................................................................
  5092   5018      return TCL_ERROR;
  5093   5019     }
  5094   5020     zDb = Tcl_GetString(objv[2]);
  5095   5021     if( zDb[0]=='\0' ) zDb = NULL;
  5096   5022   
  5097   5023     rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_CHUNK_SIZE, (void *)&nSize);
  5098   5024     if( rc ){
  5099         -    Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         5025  +    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  5100   5026       return TCL_ERROR;
  5101   5027     }
  5102   5028     return TCL_OK;
  5103   5029   }
  5104   5030   
  5105   5031   /*
  5106   5032   ** tclcmd:   file_control_sizehint_test DB DBNAME SIZE
................................................................................
  5129   5055      return TCL_ERROR;
  5130   5056     }
  5131   5057     zDb = Tcl_GetString(objv[2]);
  5132   5058     if( zDb[0]=='\0' ) zDb = NULL;
  5133   5059   
  5134   5060     rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_SIZE_HINT, (void *)&nSize);
  5135   5061     if( rc ){
  5136         -    Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         5062  +    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  5137   5063       return TCL_ERROR;
  5138   5064     }
  5139   5065     return TCL_OK;
  5140   5066   }
  5141   5067   
  5142   5068   /*
  5143   5069   ** tclcmd:   file_control_lockproxy_test DB PWD
................................................................................
  5673   5599     Tcl_Interp *pInterp;
  5674   5600     Tcl_Obj *pObj;
  5675   5601   } logcallback = {0, 0};
  5676   5602   static void xLogcallback(void *unused, int err, char *zMsg){
  5677   5603     Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj);
  5678   5604     Tcl_IncrRefCount(pNew);
  5679   5605     Tcl_ListObjAppendElement(
  5680         -      0, pNew, Tcl_NewStringObj(sqlite3TestErrorName(err), -1)
         5606  +      0, pNew, Tcl_NewStringObj(sqlite3ErrName(err), -1)
  5681   5607     );
  5682   5608     Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1));
  5683   5609     Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
  5684   5610     Tcl_DecrRefCount(pNew);
  5685   5611   }
  5686   5612   static int test_sqlite3_log(
  5687   5613     ClientData clientData,

Changes to src/test2.c.

    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "tcl.h"
    18     18   #include <stdlib.h>
    19     19   #include <string.h>
    20     20   #include <ctype.h>
    21     21   
    22         -extern const char *sqlite3TestErrorName(int rc);
           22  +extern const char *sqlite3ErrName(int);
    23     23   
    24     24   /*
    25     25   ** Page size and reserved size used for testing.
    26     26   */
    27     27   static int test_pagesize = 1024;
    28     28   
    29     29   /*
................................................................................
    55     55       return TCL_ERROR;
    56     56     }
    57     57     if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
    58     58     rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0,
    59     59         SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB,
    60     60         pager_test_reiniter);
    61     61     if( rc!=SQLITE_OK ){
    62         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
           62  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
    63     63       return TCL_ERROR;
    64     64     }
    65     65     sqlite3PagerSetCachesize(pPager, nPage);
    66     66     pageSize = test_pagesize;
    67     67     sqlite3PagerSetPagesize(pPager, &pageSize, -1);
    68     68     sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager);
    69     69     Tcl_AppendResult(interp, zBuf, 0);
................................................................................
    87     87       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    88     88          " ID\"", 0);
    89     89       return TCL_ERROR;
    90     90     }
    91     91     pPager = sqlite3TestTextToPtr(argv[1]);
    92     92     rc = sqlite3PagerClose(pPager);
    93     93     if( rc!=SQLITE_OK ){
    94         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
           94  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
    95     95       return TCL_ERROR;
    96     96     }
    97     97     return TCL_OK;
    98     98   }
    99     99   
   100    100   /*
   101    101   ** Usage:   pager_rollback ID
................................................................................
   114    114       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   115    115          " ID\"", 0);
   116    116       return TCL_ERROR;
   117    117     }
   118    118     pPager = sqlite3TestTextToPtr(argv[1]);
   119    119     rc = sqlite3PagerRollback(pPager);
   120    120     if( rc!=SQLITE_OK ){
   121         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          121  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   122    122       return TCL_ERROR;
   123    123     }
   124    124     return TCL_OK;
   125    125   }
   126    126   
   127    127   /*
   128    128   ** Usage:   pager_commit ID
................................................................................
   141    141       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   142    142          " ID\"", 0);
   143    143       return TCL_ERROR;
   144    144     }
   145    145     pPager = sqlite3TestTextToPtr(argv[1]);
   146    146     rc = sqlite3PagerCommitPhaseOne(pPager, 0, 0);
   147    147     if( rc!=SQLITE_OK ){
   148         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          148  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   149    149       return TCL_ERROR;
   150    150     }
   151    151     rc = sqlite3PagerCommitPhaseTwo(pPager);
   152    152     if( rc!=SQLITE_OK ){
   153         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          153  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   154    154       return TCL_ERROR;
   155    155     }
   156    156     return TCL_OK;
   157    157   }
   158    158   
   159    159   /*
   160    160   ** Usage:   pager_stmt_begin ID
................................................................................
   173    173       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   174    174          " ID\"", 0);
   175    175       return TCL_ERROR;
   176    176     }
   177    177     pPager = sqlite3TestTextToPtr(argv[1]);
   178    178     rc = sqlite3PagerOpenSavepoint(pPager, 1);
   179    179     if( rc!=SQLITE_OK ){
   180         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          180  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   181    181       return TCL_ERROR;
   182    182     }
   183    183     return TCL_OK;
   184    184   }
   185    185   
   186    186   /*
   187    187   ** Usage:   pager_stmt_rollback ID
................................................................................
   201    201          " ID\"", 0);
   202    202       return TCL_ERROR;
   203    203     }
   204    204     pPager = sqlite3TestTextToPtr(argv[1]);
   205    205     rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, 0);
   206    206     sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0);
   207    207     if( rc!=SQLITE_OK ){
   208         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          208  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   209    209       return TCL_ERROR;
   210    210     }
   211    211     return TCL_OK;
   212    212   }
   213    213   
   214    214   /*
   215    215   ** Usage:   pager_stmt_commit ID
................................................................................
   228    228       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   229    229          " ID\"", 0);
   230    230       return TCL_ERROR;
   231    231     }
   232    232     pPager = sqlite3TestTextToPtr(argv[1]);
   233    233     rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0);
   234    234     if( rc!=SQLITE_OK ){
   235         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          235  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   236    236       return TCL_ERROR;
   237    237     }
   238    238     return TCL_OK;
   239    239   }
   240    240   
   241    241   /*
   242    242   ** Usage:   pager_stats ID
................................................................................
   321    321     pPager = sqlite3TestTextToPtr(argv[1]);
   322    322     if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
   323    323     rc = sqlite3PagerSharedLock(pPager);
   324    324     if( rc==SQLITE_OK ){
   325    325       rc = sqlite3PagerGet(pPager, pgno, &pPage);
   326    326     }
   327    327     if( rc!=SQLITE_OK ){
   328         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          328  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   329    329       return TCL_ERROR;
   330    330     }
   331    331     sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage);
   332    332     Tcl_AppendResult(interp, zBuf, 0);
   333    333     return TCL_OK;
   334    334   }
   335    335   
................................................................................
   475    475       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   476    476          " PAGE DATA\"", 0);
   477    477       return TCL_ERROR;
   478    478     }
   479    479     pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]);
   480    480     rc = sqlite3PagerWrite(pPage);
   481    481     if( rc!=SQLITE_OK ){
   482         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          482  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   483    483       return TCL_ERROR;
   484    484     }
   485    485     pData = sqlite3PagerGetData(pPage);
   486    486     strncpy(pData, argv[2], test_pagesize-1);
   487    487     pData[test_pagesize-1] = 0;
   488    488     return TCL_OK;
   489    489   }
................................................................................
   524    524     if( zFile==0 ) return TCL_ERROR;
   525    525     memcpy(zFile, argv[2], nFile+1);
   526    526     zFile[nFile+1] = 0;
   527    527     rc = sqlite3OsOpenMalloc(pVfs, zFile, &fd, 
   528    528         (SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0
   529    529     );
   530    530     if( rc ){
   531         -    Tcl_AppendResult(interp, "open failed: ", sqlite3TestErrorName(rc), 0);
          531  +    Tcl_AppendResult(interp, "open failed: ", sqlite3ErrName(rc), 0);
   532    532       sqlite3_free(zFile);
   533    533       return TCL_ERROR;
   534    534     }
   535    535     offset = n;
   536    536     offset *= 1024*1024;
   537    537     rc = sqlite3OsWrite(fd, "Hello, World!", 14, offset);
   538    538     sqlite3OsCloseFree(fd);
   539    539     sqlite3_free(zFile);
   540    540     if( rc ){
   541         -    Tcl_AppendResult(interp, "write failed: ", sqlite3TestErrorName(rc), 0);
          541  +    Tcl_AppendResult(interp, "write failed: ", sqlite3ErrName(rc), 0);
   542    542       return TCL_ERROR;
   543    543     }
   544    544     return TCL_OK;
   545    545   }
   546    546   #endif
   547    547   
   548    548   

Changes to src/test3.c.

    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "btreeInt.h"
    18     18   #include "tcl.h"
    19     19   #include <stdlib.h>
    20     20   #include <string.h>
    21     21   
    22         -extern const char *sqlite3TestErrorName(int rc);
           22  +extern const char *sqlite3ErrName(int);
    23     23   
    24     24   /*
    25     25   ** A bogus sqlite3 connection structure for use in the btree
    26     26   ** tests.
    27     27   */
    28     28   static sqlite3 sDb;
    29     29   static int nRefSqlite3 = 0;
................................................................................
    61     61     if( zFilename==0 ) return TCL_ERROR;
    62     62     memcpy(zFilename, argv[1], n+1);
    63     63     zFilename[n+1] = 0;
    64     64     rc = sqlite3BtreeOpen(sDb.pVfs, zFilename, &sDb, &pBt, 0, 
    65     65        SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB);
    66     66     sqlite3_free(zFilename);
    67     67     if( rc!=SQLITE_OK ){
    68         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
           68  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
    69     69       return TCL_ERROR;
    70     70     }
    71     71     sqlite3BtreeSetCacheSize(pBt, nCache);
    72     72     sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pBt);
    73     73     Tcl_AppendResult(interp, zBuf, 0);
    74     74     return TCL_OK;
    75     75   }
................................................................................
    91     91       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    92     92          " ID\"", 0);
    93     93       return TCL_ERROR;
    94     94     }
    95     95     pBt = sqlite3TestTextToPtr(argv[1]);
    96     96     rc = sqlite3BtreeClose(pBt);
    97     97     if( rc!=SQLITE_OK ){
    98         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
           98  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
    99     99       return TCL_ERROR;
   100    100     }
   101    101     nRefSqlite3--;
   102    102     if( nRefSqlite3==0 ){
   103    103       sqlite3_mutex_leave(sDb.mutex);
   104    104       sqlite3_mutex_free(sDb.mutex);
   105    105       sDb.mutex = 0;
................................................................................
   128    128       return TCL_ERROR;
   129    129     }
   130    130     pBt = sqlite3TestTextToPtr(argv[1]);
   131    131     sqlite3BtreeEnter(pBt);
   132    132     rc = sqlite3BtreeBeginTrans(pBt, 1);
   133    133     sqlite3BtreeLeave(pBt);
   134    134     if( rc!=SQLITE_OK ){
   135         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          135  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   136    136       return TCL_ERROR;
   137    137     }
   138    138     return TCL_OK;
   139    139   }
   140    140   
   141    141   /*
   142    142   ** Usage:   btree_pager_stats ID
................................................................................
   222    222   #endif
   223    223     if( rc==SQLITE_OK ){
   224    224       rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, pCur);
   225    225     }
   226    226     sqlite3BtreeLeave(pBt);
   227    227     if( rc ){
   228    228       ckfree((char *)pCur);
   229         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          229  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   230    230       return TCL_ERROR;
   231    231     }
   232    232     sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pCur);
   233    233     Tcl_AppendResult(interp, zBuf, 0);
   234    234     return SQLITE_OK;
   235    235   }
   236    236   
................................................................................
   257    257     pCur = sqlite3TestTextToPtr(argv[1]);
   258    258     pBt = pCur->pBtree;
   259    259     sqlite3BtreeEnter(pBt);
   260    260     rc = sqlite3BtreeCloseCursor(pCur);
   261    261     sqlite3BtreeLeave(pBt);
   262    262     ckfree((char *)pCur);
   263    263     if( rc ){
   264         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          264  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   265    265       return TCL_ERROR;
   266    266     }
   267    267     return SQLITE_OK;
   268    268   }
   269    269   
   270    270   /*
   271    271   ** Usage:   btree_next ID
................................................................................
   291    291       return TCL_ERROR;
   292    292     }
   293    293     pCur = sqlite3TestTextToPtr(argv[1]);
   294    294     sqlite3BtreeEnter(pCur->pBtree);
   295    295     rc = sqlite3BtreeNext(pCur, &res);
   296    296     sqlite3BtreeLeave(pCur->pBtree);
   297    297     if( rc ){
   298         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          298  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   299    299       return TCL_ERROR;
   300    300     }
   301    301     sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   302    302     Tcl_AppendResult(interp, zBuf, 0);
   303    303     return SQLITE_OK;
   304    304   }
   305    305   
................................................................................
   326    326       return TCL_ERROR;
   327    327     }
   328    328     pCur = sqlite3TestTextToPtr(argv[1]);
   329    329     sqlite3BtreeEnter(pCur->pBtree);
   330    330     rc = sqlite3BtreeFirst(pCur, &res);
   331    331     sqlite3BtreeLeave(pCur->pBtree);
   332    332     if( rc ){
   333         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0);
          333  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
   334    334       return TCL_ERROR;
   335    335     }
   336    336     sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   337    337     Tcl_AppendResult(interp, zBuf, 0);
   338    338     return SQLITE_OK;
   339    339   }
   340    340   

Changes to src/test4.c.

    16     16   #if SQLITE_OS_UNIX && SQLITE_THREADSAFE
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <pthread.h>
    20     20   #include <sched.h>
    21     21   #include <ctype.h>
    22     22   
    23         -extern const char *sqlite3TestErrorName(int rc);
           23  +extern const char *sqlite3ErrName(int);
    24     24   
    25     25   /*
    26     26   ** Each thread is controlled by an instance of the following
    27     27   ** structure.
    28     28   */
    29     29   typedef struct Thread Thread;
    30     30   struct Thread {
................................................................................
   370    370     i = parse_thread_id(interp, argv[1]);
   371    371     if( i<0 ) return TCL_ERROR;
   372    372     if( !threadset[i].busy ){
   373    373       Tcl_AppendResult(interp, "no such thread", 0);
   374    374       return TCL_ERROR;
   375    375     }
   376    376     thread_wait(&threadset[i]);
   377         -  zName = sqlite3TestErrorName(threadset[i].rc);
          377  +  zName = sqlite3ErrName(threadset[i].rc);
   378    378     Tcl_AppendResult(interp, zName, 0);
   379    379     return TCL_OK;
   380    380   }
   381    381   
   382    382   /*
   383    383   ** Usage: thread_error  ID
   384    384   **

Changes to src/test7.c.

   372    372       Tcl_AppendResult(interp, "column number out of range", 0);
   373    373       return TCL_ERROR;
   374    374     }
   375    375     Tcl_AppendResult(interp, threadset[i].colv[n], 0);
   376    376     return TCL_OK;
   377    377   }
   378    378   
   379         -extern const char *sqlite3TestErrorName(int rc);
          379  +extern const char *sqlite3ErrName(int);
   380    380   
   381    381   /*
   382    382   ** Usage: client_result  ID
   383    383   **
   384    384   ** Wait on the most recent operation to complete, then return the
   385    385   ** result code from that operation.
   386    386   */
................................................................................
   401    401     i = parse_client_id(interp, argv[1]);
   402    402     if( i<0 ) return TCL_ERROR;
   403    403     if( !threadset[i].busy ){
   404    404       Tcl_AppendResult(interp, "no such thread", 0);
   405    405       return TCL_ERROR;
   406    406     }
   407    407     client_wait(&threadset[i]);
   408         -  zName = sqlite3TestErrorName(threadset[i].rc);
          408  +  zName = sqlite3ErrName(threadset[i].rc);
   409    409     Tcl_AppendResult(interp, zName, 0);
   410    410     return TCL_OK;
   411    411   }
   412    412   
   413    413   /*
   414    414   ** Usage: client_error  ID
   415    415   **

Changes to src/test8.c.

  1296   1296     echoRollbackTo
  1297   1297   };
  1298   1298   
  1299   1299   /*
  1300   1300   ** Decode a pointer to an sqlite3 object.
  1301   1301   */
  1302   1302   extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
  1303         -extern const char *sqlite3TestErrorName(int rc);
         1303  +extern const char *sqlite3ErrName(int);
  1304   1304   
  1305   1305   static void moduleDestroy(void *p){
  1306   1306     sqlite3_free(p);
  1307   1307   }
  1308   1308   
  1309   1309   /*
  1310   1310   ** Register the echo virtual table module.
................................................................................
  1336   1336       pMod = sqlite3_malloc(sizeof(EchoModule));
  1337   1337       pMod->interp = interp;
  1338   1338       rc = sqlite3_create_module_v2(db, "echo_v2", 
  1339   1339           &echoModuleV2, (void*)pMod, moduleDestroy
  1340   1340       );
  1341   1341     }
  1342   1342   
  1343         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1343  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1344   1344     return TCL_OK;
  1345   1345   }
  1346   1346   
  1347   1347   /*
  1348   1348   ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl:
  1349   1349   **
  1350   1350   ** sqlite3_declare_vtab DB SQL

Changes to src/test_async.c.

    19     19   
    20     20   #ifdef SQLITE_ENABLE_ASYNCIO
    21     21   
    22     22   #include "sqlite3async.h"
    23     23   #include "sqlite3.h"
    24     24   #include <assert.h>
    25     25   
    26         -/* From test1.c */
    27         -const char *sqlite3TestErrorName(int);
           26  +/* From main.c */
           27  +extern const char *sqlite3ErrName(int);
    28     28   
    29     29   
    30     30   struct TestAsyncGlobal {
    31     31     int isInstalled;                     /* True when async VFS is installed */
    32     32   } testasync_g = { 0 };
    33     33   
    34     34   TCL_DECLARE_MUTEX(testasync_g_writerMutex);
................................................................................
    56     56     }
    57     57     if( Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){
    58     58       return TCL_ERROR;
    59     59     }
    60     60   
    61     61     rc = sqlite3async_initialize(zParent, isDefault);
    62     62     if( rc!=SQLITE_OK ){
    63         -    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1));
           63  +    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
    64     64       return TCL_ERROR;
    65     65     }
    66     66     return TCL_OK;
    67     67   }
    68     68   
    69     69   /*
    70     70   ** sqlite3async_shutdown
................................................................................
   204    204       rc = sqlite3async_control(
   205    205           eOpt==SQLITEASYNC_HALT ? SQLITEASYNC_GET_HALT :
   206    206           eOpt==SQLITEASYNC_DELAY ? SQLITEASYNC_GET_DELAY :
   207    207           SQLITEASYNC_GET_LOCKFILES, &iVal);
   208    208     }
   209    209   
   210    210     if( rc!=SQLITE_OK ){
   211         -    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1));
          211  +    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
   212    212       return TCL_ERROR;
   213    213     }
   214    214   
   215    215     if( eOpt==SQLITEASYNC_HALT ){
   216    216       Tcl_SetObjResult(interp, Tcl_NewStringObj(az[iVal], -1));
   217    217     }else{
   218    218       Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal));

Changes to src/test_backup.c.

    12     12   ** This file contains test logic for the sqlite3_backup() interface.
    13     13   **
    14     14   */
    15     15   
    16     16   #include "tcl.h"
    17     17   #include <sqlite3.h>
    18     18   #include <assert.h>
           19  +
           20  +/* These functions are implemented in main.c. */
           21  +extern const char *sqlite3ErrName(int);
    19     22   
    20     23   /* These functions are implemented in test1.c. */
    21         -int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);
    22         -const char *sqlite3TestErrorName(int);
           24  +extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);
    23     25   
    24     26   static int backupTestCmd(
    25     27     ClientData clientData, 
    26     28     Tcl_Interp *interp, 
    27     29     int objc,
    28     30     Tcl_Obj *const*objv
    29     31   ){
................................................................................
    66     68         zCmdName = Tcl_GetString(objv[0]);
    67     69         Tcl_GetCommandInfo(interp, zCmdName, &cmdInfo);
    68     70         cmdInfo.deleteProc = 0;
    69     71         Tcl_SetCommandInfo(interp, zCmdName, &cmdInfo);
    70     72         Tcl_DeleteCommand(interp, zCmdName);
    71     73   
    72     74         rc = sqlite3_backup_finish(p);
    73         -      Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
           75  +      Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
    74     76         break;
    75     77       }
    76     78   
    77     79       case BACKUP_STEP: {
    78     80         int nPage;
    79     81         if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &nPage) ){
    80     82           return TCL_ERROR;
    81     83         }
    82     84         rc = sqlite3_backup_step(p, nPage);
    83         -      Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
           85  +      Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
    84     86         break;
    85     87       }
    86     88   
    87     89       case BACKUP_REMAINING:
    88     90         Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_remaining(p)));
    89     91         break;
    90     92   

Changes to src/test_intarray.c.

   274    274   
   275    275   /*
   276    276   ** Routines to encode and decode pointers
   277    277   */
   278    278   extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
   279    279   extern void *sqlite3TestTextToPtr(const char*);
   280    280   extern int sqlite3TestMakePointerStr(Tcl_Interp*, char *zPtr, void*);
   281         -extern const char *sqlite3TestErrorName(int);
          281  +extern const char *sqlite3ErrName(int);
   282    282   
   283    283   /*
   284    284   **    sqlite3_intarray_create  DB  NAME
   285    285   **
   286    286   ** Invoke the sqlite3_intarray_create interface.  A string that becomes
   287    287   ** the first parameter to sqlite3_intarray_bind.
   288    288   */
................................................................................
   305    305     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
   306    306     zName = Tcl_GetString(objv[2]);
   307    307   #ifndef SQLITE_OMIT_VIRTUALTABLE
   308    308     rc = sqlite3_intarray_create(db, zName, &pArray);
   309    309   #endif
   310    310     if( rc!=SQLITE_OK ){
   311    311       assert( pArray==0 );
   312         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), (char*)0);
          312  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), (char*)0);
   313    313       return TCL_ERROR;
   314    314     }
   315    315     sqlite3TestMakePointerStr(interp, zPtr, pArray);
   316    316     Tcl_AppendResult(interp, zPtr, (char*)0);
   317    317     return TCL_OK;
   318    318   }
   319    319   
................................................................................
   348    348     for(i=0; i<n; i++){
   349    349       Tcl_WideInt x = 0;
   350    350       Tcl_GetWideIntFromObj(0, objv[i+2], &x);
   351    351       a[i] = x;
   352    352     }
   353    353     rc = sqlite3_intarray_bind(pArray, n, a, sqlite3_free);
   354    354     if( rc!=SQLITE_OK ){
   355         -    Tcl_AppendResult(interp, sqlite3TestErrorName(rc), (char*)0);
          355  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), (char*)0);
   356    356       return TCL_ERROR;
   357    357     }
   358    358   #endif
   359    359     return TCL_OK;
   360    360   }
   361    361   
   362    362   /*

Changes to src/test_malloc.c.

   230    230     }
   231    231     return rc;
   232    232   }
   233    233   
   234    234   #ifdef SQLITE_TEST
   235    235   
   236    236   /*
   237         -** This function is implemented in test1.c. Returns a pointer to a static
          237  +** This function is implemented in main.c. Returns a pointer to a static
   238    238   ** buffer containing the symbolic SQLite error code that corresponds to
   239    239   ** the least-significant 8-bits of the integer passed as an argument.
   240    240   ** For example:
   241    241   **
   242         -**   sqlite3TestErrorName(1) -> "SQLITE_ERROR"
          242  +**   sqlite3ErrName(1) -> "SQLITE_ERROR"
   243    243   */
   244         -const char *sqlite3TestErrorName(int);
          244  +extern const char *sqlite3ErrName(int);
   245    245   
   246    246   /*
   247    247   ** Transform pointers to text and back again
   248    248   */
   249    249   static void pointerToText(void *p, char *z){
   250    250     static const char zHex[] = "0123456789abcdef";
   251    251     int i, k;
................................................................................
  1068   1068     Tcl_Obj *CONST objv[]
  1069   1069   ){
  1070   1070     int rc;
  1071   1071     int sz, cnt;
  1072   1072     sqlite3 *db;
  1073   1073     int bufid;
  1074   1074     static char azBuf[2][10000];
  1075         -  int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
         1075  +  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
  1076   1076     if( objc!=5 ){
  1077   1077       Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT");
  1078   1078       return TCL_ERROR;
  1079   1079     }
  1080   1080     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  1081   1081     if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR;
  1082   1082     if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR;
................................................................................
  1122   1122       zBuf = 0;
  1123   1123       rc = sqlite3_config(SQLITE_CONFIG_HEAP, (void*)0, 0, 0);
  1124   1124     }else{
  1125   1125       zBuf = realloc(zBuf, nByte);
  1126   1126       rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc);
  1127   1127     }
  1128   1128   
  1129         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1129  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1130   1130     return TCL_OK;
  1131   1131   }
  1132   1132   
  1133   1133   /*
  1134   1134   ** Usage:    sqlite3_config_error  [DB]
  1135   1135   **
  1136   1136   ** Invoke sqlite3_config() or sqlite3_db_config() with invalid
................................................................................
  1139   1139   static int test_config_error(
  1140   1140     void * clientData, 
  1141   1141     Tcl_Interp *interp,
  1142   1142     int objc,
  1143   1143     Tcl_Obj *CONST objv[]
  1144   1144   ){
  1145   1145     sqlite3 *db;
  1146         -  int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
         1146  +  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
  1147   1147   
  1148   1148     if( objc!=2 && objc!=1 ){
  1149   1149       Tcl_WrongNumArgs(interp, 1, objv, "[DB]");
  1150   1150       return TCL_ERROR;
  1151   1151     }
  1152   1152     if( objc==2 ){
  1153   1153       if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
................................................................................
  1188   1188       return TCL_ERROR;
  1189   1189     }
  1190   1190     if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){
  1191   1191       return TCL_ERROR;
  1192   1192     }
  1193   1193   
  1194   1194     rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri);
  1195         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1195  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1196   1196   
  1197   1197     return TCL_OK;
  1198   1198   }
  1199   1199   
  1200   1200   /*
  1201   1201   ** Usage:    sqlite3_config_cis  BOOLEAN
  1202   1202   **
................................................................................
  1217   1217       return TCL_ERROR;
  1218   1218     }
  1219   1219     if( Tcl_GetBooleanFromObj(interp, objv[1], &bUseCis) ){
  1220   1220       return TCL_ERROR;
  1221   1221     }
  1222   1222   
  1223   1223     rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis);
  1224         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1224  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1225   1225   
  1226   1226     return TCL_OK;
  1227   1227   }
  1228   1228   
  1229   1229   /*
  1230   1230   ** Usage:    sqlite3_dump_memsys3  FILENAME
  1231   1231   **           sqlite3_dump_memsys5  FILENAME
................................................................................
  1331   1331     int objc,
  1332   1332     Tcl_Obj *CONST objv[]
  1333   1333   ){
  1334   1334     int rc, iValue, mxValue;
  1335   1335     int i, op, resetFlag;
  1336   1336     const char *zOpName;
  1337   1337     sqlite3 *db;
  1338         -  int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
         1338  +  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
  1339   1339     static const struct {
  1340   1340       const char *zName;
  1341   1341       int op;
  1342   1342     } aOp[] = {
  1343   1343       { "LOOKASIDE_USED",      SQLITE_DBSTATUS_LOOKASIDE_USED      },
  1344   1344       { "CACHE_USED",          SQLITE_DBSTATUS_CACHE_USED          },
  1345   1345       { "SCHEMA_USED",         SQLITE_DBSTATUS_SCHEMA_USED         },
................................................................................
  1397   1397       Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN");
  1398   1398       return TCL_ERROR;
  1399   1399     }
  1400   1400     if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){
  1401   1401       return TCL_ERROR;
  1402   1402     }
  1403   1403     rc = faultsimInstall(isInstall);
  1404         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1404  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1405   1405     return TCL_OK;
  1406   1406   }
  1407   1407   
  1408   1408   /*
  1409   1409   ** sqlite3_install_memsys3
  1410   1410   */
  1411   1411   static int test_install_memsys3(
................................................................................
  1415   1415     Tcl_Obj *CONST objv[]
  1416   1416   ){
  1417   1417     int rc = SQLITE_MISUSE;
  1418   1418   #ifdef SQLITE_ENABLE_MEMSYS3
  1419   1419     const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
  1420   1420     rc = sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetMemsys3());
  1421   1421   #endif
  1422         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
         1422  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
  1423   1423     return TCL_OK;
  1424   1424   }
  1425   1425   
  1426   1426   static int test_vfs_oom_test(
  1427   1427     void * clientData,
  1428   1428     Tcl_Interp *interp,
  1429   1429     int objc,

Changes to src/test_multiplex.c.

  1179   1179     memset(&gMultiplex, 0, sizeof(gMultiplex));
  1180   1180     return SQLITE_OK;
  1181   1181   }
  1182   1182   
  1183   1183   /***************************** Test Code ***********************************/
  1184   1184   #ifdef SQLITE_TEST
  1185   1185   #include <tcl.h>
  1186         -extern const char *sqlite3TestErrorName(int);
         1186  +extern const char *sqlite3ErrName(int);
  1187   1187   
  1188   1188   
  1189   1189   /*
  1190   1190   ** tclcmd: sqlite3_multiplex_initialize NAME MAKEDEFAULT
  1191   1191   */
  1192   1192   static int test_multiplex_initialize(
  1193   1193     void * clientData,
................................................................................
  1208   1208     }
  1209   1209     zName = Tcl_GetString(objv[1]);
  1210   1210     if( Tcl_GetBooleanFromObj(interp, objv[2], &makeDefault) ) return TCL_ERROR;
  1211   1211     if( zName[0]=='\0' ) zName = 0;
  1212   1212   
  1213   1213     /* Call sqlite3_multiplex_initialize() */
  1214   1214     rc = sqlite3_multiplex_initialize(zName, makeDefault);
  1215         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1215  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1216   1216   
  1217   1217     return TCL_OK;
  1218   1218   }
  1219   1219   
  1220   1220   /*
  1221   1221   ** tclcmd: sqlite3_multiplex_shutdown
  1222   1222   */
................................................................................
  1233   1233     if( objc!=1 ){
  1234   1234       Tcl_WrongNumArgs(interp, 1, objv, "");
  1235   1235       return TCL_ERROR;
  1236   1236     }
  1237   1237   
  1238   1238     /* Call sqlite3_multiplex_shutdown() */
  1239   1239     rc = sqlite3_multiplex_shutdown();
  1240         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1240  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1241   1241   
  1242   1242     return TCL_OK;
  1243   1243   }
  1244   1244   
  1245   1245   /*
  1246   1246   ** tclcmd:  sqlite3_multiplex_dump
  1247   1247   */
................................................................................
  1351   1351         break;
  1352   1352       default:
  1353   1353         Tcl_WrongNumArgs(interp, 4, objv, "SUB-COMMAND");
  1354   1354         return TCL_ERROR;
  1355   1355     }
  1356   1356   
  1357   1357     rc = sqlite3_file_control(db, Tcl_GetString(objv[2]), aSub[idx].op, pArg);
  1358         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1358  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1359   1359     return (rc==SQLITE_OK) ? TCL_OK : TCL_ERROR;
  1360   1360   }
  1361   1361   
  1362   1362   /*
  1363   1363   ** This routine registers the custom TCL commands defined in this
  1364   1364   ** module.  This should be the only procedure visible from outside
  1365   1365   ** of this module.

Changes to src/test_mutex.c.

    15     15   #include "tcl.h"
    16     16   #include "sqlite3.h"
    17     17   #include "sqliteInt.h"
    18     18   #include <stdlib.h>
    19     19   #include <assert.h>
    20     20   #include <string.h>
    21     21   
    22         -/* defined in test1.c */
    23         -const char *sqlite3TestErrorName(int);
           22  +/* defined in main.c */
           23  +extern const char *sqlite3ErrName(int);
    24     24   
    25     25   /* A countable mutex */
    26     26   struct sqlite3_mutex {
    27     27     sqlite3_mutex *pReal;
    28     28     int eType;
    29     29   };
    30     30   
................................................................................
   144    144   
   145    145     if( objc!=1 ){
   146    146       Tcl_WrongNumArgs(interp, 1, objv, "");
   147    147       return TCL_ERROR;
   148    148     }
   149    149   
   150    150     rc = sqlite3_shutdown();
   151         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
          151  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
   152    152     return TCL_OK;
   153    153   }
   154    154   
   155    155   /*
   156    156   ** sqlite3_initialize
   157    157   */
   158    158   static int test_initialize(
................................................................................
   165    165   
   166    166     if( objc!=1 ){
   167    167       Tcl_WrongNumArgs(interp, 1, objv, "");
   168    168       return TCL_ERROR;
   169    169     }
   170    170   
   171    171     rc = sqlite3_initialize();
   172         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
          172  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
   173    173     return TCL_OK;
   174    174   }
   175    175   
   176    176   /*
   177    177   ** install_mutex_counters BOOLEAN
   178    178   */
   179    179   static int test_install_mutex_counters(
................................................................................
   226    226       memset(&g.m, 0, sizeof(sqlite3_mutex_methods));
   227    227     }
   228    228   
   229    229     if( rc==SQLITE_OK ){
   230    230       g.isInstalled = isInstall;
   231    231     }
   232    232   
   233         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
          233  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
   234    234     return TCL_OK;
   235    235   }
   236    236   
   237    237   /*
   238    238   ** read_mutex_counters
   239    239   */
   240    240   static int test_read_mutex_counters(
................................................................................
   350    350         return TCL_ERROR;
   351    351       }
   352    352     }else{
   353    353       i = aOpt[i].iValue;
   354    354     }
   355    355   
   356    356     rc = sqlite3_config(i);
   357         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
          357  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
   358    358     return TCL_OK;
   359    359   }
   360    360   
   361    361   static sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){
   362    362     sqlite3 *db;
   363    363     Tcl_CmdInfo info;
   364    364     char *zCmd = Tcl_GetString(pObj);

Changes to src/test_quota.c.

  1321   1321   */
  1322   1322   typedef struct TclQuotaCallback TclQuotaCallback;
  1323   1323   struct TclQuotaCallback {
  1324   1324     Tcl_Interp *interp;    /* Interpreter in which to run the script */
  1325   1325     Tcl_Obj *pScript;      /* Script to be run */
  1326   1326   };
  1327   1327   
  1328         -extern const char *sqlite3TestErrorName(int);
         1328  +extern const char *sqlite3ErrName(int);
  1329   1329   
  1330   1330   
  1331   1331   /*
  1332   1332   ** This is the callback from a quota-over-limit.
  1333   1333   */
  1334   1334   static void tclQuotaCallback(
  1335   1335     const char *zFilename,          /* Name of file whose size increases */
................................................................................
  1403   1403     }
  1404   1404     zName = Tcl_GetString(objv[1]);
  1405   1405     if( Tcl_GetBooleanFromObj(interp, objv[2], &makeDefault) ) return TCL_ERROR;
  1406   1406     if( zName[0]=='\0' ) zName = 0;
  1407   1407   
  1408   1408     /* Call sqlite3_quota_initialize() */
  1409   1409     rc = sqlite3_quota_initialize(zName, makeDefault);
  1410         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1410  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1411   1411   
  1412   1412     return TCL_OK;
  1413   1413   }
  1414   1414   
  1415   1415   /*
  1416   1416   ** tclcmd: sqlite3_quota_shutdown
  1417   1417   */
................................................................................
  1426   1426     if( objc!=1 ){
  1427   1427       Tcl_WrongNumArgs(interp, 1, objv, "");
  1428   1428       return TCL_ERROR;
  1429   1429     }
  1430   1430   
  1431   1431     /* Call sqlite3_quota_shutdown() */
  1432   1432     rc = sqlite3_quota_shutdown();
  1433         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1433  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1434   1434   
  1435   1435     return TCL_OK;
  1436   1436   }
  1437   1437   
  1438   1438   /*
  1439   1439   ** tclcmd: sqlite3_quota_set PATTERN LIMIT SCRIPT
  1440   1440   */
................................................................................
  1481   1481       xDestroy = 0;
  1482   1482       xCallback = 0;
  1483   1483     }
  1484   1484   
  1485   1485     /* Invoke sqlite3_quota_set() */
  1486   1486     rc = sqlite3_quota_set(zPattern, iLimit, xCallback, (void*)p, xDestroy);
  1487   1487   
  1488         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1488  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1489   1489     return TCL_OK;
  1490   1490   }
  1491   1491   
  1492   1492   /*
  1493   1493   ** tclcmd: sqlite3_quota_file FILENAME
  1494   1494   */
  1495   1495   static int test_quota_file(
................................................................................
  1507   1507       return TCL_ERROR;
  1508   1508     }
  1509   1509     zFilename = Tcl_GetString(objv[1]);
  1510   1510   
  1511   1511     /* Invoke sqlite3_quota_file() */
  1512   1512     rc = sqlite3_quota_file(zFilename);
  1513   1513   
  1514         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
         1514  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1515   1515     return TCL_OK;
  1516   1516   }
  1517   1517   
  1518   1518   /*
  1519   1519   ** tclcmd:  sqlite3_quota_dump
  1520   1520   */
  1521   1521   static int test_quota_dump(

Changes to src/test_rtree.c.

   250    250   #ifndef SQLITE_ENABLE_RTREE
   251    251     UNUSED_PARAMETER(clientData);
   252    252     UNUSED_PARAMETER(interp);
   253    253     UNUSED_PARAMETER(objc);
   254    254     UNUSED_PARAMETER(objv);
   255    255   #else
   256    256     extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
   257         -  extern const char *sqlite3TestErrorName(int);
          257  +  extern const char *sqlite3ErrName(int);
   258    258     sqlite3 *db;
   259    259     int rc;
   260    260   
   261    261     if( objc!=2 ){
   262    262       Tcl_WrongNumArgs(interp, 1, objv, "DB");
   263    263       return TCL_ERROR;
   264    264     }
   265    265     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
   266    266     rc = sqlite3_rtree_geometry_callback(db, "cube", cube_geom, (void *)&gHere);
   267         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
          267  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
   268    268   #endif
   269    269     return TCL_OK;
   270    270   }
   271    271   
   272    272   static int register_circle_geom(
   273    273     void * clientData,
   274    274     Tcl_Interp *interp,
................................................................................
   278    278   #ifndef SQLITE_ENABLE_RTREE
   279    279     UNUSED_PARAMETER(clientData);
   280    280     UNUSED_PARAMETER(interp);
   281    281     UNUSED_PARAMETER(objc);
   282    282     UNUSED_PARAMETER(objv);
   283    283   #else
   284    284     extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
   285         -  extern const char *sqlite3TestErrorName(int);
          285  +  extern const char *sqlite3ErrName(int);
   286    286     sqlite3 *db;
   287    287     int rc;
   288    288   
   289    289     if( objc!=2 ){
   290    290       Tcl_WrongNumArgs(interp, 1, objv, "DB");
   291    291       return TCL_ERROR;
   292    292     }
   293    293     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
   294    294     rc = sqlite3_rtree_geometry_callback(db, "circle", circle_geom, 0);
   295         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
          295  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
   296    296   #endif
   297    297     return TCL_OK;
   298    298   }
   299    299   
   300    300   int Sqlitetestrtree_Init(Tcl_Interp *interp){
   301    301     Tcl_CreateObjCommand(interp, "register_cube_geom", register_cube_geom, 0, 0);
   302    302     Tcl_CreateObjCommand(interp, "register_circle_geom",register_circle_geom,0,0);
   303    303     return TCL_OK;
   304    304   }

Changes to src/test_syscall.c.

    74     74   #include <stdlib.h>
    75     75   #include <string.h>
    76     76   #include <assert.h>
    77     77   
    78     78   #include "sqliteInt.h"
    79     79   #if SQLITE_OS_UNIX
    80     80   
    81         -/* From test1.c */
    82         -extern const char *sqlite3TestErrorName(int);
           81  +/* From main.c */
           82  +extern const char *sqlite3ErrName(int);
    83     83   
    84     84   #include <sys/mman.h>
    85     85   #include <sys/types.h>
    86     86   #include <errno.h>
    87     87   
    88     88   static struct TestSyscallGlobal {
    89     89     int bPersist;                   /* 1 for persistent errors, 0 for transient */
................................................................................
   494    494       for(i=0; rc==SQLITE_OK && aSyscall[i].zName; i++){
   495    495         if( strlen(aSyscall[i].zName)!=nFunc ) continue;
   496    496         if( memcmp(aSyscall[i].zName, zFunc, nFunc) ) continue;
   497    497         aSyscall[i].xOrig = 0;
   498    498       }
   499    499     }
   500    500     if( rc!=SQLITE_OK ){
   501         -    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1));
          501  +    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
   502    502       return TCL_ERROR;
   503    503     }
   504    504   
   505    505     Tcl_ResetResult(interp);
   506    506     return TCL_OK;
   507    507   }
   508    508   

Changes to src/test_thread.c.

    56     56   #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)
    57     57   static Tcl_ObjCmdProc blocking_step_proc;
    58     58   static Tcl_ObjCmdProc blocking_prepare_v2_proc;
    59     59   #endif
    60     60   int Sqlitetest1_Init(Tcl_Interp *);
    61     61   int Sqlite3_Init(Tcl_Interp *);
    62     62   
           63  +/* Functions from main.c */
           64  +extern const char *sqlite3ErrName(int);
           65  +
    63     66   /* Functions from test1.c */
    64         -void *sqlite3TestTextToPtr(const char *);
    65         -const char *sqlite3TestErrorName(int);
    66         -int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);
    67         -int sqlite3TestMakePointerStr(Tcl_Interp *, char *, void *);
    68         -int sqlite3TestErrCode(Tcl_Interp *, sqlite3 *, int);
           67  +extern void *sqlite3TestTextToPtr(const char *);
           68  +extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);
           69  +extern int sqlite3TestMakePointerStr(Tcl_Interp *, char *, void *);
           70  +extern int sqlite3TestErrCode(Tcl_Interp *, sqlite3 *, int);
    69     71   
    70     72   /*
    71     73   ** Handler for events of type EvalEvent.
    72     74   */
    73     75   static int tclScriptEvent(Tcl_Event *evPtr, int flags){
    74     76     int rc;
    75     77     EvalEvent *p = (EvalEvent *)evPtr;
................................................................................
   555    557       Tcl_WrongNumArgs(interp, 1, objv, "STMT");
   556    558       return TCL_ERROR;
   557    559     }
   558    560   
   559    561     pStmt = (sqlite3_stmt*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
   560    562     rc = sqlite3_blocking_step(pStmt);
   561    563   
   562         -  Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), 0);
          564  +  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), 0);
   563    565     return TCL_OK;
   564    566   }
   565    567   
   566    568   /*
   567    569   ** Usage: sqlite3_blocking_prepare_v2 DB sql bytes ?tailvar?
   568    570   ** Usage: sqlite3_nonblocking_prepare_v2 DB sql bytes ?tailvar?
   569    571   */
................................................................................
   602    604       if( bytes>=0 ){
   603    605         bytes = bytes - (zTail-zSql);
   604    606       }
   605    607       Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0);
   606    608     }
   607    609     if( rc!=SQLITE_OK ){
   608    610       assert( pStmt==0 );
   609         -    sprintf(zBuf, "%s ", (char *)sqlite3TestErrorName(rc));
          611  +    sprintf(zBuf, "%s ", (char *)sqlite3ErrName(rc));
   610    612       Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0);
   611    613       return TCL_ERROR;
   612    614     }
   613    615   
   614    616     if( pStmt ){
   615    617       if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;
   616    618       Tcl_AppendResult(interp, zBuf, 0);