SQLite

Check-in [a9a3b53264]
Login

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

Overview
Comment:New test case that still hits an assertion fault, just to prove that the previous checkin merely made the problem more obscure and did not completely fix it.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ticket-f09fcd17810f
Files: files | file ages | folders
SHA3-256: a9a3b532643b5f106509bb29c3e6bc9d41ec5b2da5a0cd4067898f376eb626a2
User & Date: drh 2018-12-06 19:56:20.155
Context
2018-12-06
22:04
Fix the sqlite3ExprDup() routine so that it makes complete duplications of subqueries containing window functions. (check-in: 940174543e user: drh tags: ticket-f09fcd17810f)
19:56
New test case that still hits an assertion fault, just to prove that the previous checkin merely made the problem more obscure and did not completely fix it. (check-in: a9a3b53264 user: drh tags: ticket-f09fcd17810f)
19:15
Simplify the query flattener so that it does not duplicate the WHERE clause of subquery that is being incorporated into the outer query - copies it directly. This is more efficient. And it also fixes the specific test case show for ticket [f09fcd17810f65f71789525] but it does not resolve the more general problem that sqlite3ExprDup() does not correctly duplicate expressions that contain subqueries with window functions. (check-in: f1b18d44ff user: drh tags: ticket-f09fcd17810f)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/window1.test.
592
593
594
595
596
597
598
599





600
601
602
603
604
605
606
607
608









609
610
    INTERSECT 
  SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
} {
}

# 2018-12-06
# https://www.sqlite.org/src/info/f09fcd17810f65f7
# Assertion fault when window functions are used





#
sqlite3 db :memory:
do_execsql_test 14.0 {
  SELECT * FROM(
    SELECT * FROM (SELECT 1 AS c) WHERE c IN (
        SELECT (row_number() OVER()) FROM (VALUES (0))
    )
  );
} {1}










finish_test







|
>
>
>
>
>









>
>
>
>
>
>
>
>
>


592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
    INTERSECT 
  SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
} {
}

# 2018-12-06
# https://www.sqlite.org/src/info/f09fcd17810f65f7
# Assertion fault when window functions are used.
#
# Root cause is the query flattener invoking sqlite3ExprDup() on
# expressions that contain subqueries with window functions.  The
# sqlite3ExprDup() routine is not making correctly initializing
# Select.pWin field of the subqueries.
#
sqlite3 db :memory:
do_execsql_test 14.0 {
  SELECT * FROM(
    SELECT * FROM (SELECT 1 AS c) WHERE c IN (
        SELECT (row_number() OVER()) FROM (VALUES (0))
    )
  );
} {1}
do_execsql_test 14.1 {
  CREATE TABLE t1(x); INSERT INTO t1(x) VALUES(12345);
  CREATE TABLE t2(c); INSERT INTO t2(c) VALUES(1);
  SELECT y, y+1, y+2 FROM (
    SELECT c IN (
      SELECT (row_number() OVER()) FROM t1
    ) AS y FROM t2
  );
} {1 2 3}

finish_test