/ Check-in [49e5d11d]
Login

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

Overview
Comment:Change VACUUM so that it preserves ROWID values.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:49e5d11d463de078c2b8a963f5ed436210937e6dfddf06942132db9ec685bfd8
User & Date: drh 2019-02-07 19:07:11
Context
2019-02-08
04:15
Do not do the optimization that attempts to pull expression values from an index on that expression when processing a multi-index OR (see check-in [a47efb7c8520a0111]) because the expression transformations that are applied become invalid when the processing moves off of the current index and on to the next index. Fix for ticket [4e8e4857d32d401f]. check-in: 440a7cda user: drh tags: trunk
2019-02-07
19:28
Pull in the change that causes VACUUM to preserve rowid values. check-in: c9af2f71 user: drh tags: apple-osx
19:07
Change VACUUM so that it preserves ROWID values. check-in: 49e5d11d user: drh tags: trunk
17:02
Version 3.27.0 check-in: 97744701 user: drh tags: trunk, release, version-3.27.0
15:09
Experimental change to VACUUM so that it preserves existing ROWID values. Closed-Leaf check-in: f264015f user: drh tags: vacuum-preserves-rowid
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

  2343   2343         addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
  2344   2344         sqlite3VdbeVerifyAbortable(v, onError);
  2345   2345         addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);
  2346   2346         VdbeCoverage(v);
  2347   2347         sqlite3RowidConstraint(pParse, onError, pDest);
  2348   2348         sqlite3VdbeJumpHere(v, addr2);
  2349   2349         autoIncStep(pParse, regAutoinc, regRowid);
  2350         -    }else if( pDest->pIndex==0 ){
         2350  +    }else if( pDest->pIndex==0 && !(db->mDbFlags & DBFLAG_Vacuum) ){
  2351   2351         addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);
  2352   2352       }else{
  2353   2353         addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
  2354   2354         assert( (pDest->tabFlags & TF_Autoincrement)==0 );
  2355   2355       }
  2356   2356       sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);
  2357   2357       if( db->mDbFlags & DBFLAG_Vacuum ){

Changes to test/e_vacuum.test.

   215    215   # entries in any tables that do not have an explicit INTEGER PRIMARY
   216    216   # KEY.
   217    217   #
   218    218   #   Tests e_vacuum-3.1.1 - 3.1.2 demonstrate that rowids can change when
   219    219   #   a database is VACUUMed. Tests e_vacuum-3.1.3 - 3.1.4 show that adding
   220    220   #   an INTEGER PRIMARY KEY column to a table stops this from happening.
   221    221   #
          222  +#   Update 2019-01-07:  Rowids are now preserved by VACUUM.
          223  +#
   222    224   do_execsql_test e_vacuum-3.1.1 {
   223    225     CREATE TABLE t4(x);
   224    226     INSERT INTO t4(x) VALUES('x');
   225    227     INSERT INTO t4(x) VALUES('y');
   226    228     INSERT INTO t4(x) VALUES('z');
   227    229     DELETE FROM t4 WHERE x = 'y';
   228    230     SELECT rowid, x FROM t4;
   229    231   } {1 x 3 z}
   230    232   do_execsql_test e_vacuum-3.1.2 {
   231    233     VACUUM;
   232    234     SELECT rowid, x FROM t4;
   233         -} {1 x 2 z}
          235  +} {1 x 3 z}
          236  +# Was: {1 x 2 z}
   234    237   
   235    238   do_execsql_test e_vacuum-3.1.3 {
   236    239     CREATE TABLE t5(x, y INTEGER PRIMARY KEY);
   237    240     INSERT INTO t5(x) VALUES('x');
   238    241     INSERT INTO t5(x) VALUES('y');
   239    242     INSERT INTO t5(x) VALUES('z');
   240    243     DELETE FROM t5 WHERE x = 'y';