## 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
.progress 2
ATTACH DATABASE ':memory:' AS aux8;
CREATE TABLE T (
  a TEXT,
  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;
.read commands.sql
.auth ON
PRAGMA wal_checkpoint;
.check
ATTACH DATABASE '' || (':memory:') AS aux7;
ATTACH DATABASE ':memory:' AS aux90;
BEGIN EXCLUSIVE;
((PRAGMA)) wal_autocheckpoint = degrees(json_quote(-(-(json_set(round(x'bd07'), '$.key', julianday(asin(unixepoch(log(json_valid(6.283185307179586, 8))))))))));
-- PRAGMA full_column_names = YES;
PRAGMA encoding = 'UTF-16le';
PRAGMA foreign_key_list(users);
.headers
CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE NOT NOT (NOT NOT (NOT NOT (i<10) INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c))) ;
CREATE INDEX t1a ON t1(a);
CREATE TABLE t2(x,y);
CREATE TABLE t3(cnt);
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE +i<4) INSERT INTO t3(cnt) SELECT i FROM c;
SELECT count(*) FROM t1;
WITH RECURSIVE vals(x) AS (SELECT ax FROM t1 WHERE ax IS NOT NULL UNION ALL SELECT ax FROM t1 WHERE ax IS NOT NULL LIMIT 10) SELECT * FROM vals;
INSERT OR FAIL INTO t3 VALUES (NULL);
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1) SELECT * FROM cnt;
END;
DETACH DATABASE aux90;
SELECT * FROM t1 CROSS JOIN t1;
VACUUM;
SELECT * FROM t2;
CREATE VIRTUAL TABLE t0 USING fts4("x", "y", "z");
DROP TABLE t0;
DETACH DATABASE aux7;
SELECT * FROM t3 AS a FULL JOIN t3 AS b ON a.rowid = b.rowid;
INSERT INTO t1 DEFAULT VALUES;
UPDATE t3 SET cnt = CURRENT_TIMESTAMP WHERE cnt IS NOT NULL;
ALTER TABLE t1 RENAME COLUMN b TO b_r9177;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',1.5), ('a','c',-2.25), ('b','b',4.75);
SELECT a,
SUM(CASE WHEN b='b' THEN c ELSE 0 END) AS d,
SUM(CASE WHEN b='c' THEN c ELSE 0 END) AS e
FROM T
GROUP BY a;
SELECT LAG(cnt, 2) OVER (ORDER BY cnt) FROM t3;
INSERT INTO t2 SELECT * FROM t2;
VACUUM;
CREATE  INDEX IF NOT EXISTS idx_t3_7253 ON t3(cnt COLLATE NOCASE);
CREATE  INDEX IF NOT EXISTS idx_T_5985 ON T((a + 1)) WHERE a > 0;
SELECT LEAD(a, 0, 'default') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM /* PRAGMA vdbe_addoptrace = ON; */ T;
VACUUM main;
INSERT INTO t2 DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM T;
VACUUM;
CREATE TEMP  VIEW IF NOT EXISTS v_t3_9532 AS SELECT cnt FROM t3;
.auth ON
PRAGMA wal_checkpoint;
.check
ATTACH DATABASE ':memory:' AS aux7;
ATTACH DATABASE ':memory:' AS aux90;
BEGIN EXCLUSIVE;
((PRAGMA)) wal_autocheckpoint = degrees(json_quote(-(-(json_set(round(x'bd07'), '$.key', julianday(asin(unixepoch(6.283185307179586))))))));
-- PRAGMA full_column_names = YES;
PRAGMA encoding = 'UTF-16le';
PRAGMA foreign_key_list(users);
.headers
CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10) INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c;
CREATE INDEX t1a ON t1(a);
CREATE TABLE t2(x,y);
CREATE TABLE t3(cnt);
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4) INSERT INTO t3(cnt) SELECT i FROM c;
SELECT count(*) FROM t1;
WITH RECURSIVE vals(x) AS (SELECT ax FROM t1 WHERE ax IS NOT NULL UNION ALL SELECT ax FROM t1 WHERE ax IS NOT NULL LIMIT 10) SELECT * FROM vals;
INSERT OR FAIL INTO t3 VALUES (NULL);
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1) SELECT * FROM cnt;
END;
DETACH DATABASE aux90;
SELECT * FROM t1 CROSS JOIN t1;
VACUUM;
SELECT * FROM t2;
DETACH DATABASE aux7;
SELECT * FROM t3 AS a FULL JOIN t3 AS b ON a.rowid = b.rowid;
INSERT INTO t1 DEFAULT VALUES;
UPDATE t3 SET cnt = CURRENT_TIMESTAMP WHERE cnt IS NOT NULL;
ALTER TABLE t1 RENAME COLUMN b TO b_r9177;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',1.5), ('a','c',-2.25), ('b','b',4.75);
SELECT a,
SUM(CASE WHEN b='b' THEN c ELSE 0 END) AS d,
SUM(CASE WHEN b='c' THEN c ELSE 0 END) AS e
FROM T
GROUP BY a;
SELECT LAG(cnt, 2) OVER (ORDER BY cnt) FROM t3;
INSERT INTO t2 SELECT * FROM t2;
VACUUM;
CREATE  INDEX IF NOT EXISTS idx_t3_7253 ON t3(cnt COLLATE NOCASE);
CREATE  INDEX IF NOT EXISTS idx_T_5985 ON T((a + 1)) WHERE a > 0;
SELECT LEAD(a, 0, 'default') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM /* PRAGMA vdbe_addoptrace = ON; */ T;
VACUUM main;
INSERT INTO t2 DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM T;
VACUUM;
CREATE TEMP  VIEW IF NOT EXISTS v_t3_9532 AS SELECT cnt FROM t3;
.auth ON
PRAGMA wal_checkpoint;
.check
ATTACH DATABASE ':memory:' AS aux7;
ATTACH DATABASE ':memory:' AS aux90;
BEGIN EXCLUSIVE;
((PRAGMA)) wal_autocheckpoint = degrees(json_quote(-(-(json_set(round(x'bd07'), '$.key', julianday(asin(unixepoch(6.283185307179586))))))));
-- PRAGMA full_column_names = YES;
PRAGMA encoding = 'UTF-16le';
PRAGMA foreign_key_list(users);
.headers
CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10) INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c;
CREATE INDEX t1a ON t1(a);
CREATE TABLE t2(x,y);
CREATE TABLE t3(cnt);
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4) INSERT INTO t3(cnt) SELECT i FROM c;
SELECT count(*) FROM t1;
WITH RECURSIVE vals(x) AS (SELECT ax FROM t1 WHERE ax IS NOT NULL UNION ALL SELECT ax FROM t1 WHERE ax IS NOT NULL LIMIT 10) SELECT * FROM vals;
INSERT OR FAIL INTO t3 VALUES (NULL);
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1) SELECT * FROM cnt;
END;
DETACH DATABASE aux90;
SELECT * FROM t1 CROSS JOIN t1;
VACUUM;
SELECT * FROM t2;
DETACH DATABASE aux7;
SELECT * FROM t3 AS a FULL JOIN t3 AS b ON a.rowid = b.rowid;
INSERT INTO t1 DEFAULT VALUES;
UPDATE t3 SET cnt = CURRENT_TIMESTAMP WHERE cnt IS NOT NULL;
ALTER TABLE t1 RENAME COLUMN b TO b_r9177;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',1.5), ('a','c',-2.25), ('b','b',4.75);
SELECT a,
SUM(CASE WHEN b='b' THEN c ELSE 0 END) AS d,
SUM(CASE WHEN b='c' THEN c ELSE 0 END) AS e
FROM T
GROUP BY a;
SELECT LAG(cnt, 2) OVER (ORDER BY cnt) FROM t3;
INSERT INTO t2 SELECT * FROM t2;
VACUUM;
CREATE  INDEX IF NOT EXISTS idx_t3_7253 ON t3(cnt COLLATE NOCASE);
CREATE  INDEX IF NOT EXISTS idx_T_5985 ON T((a + 1)) WHERE a > 0;
SELECT LEAD(a, 0, 'default') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM /* PRAGMA vdbe_addoptrace = ON; */ T;
VACUUM main;
INSERT INTO t2 DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM T;
VACUUM;
CREATE TEMP  VIEW IF NOT EXISTS v_t3_9532 AS SELECT cnt FROM t3;
.auth ON
PRAGMA wal_checkpoint;
.check
ATTACH DATABASE ':memory:' AS aux7;
ATTACH DATABASE ':memory:' AS aux90;
BEGIN EXCLUSIVE;
((PRAGMA)) wal_autocheckpoint = degrees(json_quote(-(-(json_set(round(x'bd07'), '$.key', julianday(asin(unixepoch(6.283185307179586))))))));
-- PRAGMA full_column_names = YES;
PRAGMA encoding = 'UTF-16le';
PRAGMA foreign_key_list(users);
.headers
CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10) INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c;
CREATE INDEX t1a ON t1(a);
CREATE TABLE t2(x,y);
CREATE TABLE t3(cnt);
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4) INSERT INTO t3(cnt) SELECT i FROM c;
SELECT count(*) FROM t1;
WITH RECURSIVE vals(x) AS (SELECT ax FROM t1 WHERE ax IS NOT NULL UNION ALL SELECT ax FROM t1 WHERE ax IS NOT NULL LIMIT 10) SELECT * FROM vals;
INSERT OR FAIL INTO t3 VALUES (NULL);
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1) SELECT * FROM cnt;
END;
DETACH DATABASE aux90;
SELECT * FROM t1 CROSS JOIN t1;
VACUUM;
SELECT * FROM t2;
DETACH DATABASE aux7;
SELECT * FROM t3 AS a FULL JOIN t3 AS b ON a.rowid = b.rowid;
INSERT INTO t1 DEFAULT VALUES;
UPDATE t3 SET cnt = CURRENT_TIMESTAMP WHERE cnt IS NOT NULL;
ALTER TABLE t1 RENAME COLUMN b TO b_r9177;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',1.5), ('a','c',-2.25), ('b','b',4.75);
SELECT a,
SUM(CASE WHEN b='b' THEN c ELSE 0 END) AS d,
SUM(CASE WHEN b='c' THEN c ELSE 0 END) AS e
FROM T
GROUP BY a;
SELECT LAG(cnt, 2) OVER (ORDER BY cnt) FROM t3;
INSERT INTO t2 SELECT * FROM t2;
VACUUM;
CREATE  INDEX IF NOT EXISTS idx_t3_7253 ON t3(cnt COLLATE NOCASE);
CREATE  INDEX IF NOT EXISTS idx_T_5985 ON T((a + 1)) WHERE a > 0;
SELECT LEAD(a, 0, 'default') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM /* PRAGMA vdbe_addoptrace = ON; */ T;
VACUUM main;
INSERT INTO t2 DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM T;
VACUUM;
CREATE TEMP  VIEW IF NOT EXISTS v_t3_9532 AS SELECT cnt FROM t3;
CREATE TEMP  VIEW IF NOT EXISTS v_t3_9750 AS SELECT cnt FROM t3;
INSERT OR FAIL INTO T VALUES ('x', 0, NULL);
SELECT LEAD(a, 1) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1;
CREATE TRIGGER IF NOT EXISTS trg_t2_5381 AFTER DELETE ON t2 BEGIN SELECT RAISE(ABORT, 'abort'); END;
WITH RECURSIVE multi(a, b) AS (VALUES(1, "x") UNION ALL SELECT a+1, "x" FROM multi WHERE a<89) SELECT * FROM multi;
ANALYZE t3;
SELECT COUNT(*) FROM t2;
INSERT OR FAIL INTO t1 VALUES ('x', NULL, '');
SELECT * FROM t2 AS a RIGHT JOIN t2 AS b ON a.rowid = b.rowid;
SELECT * FROM t1;
CREATE TRIGGER IF NOT EXISTS trg_T_4265 AFTER UPDATE OF c ON T BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
PRAGMA cell_size_check = ON;
ALTER TABLE t2 ADD COLUMN extra_2596 BIGINT UNIQUE;
CREATE TRIGGER IF NOT EXISTS trg_t1_318 AFTER INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t1(b) VALUES (NULL); END;
SELECT COUNT(*) FROM t1;
INSERT INTO t1 VALUES (NULL, NULL, NULL);
SELECT cnt, (SELECT SUM(cnt) FROM t3) AS sum_val FROM t3;
ANALYZE t2;
DROP TRIGGER IF EXISTS t3;
REINDEX t1;
SELECT STRING_AGG(y, '|') FROM t2;
INSERT INTO t2 SELECT * FROM t2;
WITH cte(x) AS (SELECT x FROM t2) SELECT x FROM cte;
VACUUM;
ALTER TABLE t2 DROP COLUMN x;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t1_5304 ON t1((a + 1));
UPDATE t1 SET ax = '';
CREATE TEMP  VIEW IF NOT EXISTS v_t3_4657 AS SELECT cnt FROM t3;
CREATE  INDEX IF NOT EXISTS idx_t3_1119 ON t3(lower(cnt));
INSERT INTO T SELECT * FROM T;
REINDEX t2;
WITH cte AS (SELECT c FROM T INTERSECT SELECT c FROM T) SELECT * FROM cte;
DROP TABLE IF EXISTS t2;
UPDATE T SET a = json_object('k', a) WHERE 1;
DETACH DATABASE aux8;
VACUUM;
DROP TRIGGER IF EXISTS t2;
INSERT INTO t3 VALUES (NULL);
PRAGMA vdbe_trace = 0;
```

## Actual output

```sql
Progress 1
Progress 2
Progress 3
Progress 4
Progress 5
Progress 6
Progress 7
Progress 8
Progress 9
Progress 10
Progress 11
Progress 12
Progress 13
Progress 14
Progress 15
Progress 16
Progress 17
Progress 18
Progress 19
Progress 20
Progress 21
Progress 22
Progress 23
Progress 24
Progress 25
Progress 26
Progress 27
Progress 28
Progress 29
Progress 30
Progress 31
Progress 32
Progress 33
Progress 34
Progress 35
Progress 36
Progress 37
Progress 38
Progress 39
Progress 40
Progress 41
Progress 42
Progress 43
Progress 44
Progress 45
Progress 46
Progress 47
Progress 48
Progress 49
Progress 50
Progress 51
Progress 52
Progress 53
Progress 54
[{"a":"a","c":6}Progress 55
Progress 56
Progress 57
Progress 58
,
{"a":"b","c":0}Progress 59
]
Progress 60
[{"1":1}Progress 61
]
authorizer: PRAGMA "wal_checkpoint" NULL NULL NULL
Progress 62
Progress 63
[{"busy":0,"log":-1,"checkpointed":-1}]
```

## Expectation

```sql
Progress 1
Progress 2
Progress 3
Progress 4
Progress 5
Progress 6
Progress 7
Progress 8
Progress 9
Progress 10
Progress 11
Progress 12
Progress 13
Progress 14
Progress 15
Progress 16
Progress 17
Progress 18
Progress 19
Progress 20
Progress 21
Progress 22
Progress 23
Progress 24
Progress 25
Progress 26
Progress 27
Progress 28
Progress 29
Progress 30
Progress 31
Progress 32
Progress 33
Progress 34
Progress 35
Progress 36
Progress 37
Progress 38
Progress 39
Progress 40
Progress 41
Progress 42
Progress 43
Progress 44
Progress 45
Progress 46
Progress 47
Progress 48
Progress 49
Progress 50
Progress 51
Progress 52
Progress 53
Progress 54
Progress 55
Progress 56
[{"a":"a","c":6}Progress 57
Progress 58
Progress 59
Progress 60
,
{"a":"b","c":0}Progress 61
]
Progress 62
Progress 63
[{"1":1}]
authorizer: PRAGMA "wal_checkpoint" NULL NULL NULL
Progress 64
Progress 65
[{"busy":0,"log":-1,"checkpointed":-1}Progress 66
]
```

## Flag

```
-json
```

