[litetree] Do not select a random ROWID when inserting a row
@@ -89820,14 +89820,16 @@ case OP_NewRowid: { /* out2 */
** it finds one that is not previously used. */
assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
** an AUTOINCREMENT table. */
- cnt = 0;
+ rc = sqlite3BtreeCount(pC->uc.pCursor, &v);
+ if( rc ) goto abort_due_to_error;
+ cnt = 0; res = 0;
do{
- sqlite3_randomness(sizeof(v), &v);
- v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */
+ if( v==MAX_ROWID ) break; /* Ensure that v is greater than zero */
+ v++;
}while( ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,
0, &res))==SQLITE_OK)
&& (res==0)
- && (++cnt<100));
+ && (++cnt<1000));
if( rc ) goto abort_due_to_error;
if( res==0 ){
rc = SQLITE_FULL; /* IMP: R-38219-53002 */
