/ Check-in [de697251]
Login

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

Overview
Comment:Capture BTREE_FORDELETE test cases that were mistakenly omitted from the previous merge.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: de6972515f65c5cf5da7cfdf876a05718299e9b8
User & Date: drh 2015-10-26 18:01:36
Context
2015-10-26
20:39
Add new extended error code SQLITE_IOERR_AUTH. check-in: b4e70dd0 user: dan tags: trunk
20:11
Merge the BTREE_FORDELETE enhancement with this branch. check-in: 20da0849 user: dan tags: cursor-hints
18:01
Capture BTREE_FORDELETE test cases that were mistakenly omitted from the previous merge. check-in: de697251 user: drh tags: trunk
17:50
Provide the BTREE_FORDELETE flag to sqlite3BtreeCursor() if the cursor will be used only for deletions and seeking. check-in: 871b1c78 user: drh tags: trunk
16:34
Fix an uninitialized variable problem in the test code added by the previous commit. Closed-Leaf check-in: 7849662e user: dan tags: btree-fordelete-flag
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test3.c.

   215    215     if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
   216    216     if( Tcl_GetBoolean(interp, argv[3], &wrFlag) ) return TCL_ERROR;
   217    217     if( wrFlag ) wrFlag = BTREE_WRCSR;
   218    218     pCur = (BtCursor *)ckalloc(sqlite3BtreeCursorSize());
   219    219     memset(pCur, 0, sqlite3BtreeCursorSize());
   220    220     sqlite3BtreeEnter(pBt);
   221    221   #ifndef SQLITE_OMIT_SHARED_CACHE
   222         -  rc = sqlite3BtreeLockTable(pBt, iTable, wrFlag);
          222  +  rc = sqlite3BtreeLockTable(pBt, iTable, !!wrFlag);
   223    223   #endif
   224    224     if( rc==SQLITE_OK ){
   225    225       rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, pCur);
   226    226     }
   227    227     sqlite3BtreeLeave(pBt);
   228    228     if( rc ){
   229    229       ckfree((char *)pCur);
................................................................................
   595    595     sqlite3BtreeEnter(pBt);
   596    596     sqlite3BtreeSetCacheSize(pBt, nCache);
   597    597     sqlite3BtreeLeave(pBt);
   598    598     sqlite3_mutex_leave(pBt->db->mutex);
   599    599     return TCL_OK;
   600    600   }      
   601    601   
          602  +/*
          603  +** usage:   btree_insert CSR ?KEY? VALUE
          604  +**
          605  +** Set the size of the cache used by btree $ID.
          606  +*/
          607  +static int btree_insert(
          608  +  ClientData clientData,
          609  +  Tcl_Interp *interp,
          610  +  int objc,
          611  +  Tcl_Obj *const objv[]
          612  +){
          613  +  BtCursor *pCur;
          614  +  int rc;
          615  +  void *pKey = 0;
          616  +  int nKey = 0;
          617  +  void *pData = 0;
          618  +  int nData = 0;
          619  +
          620  +  if( objc!=4 && objc!=3 ){
          621  +    Tcl_WrongNumArgs(interp, 1, objv, "?-intkey? CSR KEY VALUE");
          622  +    return TCL_ERROR;
          623  +  }
          624  +
          625  +  if( objc==4 ){
          626  +    if( Tcl_GetIntFromObj(interp, objv[2], &nKey) ) return TCL_ERROR;
          627  +    pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &nData);
          628  +  }else{
          629  +    pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &nKey);
          630  +  }
          631  +  pCur = (BtCursor*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
          632  +
          633  +  sqlite3BtreeEnter(pCur->pBtree);
          634  +  rc = sqlite3BtreeInsert(pCur, pKey, nKey, pData, nData, 0, 0, 0);
          635  +  sqlite3BtreeLeave(pCur->pBtree);
          636  +
          637  +  Tcl_ResetResult(interp);
          638  +  if( rc ){
          639  +    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
          640  +    return TCL_ERROR;
          641  +  }
          642  +  return TCL_OK;
          643  +}
   602    644   
   603    645   
   604    646   /*
   605    647   ** Register commands with the TCL interpreter.
   606    648   */
   607    649   int Sqlitetest3_Init(Tcl_Interp *interp){
   608    650     static struct {
................................................................................
   625    667        { "btree_set_cache_size",     (Tcl_CmdProc*)btree_set_cache_size     }
   626    668     };
   627    669     int i;
   628    670   
   629    671     for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
   630    672       Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
   631    673     }
          674  +
          675  +  Tcl_CreateObjCommand(interp, "btree_insert", btree_insert, 0, 0);
   632    676   
   633    677     return TCL_OK;
   634    678   }

Changes to test/fordelete.test.

    72     72     2 { DELETE FROM t2 WHERE a=? AND +b=?} { t2 t2a t2b* t2c* }
    73     73     3 { DELETE FROM t2 WHERE a=? OR b=?}   { t2 t2a* t2b* t2c* }
    74     74     4 { DELETE FROM t2 WHERE +a=? }        { t2 t2a* t2b* t2c* }
    75     75     5 { DELETE FROM t2 WHERE rowid=? }     { t2 t2a* t2b* t2c* }
    76     76   } {
    77     77     do_adp_test 2.$tn $sql $res
    78     78   }
    79         - 
           79  +
           80  +#-------------------------------------------------------------------------
           81  +# Test that a record that consists of the bytes:
           82  +#
           83  +#   0x01 0x00
           84  +#
           85  +# is interpreted by OP_Column as a vector of NULL values (assuming the 
           86  +# default column values are NULL). Also test that:
           87  +#
           88  +#   0x00
           89  +#
           90  +# is handled in the same way.
           91  +#
           92  +do_execsql_test 3.0 {
           93  +  CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c, d);
           94  +  CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c, d);
           95  +}
           96  +
           97  +do_test 3.1 {
           98  +  set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x1' }]
           99  +  db eval { 
          100  +    BEGIN IMMEDIATE;
          101  +  }
          102  +  set bt [btree_from_db db]
          103  +  set csr [btree_cursor $bt $root 1]
          104  +  btree_insert $csr 5 "\000"
          105  +  btree_close_cursor $csr
          106  +  db eval { COMMIT }
          107  +
          108  +  db eval {
          109  +    SELECT * FROM x1;
          110  +  }
          111  +} {5 {} {} {}}
          112  +
          113  +do_test 3.2 {
          114  +  set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x2' }]
          115  +  db eval { 
          116  +    BEGIN IMMEDIATE;
          117  +  }
          118  +  set bt [btree_from_db db]
          119  +  set csr [btree_cursor $bt $root 1]
          120  +  btree_insert $csr 6 "\000"
          121  +  btree_close_cursor $csr
          122  +  db eval { COMMIT }
          123  +
          124  +  db eval {
          125  +    SELECT * FROM x2;
          126  +  }
          127  +} {6 {} {} {}}
          128  +
    80    129   finish_test
          130  +