/ Check-in [d8d1c91e]
Login

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

Overview
Comment:Add a temporary sqlite2BtreeKeyCompare() function to help get regression tests passing again. (CVS 1332)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d8d1c91e55f24d17233414facaa03136b3b320d5
User & Date: danielk1977 2004-05-09 23:23:57
Context
2004-05-10
01:17
Change some code that assumes the root-page of sqlite_master is 2 (it is now 1) (CVS 1333) check-in: 37ae528f user: danielk1977 tags: trunk
2004-05-09
23:23
Add a temporary sqlite2BtreeKeyCompare() function to help get regression tests passing again. (CVS 1332) check-in: d8d1c91e user: danielk1977 tags: trunk
20:40
More btree.c bug fixing. It's getting closer but still not there yet. Move obsolete test scripts into the attic. (CVS 1331) check-in: 9379c7c9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.h.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This header file defines the interface that the sqlite B-Tree file
    13     13   ** subsystem.  See comments in the source code for a detailed description
    14     14   ** of what each interface routine does.
    15     15   **
    16         -** @(#) $Id: btree.h,v 1.42 2004/05/09 00:40:52 drh Exp $
           16  +** @(#) $Id: btree.h,v 1.43 2004/05/09 23:23:57 danielk1977 Exp $
    17     17   */
    18     18   #ifndef _BTREE_H_
    19     19   #define _BTREE_H_
    20     20   
    21     21   /* TODO: This definition is just included so other modules compile. It
    22     22   ** needs to be revisited.
    23     23   */
................................................................................
    83     83   int sqlite3BtreeEof(BtCursor*);
    84     84   int sqlite3BtreePrevious(BtCursor*, int *pRes);
    85     85   int sqlite3BtreeKeySize(BtCursor*, u64 *pSize);
    86     86   int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
    87     87   void *sqlite3BtreeKeyFetch(BtCursor*);
    88     88   int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
    89     89   int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
    90         -int sqlite3BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
    91     90   
    92     91   char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
    93     92   struct Pager *sqlite3BtreePager(Btree*);
    94     93   
    95     94   #ifdef SQLITE_TEST
    96     95   int sqlite3BtreeCursorInfo(BtCursor*, int*);
    97     96   void sqlite3BtreeCursorList(Btree*);
    98     97   int sqlite3BtreeFlags(BtCursor*);
    99     98   int sqlite3BtreePageDump(Btree*, int, int recursive);
   100     99   #endif
   101    100   
   102    101   
   103    102   #endif /* _BTREE_H_ */

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.270 2004/05/08 10:56:12 drh Exp $
           46  +** $Id: vdbe.c,v 1.271 2004/05/09 23:23:58 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  2740   2740       if( res<0 ){
  2741   2741         rc = sqlite3BtreeNext(pCrsr, &res);
  2742   2742         if( res ){
  2743   2743           pc = pOp->p2 - 1;
  2744   2744           break;
  2745   2745         }
  2746   2746       }
  2747         -/******** FIX ME
  2748         -    rc = sqlite3BtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &res); 
  2749         -*/rc=SQLITE_INTERNAL;
         2747  +    /* FIX ME - the sqlite2BtreeKeyCompare() function is a temporary hack */
         2748  +    rc = sqlite2BtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &res); 
  2750   2749       if( rc!=SQLITE_OK ) goto abort_due_to_error;
  2751   2750       if( res>0 ){
  2752   2751         pc = pOp->p2 - 1;
  2753   2752         break;
  2754   2753       }
  2755   2754   
  2756   2755       /* At this point, pCrsr is pointing to an entry in P1 where all but
................................................................................
  3470   3469         assert( nKey >= 4 );
  3471   3470         rc = sqlite3BtreeMoveto(pCrsr, zKey, nKey-4, &res);
  3472   3471         if( rc!=SQLITE_OK ) goto abort_due_to_error;
  3473   3472         while( res!=0 ){
  3474   3473           int c;
  3475   3474           /* TODO: sqlite3BtreeKeySize(pCrsr, &n); */
  3476   3475           if( n==nKey
  3477         -/***** FIX ME
  3478         -            && sqlite3BtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &c)==SQLITE_OK
  3479         -*/
         3476  +     /* FIX ME - the sqlite2BtreeKeyCompare() function is a temporary hack */
         3477  +            && sqlite2BtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &c)==SQLITE_OK
  3480   3478              && c==0
  3481   3479           ){
  3482   3480             rc = SQLITE_CONSTRAINT;
  3483   3481             if( pOp->p3 && pOp->p3[0] ){
  3484   3482               sqlite3SetString(&p->zErrMsg, pOp->p3, (char*)0);
  3485   3483             }
  3486   3484             goto abort_due_to_error;
................................................................................
  3593   3591     assert( i>=0 && i<p->nCursor );
  3594   3592     assert( pTos>=p->aStack );
  3595   3593     if( (pCrsr = p->aCsr[i].pCursor)!=0 ){
  3596   3594       int res, rc;
  3597   3595    
  3598   3596       Stringify(pTos);
  3599   3597       assert( p->aCsr[i].deferredMoveto==0 );
  3600         -/****** FIX ME
  3601         -    rc = sqlite3BtreeKeyCompare(pCrsr, pTos->z, pTos->n, 4, &res);
  3602         -*/rc=SQLITE_INTERNAL;
         3598  +    /* FIX ME - the sqlite2BtreeKeyCompare() function is a temporary hack */
         3599  +    rc = sqlite2BtreeKeyCompare(pCrsr, pTos->z, pTos->n, 4, &res);
  3603   3600       if( rc!=SQLITE_OK ){
  3604   3601         break;
  3605   3602       }
  3606   3603       if( pOp->opcode==OP_IdxLT ){
  3607   3604         res = -res;
  3608   3605       }else if( pOp->opcode==OP_IdxGE ){
  3609   3606         res++;

Changes to src/vdbeInt.h.

   297    297   void sqlite3VdbeKeylistFree(Keylist*);
   298    298   void sqliteVdbePopStack(Vdbe*,int);
   299    299   int sqlite3VdbeCursorMoveto(Cursor*);
   300    300   int sqlite3VdbeByteSwap(int);
   301    301   #if !defined(NDEBUG) || defined(VDBE_PROFILE)
   302    302   void sqlite3VdbePrintOp(FILE*, int, Op*);
   303    303   #endif
          304  +
          305  +int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
   304    306   
   305    307   
   306    308   

Changes to src/vdbeaux.c.

  1056   1056       }
  1057   1057       sqlite_search_count++;
  1058   1058       p->deferredMoveto = 0;
  1059   1059     }
  1060   1060     return SQLITE_OK;
  1061   1061   }
  1062   1062   
         1063  +/*
         1064  +** FIX ME
         1065  +**
         1066  +** This function is included temporarily so that regression tests have
         1067  +** a chance of passing. It always uses memcmp().
         1068  +*/
         1069  +int sqlite2BtreeKeyCompare(
         1070  +  BtCursor *pCur,       /* Pointer to entry to compare against */
         1071  +  const void *pKey,     /* Key to compare against entry that pCur points to */
         1072  +  int nKey,             /* Number of bytes in pKey */
         1073  +  int nIgnore,          /* Ignore this many bytes at the end of pCur */
         1074  +  int *pResult          /* Write the result here */
         1075  +){
         1076  +  void *pCellKey;
         1077  +  u64 nCellKey;
         1078  +  int rc;
         1079  +
         1080  +  sqlite3BtreeKeySize(pCur, &nCellKey);
         1081  +  nCellKey = nCellKey - nIgnore;
         1082  +  if( nCellKey<=0 ){
         1083  +    *pResult = 0;
         1084  +    return SQLITE_OK;
         1085  +  }
         1086  +
         1087  +  pCellKey = sqlite3BtreeKeyFetch(pCur);
         1088  +  if( pCellKey ){
         1089  +    *pResult = memcmp(pCellKey, pKey, nKey>nCellKey?nCellKey:nKey);
         1090  +    return SQLITE_OK;
         1091  +  }
         1092  +
         1093  +  pCellKey = sqliteMalloc( nCellKey );
         1094  +  if( pCellKey==0 ) return SQLITE_NOMEM;
         1095  +
         1096  +  rc = sqlite3BtreeKey(pCur, 0, nCellKey, pCellKey);
         1097  +  *pResult = memcmp(pCellKey, pKey, nKey>nCellKey?nCellKey:nKey);
         1098  +  sqliteFree(pCellKey);
         1099  +
         1100  +  return rc;
         1101  +}
  1063   1102   
  1064   1103   /*
  1065   1104   ** The following is the comparison function for (non-integer)
  1066   1105   ** keys in the btrees.  This function returns negative, zero, or
  1067   1106   ** positive if the first key is less than, equal to, or greater than
  1068   1107   ** the second.
  1069   1108   **