SQLite

Check-in [c403502cdc]
Login

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

Overview
Comment:Fix handling of queries with VALUES on the left and UNION ALL SELECT on the right and a LIMIT clause.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c403502cdce8b82e570e6fc49ab7f5144800c189
User & Date: drh 2015-05-20 00:15:27.101
Context
2015-05-20
17:36
Fix the initialization logic in CREATE TABLE AS so that the correct affinities are applied to all values being inserted into the new table, even if the RHS is a compound SELECT. Fix for ticket [f2ad7de056ab1dc9200]. (check-in: 6a0cf3ce9e user: drh tags: trunk)
15:51
A proposed fix for the problem of CREATE TABLE AS generating a table that has INTEGER values in a TEXT column. Ticket [f2ad7de056ab1dc92]. (check-in: d5e2c1fc76 user: drh tags: create-table-as-type-fix)
00:15
Fix handling of queries with VALUES on the left and UNION ALL SELECT on the right and a LIMIT clause. (check-in: c403502cdc user: drh tags: trunk)
2015-05-19
23:56
Enhance the selecttrace display by showing Select.selFlags. (check-in: 45d3893c61 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/parse.y.
444
445
446
447
448
449
450

451
452
453
454
455
456
457
458
459
460
461


462
463
464
465

466
467
468
469
470
471
472
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

462
463
464
465
466

467
468
469
470
471
472
473
474







+










-
+
+



-
+







  A = p;
}

selectnowith(A) ::= oneselect(X).                      {A = X;}
%ifndef SQLITE_OMIT_COMPOUND_SELECT
selectnowith(A) ::= selectnowith(X) multiselect_op(Y) oneselect(Z).  {
  Select *pRhs = Z;
  Select *pLhs = X;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;
    parserDoubleLinkSelect(pParse, pRhs);
    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
  }
  if( pRhs ){
    pRhs->op = (u8)Y;
    pRhs->pPrior = X;
    pRhs->pPrior = pLhs;
    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
    pRhs->selFlags &= ~SF_MultiValue;
    if( Y!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, X);
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  A = pRhs;
}
%type multiselect_op {int}
multiselect_op(A) ::= UNION(OP).             {A = @OP;}
multiselect_op(A) ::= UNION ALL.             {A = TK_ALL;}
multiselect_op(A) ::= EXCEPT|INTERSECT(OP).  {A = @OP;}
Changes to test/select4.test.
905
906
907
908
909
910
911






912
913
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919







+
+
+
+
+
+


} {1 3}
do_execsql_test select4-14.14 {
  VALUES(1),(2),(3) EXCEPT VALUES(1),(3);
} {2}
do_execsql_test select4-14.15 {
  SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0;
} {123 456}
do_execsql_test select4-14.16 {
  VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99;
} {1 2 3 4 5}
do_execsql_test select4-14.17 {
  VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3;
} {1 2 3}

finish_test