/ Check-in [104a2beb57]
Login

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

Overview
Comment:Restore generated column loop detection logic that was incorrectly removed from the previous check-in [9e07b48934e9a972]. This fixes ticket [299b50ba812d8e54]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 104a2beb57037f9353ffa77096aae0eb64e4682e667f31623bfd3d064dd8d881
User & Date: drh 2019-11-07 02:32:54
Context
2019-11-07
14:51
Fix the xferCompatibleIndex() function so that it recognizes that a PRIMARY KEY index for a WITHOUT ROWID table is different from a UNIQUE constraint index on the primary key. Ticket [302027baf1374498] check-in: 34f64f11ca user: drh tags: trunk
02:32
Restore generated column loop detection logic that was incorrectly removed from the previous check-in [9e07b48934e9a972]. This fixes ticket [299b50ba812d8e54] check-in: 104a2beb57 user: drh tags: trunk
2019-11-06
22:19
Change the way generated columns are computed so that no column is computed inside branch code that might not be taken. Ticket [4fc08501f4e56692] check-in: 9e07b48934 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  3641   3641               return -1-pParse->iSelfTab;
  3642   3642             }
  3643   3643             pCol = pTab->aCol + iCol;
  3644   3644             testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
  3645   3645             iSrc = sqlite3TableColumnToStorage(pTab, iCol) - pParse->iSelfTab;
  3646   3646   #ifndef SQLITE_OMIT_GENERATED_COLUMNS
  3647   3647             if( pCol->colFlags & COLFLAG_GENERATED ){
  3648         -            sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
         3648  +            if( pCol->colFlags & COLFLAG_BUSY ){
         3649  +              sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
         3650  +                              pCol->zName);
         3651  +              return 0;
         3652  +            }
         3653  +            pCol->colFlags |= COLFLAG_BUSY;
         3654  +            if( pCol->colFlags & COLFLAG_NOTAVAIL ){
         3655  +              sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
         3656  +            }
         3657  +            pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
  3649   3658               return iSrc;
  3650   3659             }else
  3651   3660   #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
  3652   3661             if( pCol->affinity==SQLITE_AFF_REAL ){
  3653   3662               sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target);
  3654   3663               sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
  3655   3664               return target;

Changes to test/gencol1.test.

   229    229       c0 AS (('a', 9) < ('b', c1)),
   230    230       c1 AS (1),
   231    231       c2 CHECK (1 = c1)
   232    232     );
   233    233     INSERT INTO t0 VALUES (0),(99);
   234    234     SELECT * FROM t0;
   235    235   } {1 1 0 1 1 99}
          236  +do_catchsql_test gencol1-8.20 {
          237  +  DROP TABLE IF EXISTS t0;
          238  +  CREATE TABLE t0(
          239  +    c0,
          240  +    c1 AS(c0 + c2),
          241  +    c2 AS(c1) CHECK(c2)
          242  +  );
          243  +  UPDATE t0 SET c0 = NULL;
          244  +} {1 {generated column loop on "c2"}}
          245  +
   236    246   
   237    247   finish_test