/ Check-in [7daa6873]
Login

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

Overview
Comment:Fix the query planner so that it takes into account dependencies in the arguments to table-valued functions in subexpressions in the WHERE clause. Fix for ticket [80177f0c226ff54f6dd].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:7daa687340e475972d6849f84fe1419a1f5700934f53fd80656849adc73d6d04
User & Date: drh 2018-01-26 22:41:59
Context
2018-01-27
03:26
Fix compiler warnings in zipfile.c. check-in: bed610d9 user: drh tags: trunk
2018-01-26
22:41
Fix the query planner so that it takes into account dependencies in the arguments to table-valued functions in subexpressions in the WHERE clause. Fix for ticket [80177f0c226ff54f6dd]. check-in: 7daa6873 user: drh tags: trunk
18:59
If the argument to table function zipfile() is a blob (not text), assume that it contains a zip file image to interpret, not the name of a file on disk. check-in: 029ebcd3 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

   872    872       mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);
   873    873       mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);
   874    874       if( ALWAYS(pSrc!=0) ){
   875    875         int i;
   876    876         for(i=0; i<pSrc->nSrc; i++){
   877    877           mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);
   878    878           mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);
          879  +        if( pSrc->a[i].fg.isTabFunc ){
          880  +          mask |= sqlite3WhereExprListUsage(pMaskSet, pSrc->a[i].u1.pFuncArg);
          881  +        }
   879    882         }
   880    883       }
   881    884       pS = pS->pPrior;
   882    885     }
   883    886     return mask;
   884    887   }
   885    888   

Changes to test/json101.test.

   755    755       FROM t12;
   756    756   } {{{"settings":{"layer2":{"hapax.legomenon":{"forceDisplay":true,"transliterate":true,"add.footnote":true,"summary.report":true},"dis.legomenon":{"transliterate":false,"add.footnote":false,"summary.report":true},"tris.legomenon":{"forceDisplay":true,"transliterate":false,"add.footnote":false,"summary.report":false}}}}}}
   757    757   do_execsql_test json-12.120 {
   758    758     SELECT json_extract(x, '$.settings.layer2."tris.legomenon"."summary.report"')
   759    759       FROM t12;
   760    760   } {0}
   761    761   
   762         -
          762  +# 2018-01-26
          763  +# ticket https://www.sqlite.org/src/tktview/80177f0c226ff54f6ddd41
          764  +# Make sure the query planner knows about the arguments to table-valued functions.
          765  +#
          766  +do_execsql_test json-13.100 {
          767  +  DROP TABLE IF EXISTS t1;
          768  +  DROP TABLE IF EXISTS t2;
          769  +  CREATE TABLE t1(id, json);
          770  +  INSERT INTO t1(id,json) VALUES(1,'{"items":[3,5]}');
          771  +  CREATE TABLE t2(id, json);
          772  +  INSERT INTO t2(id,json) VALUES(2,'{"value":2}');
          773  +  INSERT INTO t2(id,json) VALUES(3,'{"value":3}');
          774  +  INSERT INTO t2(id,json) VALUES(4,'{"value":4}');
          775  +  INSERT INTO t2(id,json) VALUES(5,'{"value":5}');
          776  +  INSERT INTO t2(id,json) VALUES(6,'{"value":6}');
          777  +  SELECT * FROM t1 CROSS JOIN t2
          778  +   WHERE EXISTS(SELECT 1 FROM json_each(t1.json,'$.items') AS Z
          779  +                 WHERE Z.value==t2.id);
          780  +} {1 {{"items":[3,5]}} 3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}}}
          781  +do_execsql_test json-13.110 {
          782  +  SELECT * FROM t2 CROSS JOIN t1
          783  +   WHERE EXISTS(SELECT 1 FROM json_each(t1.json,'$.items') AS Z
          784  +                 WHERE Z.value==t2.id);
          785  +} {3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}} 1 {{"items":[3,5]}}}
   763    786   
   764    787   
   765    788   finish_test