## Summary
<!--Explain briefly what goes wrong and explain why you believe this is a bug and not the intended behavior of SQLite (if it is not a crash).-->**No review yet**

## Minimized query

```sql
ATTACH DATABASE ':memory:' AS aux74;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = --(-(3261424436108084681));
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;
BEGIN DEFERRED TRANSACTION;
SAVEPOINT sp5860;
PRAGMA foreign_keys = -3261424436108084681;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote(abs(-CAST(unicode('A') AS CHAR(10)))));
CREATE TABLE t2(y,z);
INSERT /**/ INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE NOT NOT (y=2) ORDER BY y,z);

SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
CREATE TABLE T (
  a INT8,
  b TEXT
);
INSERT INTO T VALUES ('a','2020-01-01'), ('b','2026-01-01');
SELECT a,
CAST(
  (julianday('now')-julianday(b))/365.25
  AS INTEGER
) AS c
FROM T;
WITH cte AS (SELECT * FROM T WHERE +a = (SELECT MAX(a) FROM T)) SELECT * FROM cte;
INSERT INTO t2 VALUES (NULL, NULL);
REINDEX T;
DROP TRIGGER IF EXISTS t2;
CREATE TRIGGER IF NOT EXISTS trg_t1_5287 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t1(x) VALUES (NULL); END;
SELECT FIRST_VALUE(y) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM t2;
INSERT INTO t2 VALUES (NULL, NULL);
ANALYZE;
PRAGMA ignore_check_constraints = YES;
INSERT INTO t1 DEFAULT VALUES;
WITH cte AS (SELECT x FROM t1 INTERSECT SELECT x FROM t1) SELECT * FROM cte;

SELECT COUNT(*) FROM t1;
SELECT LEAD(z, 2) OVER (PARTITION BY z ORDER BY z ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
SELECT AVG(y) FROM t2;
INSERT OR REPLACE INTO t1 VALUES ('');
ANALYZE;
CREATE TRIGGER IF NOT EXISTS trg_T_9357 AFTER INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'no'); END;
ALTER TABLE t2 DROP COLUMN z;
SELECT NTILE(1) OVER (PARTITION BY y ORDER BY y ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t2;
CREATE  INDEX IF NOT EXISTS idx_T_5658 ON T(a COLLATE NOCASE) WHERE a > 0;
CREATE  INDEX IF NOT EXISTS idx_t2_5862 ON t2((y + 1)) WHERE y IS NOT NULL;
ALTER TABLE t1 ADD COLUMN extra_5808 REAL NOT NULL DEFAULT 0;
RELEASE sp5860;
ALTER TABLE t2 RENAME TO t2_r3276;
UPDATE T SET a = json_object('k', a) WHERE a BETWEEN 0 AND 100;
SELECT COUNT(*) FROM t1;
SELECT * FROM t1;
SELECT LAG(x, 2) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
PRAGMA wal_checkpoint('TRUNCATE');
COMMIT TRANSACTION;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_3666 AS SELECT a FROM T;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T;
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (1,'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999);
SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_693 AS SELECT b FROM T;

DETACH DATABASE aux74;
PRAGMA hard_heap_limit = 50000000;
DROP VIEW IF EXISTS t1;
ALTER TABLE t2 DROP COLUMN y;
CREATE  VIEW IF NOT EXISTS v_t2_3547 AS SELECT z FROM t2;
INSERT INTO T VALUES ('x', 1, NULL, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
```

## Actual output

```sql
3.39.0 2022-05-10 23:28:12 764b71267e0b31ff7eaf2a0def7526a1a02dce4d5b456dea060d97ed342ealt1
```

## Expectation

```sql
3.51.1 2025-11-28 17:28:25 281fc0e9afc38674b9b0991943b9e9d1e64c6cbdb133d35f6f5c87ff6af38a88 (64-bit)
```

## Flag

```
-version
```

