/ Check-in [0e918c54]
Login

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

Overview
Comment:Add evidence marks associated with autoincrement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e918c54893c361fb005295847f89aadcbfae35d
User & Date: drh 2010-01-01 18:57:48
Context
2010-01-02
03:21
Add a new sqlite3_test_control() verb that facilitates testing that all keywords are shown in the documentation. (Two keywords were found to be missing while testing the change.) check-in: d3cdc4b1 user: drh tags: trunk
2010-01-01
18:57
Add evidence marks associated with autoincrement. check-in: 0e918c54 user: drh tags: trunk
2009-12-31
20:35
Add comments and an assert() to help clarify the operation of the sqlite3VdbeList() routine used to implement EXPLAIN. check-in: e1ccdb93 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

   249    249               if( iCol==pTab->iPKey ){
   250    250                 iCol = -1;
   251    251               }
   252    252               break;
   253    253             }
   254    254           }
   255    255           if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){
   256         -          iCol = -1;
          256  +          iCol = -1;        /* IMP: R-44911-55124 */
   257    257           }
   258    258           if( iCol<pTab->nCol ){
   259    259             cnt++;
   260    260             if( iCol<0 ){
   261    261               pExpr->affinity = SQLITE_AFF_INTEGER;
   262    262             }else if( pExpr->iTable==0 ){
   263    263               testcase( iCol==31 );
................................................................................
   277    277   #endif /* !defined(SQLITE_OMIT_TRIGGER) */
   278    278   
   279    279       /*
   280    280       ** Perhaps the name is a reference to the ROWID
   281    281       */
   282    282       if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
   283    283         cnt = 1;
   284         -      pExpr->iColumn = -1;
          284  +      pExpr->iColumn = -1;     /* IMP: R-44911-55124 */
   285    285         pExpr->affinity = SQLITE_AFF_INTEGER;
   286    286       }
   287    287   
   288    288       /*
   289    289       ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
   290    290       ** might refer to an result-set alias.  This happens, for example, when
   291    291       ** we are resolving names in the WHERE clause of the following command:

Changes to src/vdbe.c.

  3659   3659         v = sqlite3BtreeGetCachedRowid(pC->pCursor);
  3660   3660         if( v==0 ){
  3661   3661           rc = sqlite3BtreeLast(pC->pCursor, &res);
  3662   3662           if( rc!=SQLITE_OK ){
  3663   3663             goto abort_due_to_error;
  3664   3664           }
  3665   3665           if( res ){
  3666         -          v = 1;
         3666  +          v = 1;   /* IMP: R-61914-48074 */
  3667   3667           }else{
  3668   3668             assert( sqlite3BtreeCursorIsValid(pC->pCursor) );
  3669   3669             rc = sqlite3BtreeKeySize(pC->pCursor, &v);
  3670   3670             assert( rc==SQLITE_OK );   /* Cannot fail following BtreeLast() */
  3671   3671             if( v==MAX_ROWID ){
  3672   3672               pC->useRandomRowid = 1;
  3673   3673             }else{
  3674         -            v++;
         3674  +            v++;   /* IMP: R-29538-34987 */
  3675   3675             }
  3676   3676           }
  3677   3677         }
  3678   3678   
  3679   3679   #ifndef SQLITE_OMIT_AUTOINCREMENT
  3680   3680         if( pOp->p3 ){
  3681   3681           /* Assert that P3 is a valid memory cell. */
................................................................................
  3691   3691             pMem = &aMem[pOp->p3];
  3692   3692           }
  3693   3693   
  3694   3694           REGISTER_TRACE(pOp->p3, pMem);
  3695   3695           sqlite3VdbeMemIntegerify(pMem);
  3696   3696           assert( (pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */
  3697   3697           if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
  3698         -          rc = SQLITE_FULL;
         3698  +          rc = SQLITE_FULL;   /* IMP: R-12275-61338 */
  3699   3699             goto abort_due_to_error;
  3700   3700           }
  3701   3701           if( v<pMem->u.i+1 ){
  3702   3702             v = pMem->u.i + 1;
  3703   3703           }
  3704   3704           pMem->u.i = v;
  3705   3705         }
  3706   3706   #endif
  3707   3707   
  3708   3708         sqlite3BtreeSetCachedRowid(pC->pCursor, v<MAX_ROWID ? v+1 : 0);
  3709   3709       }
  3710   3710       if( pC->useRandomRowid ){
         3711  +      /* IMPLEMENTATION-OF: R-48598-02938 If the largest ROWID is equal to the
         3712  +      ** largest possible integer (9223372036854775807) then the database
         3713  +      ** engine starts picking candidate ROWIDs at random until it finds one
         3714  +      ** that is not previously used.
         3715  +      */
  3711   3716         assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is
  3712   3717                                ** an AUTOINCREMENT table. */
  3713   3718         v = db->lastRowid;
  3714   3719         cnt = 0;
  3715   3720         do{
  3716   3721           if( cnt==0 && (v&0xffffff)==v ){
  3717   3722             v++;
................................................................................
  3719   3724             sqlite3_randomness(sizeof(v), &v);
  3720   3725             if( cnt<5 ) v &= 0xffffff;
  3721   3726           }
  3722   3727           rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)v, 0, &res);
  3723   3728           cnt++;
  3724   3729         }while( cnt<100 && rc==SQLITE_OK && res==0 );
  3725   3730         if( rc==SQLITE_OK && res==0 ){
  3726         -        rc = SQLITE_FULL;
         3731  +        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */
  3727   3732           goto abort_due_to_error;
  3728   3733         }
  3729   3734       }
  3730   3735       pC->rowidIsValid = 0;
  3731   3736       pC->deferredMoveto = 0;
  3732   3737       pC->cacheStatus = CACHE_STALE;
  3733   3738     }