/ Check-in [4b608b62]
Login

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

Overview
Comment:Add requirements marks on the built-in collating functions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4b608b62ac8d4eafdb76192b3b5db272332a4bfd
User & Date: drh 2014-11-20 19:22:26
Context
2014-11-20
23:03
Updates to requirements tags on the mutex documentation. check-in: fcf8b7e4 user: drh tags: trunk
19:22
Add requirements marks on the built-in collating functions. check-in: 4b608b62 user: drh tags: trunk
15:30
Ensure that when the number of cells on a page drops to zero that the freelist and fragment counter are both cleared. Also add evidence marks corresponding to file-format documentation. check-in: ef9fbc08 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

   769    769   static int binCollFunc(
   770    770     void *padFlag,
   771    771     int nKey1, const void *pKey1,
   772    772     int nKey2, const void *pKey2
   773    773   ){
   774    774     int rc, n;
   775    775     n = nKey1<nKey2 ? nKey1 : nKey2;
          776  +  /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares
          777  +  ** strings byte by byte using the memcmp() function from the standard C
          778  +  ** library. */
   776    779     rc = memcmp(pKey1, pKey2, n);
   777    780     if( rc==0 ){
   778    781       if( padFlag
   779    782        && allSpaces(((char*)pKey1)+n, nKey1-n)
   780    783        && allSpaces(((char*)pKey2)+n, nKey2-n)
   781    784       ){
   782         -      /* Leave rc unchanged at 0 */
          785  +      /* EVIDENCE-OF: R-31624-24737 RTRIM is like BINARY except that extra
          786  +      ** spaces at the end of either string do not change the result. In other
          787  +      ** words, strings will compare equal to one another as long as they
          788  +      ** differ only in the number of spaces at the end.
          789  +      */
   783    790       }else{
   784    791         rc = nKey1 - nKey2;
   785    792       }
   786    793     }
   787    794     return rc;
   788    795   }
   789    796   
................................................................................
  2726   2733   #ifndef SQLITE_OMIT_VIRTUALTABLE
  2727   2734     sqlite3HashInit(&db->aModule);
  2728   2735   #endif
  2729   2736   
  2730   2737     /* Add the default collation sequence BINARY. BINARY works for both UTF-8
  2731   2738     ** and UTF-16, so add a version for each to avoid any unnecessary
  2732   2739     ** conversions. The only error that can occur here is a malloc() failure.
         2740  +  **
         2741  +  ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating
         2742  +  ** functions:
  2733   2743     */
  2734   2744     createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0);
  2735   2745     createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0);
  2736   2746     createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0);
         2747  +  createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
  2737   2748     createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
  2738   2749     if( db->mallocFailed ){
  2739   2750       goto opendb_out;
  2740   2751     }
         2752  +  /* EVIDENCE-OF: R-08308-17224 The default collating function for all
         2753  +  ** strings is BINARY. 
         2754  +  */
  2741   2755     db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
  2742   2756     assert( db->pDfltColl!=0 );
  2743   2757   
  2744         -  /* Also add a UTF-8 case-insensitive collation sequence. */
  2745         -  createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
  2746         -
  2747   2758     /* Parse the filename/URI argument. */
  2748   2759     db->openFlags = flags;
  2749   2760     rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
  2750   2761     if( rc!=SQLITE_OK ){
  2751   2762       if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
  2752   2763       sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
  2753   2764       sqlite3_free(zErrMsg);