/ Check-in [aba1e22b]
Login

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

Overview
Comment:Make sure left-join markings are transferred to the virtual scalar subexpressions when decomposing a vector comparison in the ON clause of a LEFT JOIN. Fix for ticket [fef4bb4bd9185ec8f].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.15
Files: files | file ages | folders
SHA1: aba1e22bbae1cd21f6e1d10773ccbfc4682db52c
User & Date: drh 2016-11-03 18:35:19
Context
2016-11-03
18:36
Fix an issue that was causing the new database image to be assembled entirely in heap memory when VACUUMing a database, even if it should use a temp file. This could cause SQLITE_NOMEM errors when vacuuming very large databases on 32-bit systems. check-in: 3fae483f user: drh tags: branch-3.15
18:35
Make sure left-join markings are transferred to the virtual scalar subexpressions when decomposing a vector comparison in the ON clause of a LEFT JOIN. Fix for ticket [fef4bb4bd9185ec8f]. check-in: aba1e22b user: drh tags: branch-3.15
18:33
If all branches of an OR optimize scan that is the rhs of a LEFT JOIN use the same index, set the index cursor to return NULL values if there are no matches for a row on the lhs. Fix for ticket [34a579141b2c5ac] check-in: 54eeddec user: drh tags: branch-3.15
2016-10-27
01:02
Make sure left-join markings are transferred to the virtual scalar subexpressions when decomposing a vector comparison in the ON clause of a LEFT JOIN. Fix for ticket [fef4bb4bd9185ec8f]. check-in: 619f5cc7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/whereexpr.c.

  1194   1194       for(i=0; i<nLeft; i++){
  1195   1195         int idxNew;
  1196   1196         Expr *pNew;
  1197   1197         Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
  1198   1198         Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
  1199   1199   
  1200   1200         pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
         1201  +      transferJoinMarkings(pNew, pExpr);
  1201   1202         idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
  1202   1203         exprAnalyze(pSrc, pWC, idxNew);
  1203   1204       }
  1204   1205       pTerm = &pWC->a[idxTerm];
  1205   1206       pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL;  /* Disable the original */
  1206   1207       pTerm->eOperator = 0;
  1207   1208     }

Changes to test/rowvalue.test.

   251    251   do_catchsql_test 11.7 {
   252    252     SELECT * FROM t11 WHERE (a,a) IS 1;
   253    253   } {1 {row value misused}}
   254    254   do_catchsql_test 11.8 {
   255    255     SELECT * FROM t11 WHERE (a,a) IS NOT 1;
   256    256   } {1 {row value misused}}
   257    257   
          258  +# 2016-10-27: https://www.sqlite.org/src/tktview/fef4bb4bd9185ec8f
          259  +# Incorrect result from a LEFT JOIN with a row-value constraint
          260  +#
          261  +do_execsql_test 12.1 {
          262  +  DROP TABLE IF EXISTS t1;
          263  +  CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2);
          264  +  DROP TABLE IF EXISTS t2;
          265  +  CREATE TABLE t2(x,y); INSERT INTO t2 VALUES(3,4);
          266  +  SELECT *,'x' FROM t1 LEFT JOIN t2 ON (a,b)=(x,y);
          267  +} {1 2 {} {} x}
   258    268   
   259    269   finish_test