/ Check-in [28df5dc4]
Login

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

Overview
Comment:When manifesting a view as part of an DELETE or UPDATE, be sure to include the hidden columns in the manifestation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:28df5dc4a9569f388af2ee0d1f016afbea132277
User & Date: drh 2015-11-19 17:55:11
Context
2015-11-19
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
16:46
Fix problems with INSERT INTO ... SELECT ... statements that write to tables with __hidden__ columns. check-in: 59bd0ec7 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/delete.c.

   102    102     if( pFrom ){
   103    103       assert( pFrom->nSrc==1 );
   104    104       pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);
   105    105       pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
   106    106       assert( pFrom->a[0].pOn==0 );
   107    107       assert( pFrom->a[0].pUsing==0 );
   108    108     }
   109         -  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
          109  +  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 
          110  +                          SF_IncludeHidden, 0, 0);
   110    111     sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
   111    112     sqlite3Select(pParse, pSel, &dest);
   112    113     sqlite3SelectDelete(db, pSel);
   113    114   }
   114    115   #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */
   115    116   
   116    117   #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)

Changes to src/select.c.

  4360   4360               assert( zName );
  4361   4361               if( zTName && pSub
  4362   4362                && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0
  4363   4363               ){
  4364   4364                 continue;
  4365   4365               }
  4366   4366   
  4367         -            /* If a column is marked as 'hidden', do not include it in
  4368         -            ** the expanded result-set list.
         4367  +            /* If a column is marked as 'hidden', omit it from the expanded
         4368  +            ** result-set list unless the SELECT has the SF_IncludeHidden
         4369  +            ** bit set.
  4369   4370               */
  4370         -            if( IsHiddenColumn(&pTab->aCol[j]) ){
         4371  +            if( (p->selFlags & SF_IncludeHidden)==0
         4372  +             && IsHiddenColumn(&pTab->aCol[j]) 
         4373  +            ){
  4371   4374                 continue;
  4372   4375               }
  4373   4376               tableSeen = 1;
  4374   4377   
  4375   4378               if( i>0 && zTName==0 ){
  4376   4379                 if( (pFrom->fg.jointype & JT_NATURAL)!=0
  4377   4380                   && tableAndColumnIndex(pTabList, i, zName, 0, 0)

Changes to src/sqliteInt.h.

  1669   1669     Schema *pSchema;     /* Schema that contains this table */
  1670   1670     Table *pNextZombie;  /* Next on the Parse.pZombieTab list */
  1671   1671   };
  1672   1672   
  1673   1673   /*
  1674   1674   ** Allowed values for Table.tabFlags.
  1675   1675   **
  1676         -** TF_OOOHidden applies to virtual tables that have hidden columns that are
         1676  +** TF_OOOHidden applies to tables or view that have hidden columns that are
  1677   1677   ** followed by non-hidden columns.  Example:  "CREATE VIRTUAL TABLE x USING
  1678   1678   ** vtab1(a HIDDEN, b);".  Since "b" is a non-hidden column but "a" is hidden,
  1679   1679   ** the TF_OOOHidden attribute would apply in this case.  Such tables require
  1680   1680   ** special handling during INSERT processing.
  1681   1681   */
  1682   1682   #define TF_Readonly        0x01    /* Read-only system table */
  1683   1683   #define TF_Ephemeral       0x02    /* An ephemeral table */
................................................................................
  2508   2508   #define SF_Values          0x0100  /* Synthesized from VALUES clause */
  2509   2509   #define SF_MultiValue      0x0200  /* Single VALUES term with multiple rows */
  2510   2510   #define SF_NestedFrom      0x0400  /* Part of a parenthesized FROM clause */
  2511   2511   #define SF_MaybeConvert    0x0800  /* Need convertCompoundSelectToSubquery() */
  2512   2512   #define SF_MinMaxAgg       0x1000  /* Aggregate containing min() or max() */
  2513   2513   #define SF_Recursive       0x2000  /* The recursive part of a recursive CTE */
  2514   2514   #define SF_Converted       0x4000  /* By convertCompoundSelectToSubquery() */
         2515  +#define SF_IncludeHidden   0x8000  /* Include hidden columns in output */
  2515   2516   
  2516   2517   
  2517   2518   /*
  2518   2519   ** The results of a SELECT can be distributed in several ways, as defined
  2519   2520   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2520   2521   ** Type".
  2521   2522   **