/ Check-in [9c0d8090]
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:Make a hard copy of the results of a subquery lest the result of the subquery be referenced after a change to the table that generated the subquery result.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9c0d80907b4dee8ee8f205c2ebdb759f5ba1d771
User & Date: drh 2015-05-18 04:24:27
Context
2015-05-18
12:28
Transitive constraints should only work if operands have compatible affinities and collating sequences. check-in: 5df40564 user: drh tags: trunk
04:24
Make a hard copy of the results of a subquery lest the result of the subquery be referenced after a change to the table that generated the subquery result. check-in: 9c0d8090 user: drh tags: trunk
2015-05-16
18:31
Fix a typo in a comment. No changes to code. check-in: ee4b7425 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

   709    709         sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);
   710    710         VdbeComment((v, "%s", pEList->a[i].zName));
   711    711       }
   712    712     }else if( eDest!=SRT_Exists ){
   713    713       /* If the destination is an EXISTS(...) expression, the actual
   714    714       ** values returned by the SELECT are not required.
   715    715       */
   716         -    sqlite3ExprCodeExprList(pParse, pEList, regResult,
   717         -                  (eDest==SRT_Output||eDest==SRT_Coroutine)?SQLITE_ECEL_DUP:0);
          716  +    u8 ecelFlags;
          717  +    if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){
          718  +      ecelFlags = SQLITE_ECEL_DUP;
          719  +    }else{
          720  +      ecelFlags = 0;
          721  +    }
          722  +    sqlite3ExprCodeExprList(pParse, pEList, regResult, ecelFlags);
   718    723     }
   719    724   
   720    725     /* If the DISTINCT keyword was present on the SELECT statement
   721    726     ** and this row has been seen before, then do not make this row
   722    727     ** part of the result.
   723    728     */
   724    729     if( hasDistinct ){

Changes to test/misc4.test.

   214    214   sqlite3 db :memory:
   215    215   do_catchsql_test misc4-7.1 {
   216    216     CREATE TABLE t7(x);
   217    217     PRAGMA writable_schema=ON;
   218    218     UPDATE sqlite_master SET sql='CREATE TABLE [M%s%s%s%s%s%s%s%s%s%s%s%s%s';
   219    219     VACUUM;
   220    220   } {1 {unrecognized token: "[M%s%s%s%s%s%s%s%s%s%s%s%s%s"}}
          221  +
          222  +# 2015-05-18.  Use of ephermeral Mem content after the cursor that holds
          223  +# the canonical content has moved on.
          224  +#
          225  +do_execsql_test misc4-7.2 {
          226  +  CREATE TABLE t0(a,b);
          227  +  INSERT INTO t0 VALUES(1,0),(2,0);
          228  +  UPDATE t0 SET b=9 WHERE a AND (SELECT a FROM t0 WHERE a);
          229  +  SELECT * FROM t0 ORDER BY +a;
          230  +} {1 9 2 9}
   221    231   
   222    232   finish_test