/ Check-in [b11d1793]
Login

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

Overview
Comment:Correctly detect the error of having a "*" wildcard on a SELECT without a FROM clause on the left-hand side of a recursive CTE.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b11d1793a06a44931edcbf12a615b49794d53a62
User & Date: drh 2015-03-21 03:18:22
Context
2015-03-21
10:53
Add a missing "ifcapable fts3" to a test case in vtab2.test. check-in: d845b0f6 user: dan tags: trunk
07:16
Merge recent trunk changes with this branch. check-in: 35eef4dd user: dan tags: insert-select-opt
03:18
Correctly detect the error of having a "*" wildcard on a SELECT without a FROM clause on the left-hand side of a recursive CTE. check-in: b11d1793 user: drh tags: trunk
02:58
If a column is both UNIQUE and a PRIMARY KEY, make sure the PRIMARY KEY designation takes precedence. check-in: d871a792 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  4031   4031       pSavedWith = pParse->pWith;
  4032   4032       pParse->pWith = pWith;
  4033   4033       sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel);
  4034   4034   
  4035   4035       for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
  4036   4036       pEList = pLeft->pEList;
  4037   4037       if( pCte->pCols ){
  4038         -      if( pEList->nExpr!=pCte->pCols->nExpr ){
         4038  +      if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){
  4039   4039           sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
  4040   4040               pCte->zName, pEList->nExpr, pCte->pCols->nExpr
  4041   4041           );
  4042   4042           pParse->pWith = pSavedWith;
  4043   4043           return SQLITE_ERROR;
  4044   4044         }
  4045   4045         pEList = pCte->pCols;

Changes to test/with1.test.

   823    823   do_execsql_test 12.1 {
   824    824   WITH RECURSIVE
   825    825     t1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM t1 WHERE x<20),
   826    826     t2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM t2 WHERE y<20)
   827    827   SELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1;
   828    828   } {2 4 8 10 14 16 20}
   829    829   
          830  +# 2015-03-21
          831  +# Column wildcards on the LHS of a recursive table expression
          832  +#
          833  +do_catchsql_test 13.1 {
          834  +  WITH RECURSIVE c(i) AS (SELECT * UNION ALL SELECT i+1 FROM c WHERE i<10)
          835  +  SELECT i FROM c;
          836  +} {1 {no tables specified}}
          837  +do_catchsql_test 13.2 {
          838  +  WITH RECURSIVE c(i) AS (SELECT 5,* UNION ALL SELECT i+1 FROM c WHERE i<10)
          839  +  SELECT i FROM c;
          840  +} {1 {no tables specified}}
          841  +do_catchsql_test 13.3 {
          842  +  WITH RECURSIVE c(i,j) AS (SELECT 5,* UNION ALL SELECT i+1,11 FROM c WHERE i<10)
          843  +  SELECT i FROM c;
          844  +} {1 {table c has 1 values for 2 columns}}
   830    845   
   831    846   finish_test