parse failure with a comment between WINDOW and first named window
(1) By El Yobo (elyobo) on 2025-07-07 01:41:05 [source]
Example as below. I noticed this with a better-sqlite3
upgrade to 11.9.0 which included an upgrade to sqlite 3.49.1. I have also confirmed that it's still present in sqlite 3.50.2. Shifting the comment into the window definition instead works.
-- Create and populate a test table
CREATE TABLE test (x INTEGER);
INSERT INTO test (x) VALUES (1), (2), (3);
-- This works:
SELECT x, ROW_NUMBER() OVER (ORDER BY x) AS rn
FROM test;
SELECT x, ROW_NUMBER() OVER (w) AS rn
FROM test
WINDOW
w AS ( -- this comment is fine
ORDER BY x
);
-- This fails with: "near "WINDOW": syntax error"
-- because of the comment between WINDOW and the window definition
SELECT x, ROW_NUMBER() OVER (w) AS rn
FROM test
WINDOW -- this comment breaks it
w AS (ORDER BY x);
Output from the above looks like this; unsure whether the layout change (the newlines are not as per the source file) are significant.
sqlite3 < tmp.sql
1|1
2|2
3|3
1|1
2|2
3|3
Parse error near line 18: near "w": syntax error
S rn FROM test WINDOW -- this comment breaks it w AS (ORDER BY x);
error here ---^
(2.1) By Richard Hipp (drh) on 2025-07-07 02:25:04 edited from 2.0 in reply to 1 [link] [source]
This bug appears to have been introduced in version 3.49.0 by the addition of support for the SQLITE_DBCONFIG_ENABLE_COMMENTS option, item 5c on the change log.
Now fixed by check-in 2025-07-07T02:18Z.