/ Check-in [13995756]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix a problem with VACUUM and __hidden__ columns.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 13995756ad8b80568aa2f74387788a8cab1123ef
User & Date: dan 2015-11-19 18:09:05
Context
2015-11-19
18:11
Fix problems with the way the IsHiddenColumn() macro is defined. check-in: 126b998c user: drh tags: trunk
18:09
Fix a problem with VACUUM and __hidden__ columns. check-in: 13995756 user: dan tags: trunk
17:55
When manifesting a view as part of an DELETE or UPDATE, be sure to include the hidden columns in the manifestation. check-in: 28df5dc4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

  1906   1906     if( pDest->iPKey!=pSrc->iPKey ){
  1907   1907       return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */
  1908   1908     }
  1909   1909     for(i=0; i<pDest->nCol; i++){
  1910   1910       Column *pDestCol = &pDest->aCol[i];
  1911   1911       Column *pSrcCol = &pSrc->aCol[i];
  1912   1912   #ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
  1913         -    if( (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN ){
         1913  +    if( (db->flags & SQLITE_Vacuum)==0 
         1914  +     && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN 
         1915  +    ){
  1914   1916         return 0;    /* Neither table may have __hidden__ columns */
  1915   1917       }
  1916   1918   #endif
  1917   1919       if( pDestCol->affinity!=pSrcCol->affinity ){
  1918   1920         return 0;    /* Affinity must be the same on all columns */
  1919   1921       }
  1920   1922       if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){

Changes to test/hidden.test.

    94     94     SELECT * FROM t5;
    95     95   } {2 3   5 6   8 9}
    96     96   
    97     97   do_execsql_test 3.2.3 {
    98     98     SELECT __hidden__a FROM t5;
    99     99   } {{} {} {}}
   100    100   
          101  +
          102  +do_execsql_test 3.3.1 {
          103  +  CREATE TABLE t5a(a, b, __hidden__c);
          104  +  CREATE TABLE t6a(a, b, __hidden__c);
          105  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(1, 2, 3);
          106  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(4, 5, 6);
          107  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(7, 8, 9);
          108  +}
          109  +
          110  +do_execsql_test 3.3.2 {
          111  +  INSERT INTO t5a SELECT * FROM t6a;
          112  +  SELECT * FROM t5a;
          113  +} {1 2   4 5   7 8}
          114  +
          115  +do_execsql_test 3.3.3 {
          116  +  SELECT __hidden__c FROM t5a;
          117  +} {{} {} {}}
          118  +
          119  +do_execsql_test 3.4.1 {
          120  +  CREATE TABLE t5b(a, __hidden__b, c);
          121  +  CREATE TABLE t6b(a, b, __hidden__c);
          122  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(1, 2, 3);
          123  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(4, 5, 6);
          124  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(7, 8, 9);
          125  +}
          126  +
          127  +do_execsql_test 3.4.2 {
          128  +  INSERT INTO t5b SELECT * FROM t6b;
          129  +  SELECT * FROM t5b;
          130  +} {1 2   4 5   7 8}
          131  +
          132  +do_execsql_test 3.4.3 {
          133  +  SELECT __hidden__b FROM t5b;
          134  +} {{} {} {}}
          135  +
          136  +#-------------------------------------------------------------------------
          137  +# Test VACUUM
          138  +#
          139  +reset_db
          140  +do_execsql_test 4.1 {
          141  +  CREATE TABLE t1(a, __hidden__b, c UNIQUE);
          142  +  INSERT INTO t1(a, __hidden__b, c) VALUES(1, 2, 3);
          143  +  INSERT INTO t1(a, __hidden__b, c) VALUES(4, 5, 6);
          144  +  INSERT INTO t1(a, __hidden__b, c) VALUES(7, 8, 9);
          145  +  DELETE FROM t1 WHERE __hidden__b = 5;
          146  +  SELECT rowid, a, __hidden__b, c FROM t1;
          147  +} {1 1 2 3   3 7 8 9}
          148  +do_execsql_test 4.2 {
          149  +  VACUUM;
          150  +  SELECT rowid, a, __hidden__b, c FROM t1;
          151  +} {1 1 2 3   3 7 8 9}
          152  +
   101    153   finish_test