## 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
PRAGMA auto_vacuum = NONE;
SAVEPOINT sp1400;
ATTACH DATABASE ':memory:' AS aux76;
SAVEPOINT sp9627;
.dbconfig
PRAGMA wal_checkpoint('FULL');
PRAGMA cache_spill = FALSE;
.quit
((ATTACH)) DATABASE ':memory:' AS aux54;
-- LEAD({c}, 2, 'default')

CREATE TABLE T (
  a INT8,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (-iif(NULL, likelihood(degrees(sign(-glob(NULL, NULL))), -(-(datetime(quote(NULL))))), time(coalesce(NULL, NULL, 4041010528813953889))),'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;
WITH RECURSIVE empty(x) AS (SELECT 1 WHERE 1=0 uNiOn ALL SELECT x+1 FROM empty WHERE x<10) SELECT * FROM empty;
SELECT * FROM T AS a RIGHT JOIN T AS b ON a.rowid = b.rowid;
SELECT COUNT(*) FROM T;
DETACH DATABASE aux54;
SELECT COUNT(*) FROM T;
UPDATE T SET a = a + 1 WHERE rowid = 1;
UPDATE T SET a = json_object('k', a) WHERE a IS NOT NULL RETURNING *;
UPDATE T SET a = a + 1;
DELETE FROM T WHERE 0;
SELECT * FROM T;
CREATE  VIEW IF NOT EXISTS v_T_949 AS SELECT b FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T_4240 BEFORE UPDATE OF a ON T BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTILE(0) OVER (PARTITION BY c ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM T;
PRAGMA temp_store = 'MEMORY';
ALTER TABLE T RENAME COLUMN a TO a_r7606;
INSERT INTO T DEFAULT VALUES;
INSERT INTO T VALUES (NULL, NULL, NULL, NULL);
INSERT INTO T DEFAULT VALUES;
SELECT * FROM T;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_5148 AS SELECT a FROM T;
PRAGMA cache_spill = FALSE;
.quit
((ATTACH)) DATABASE ':memory:' AS aux54;
-- LEAD({c}, 2, 'default')

CREATE TABLE T (
  a NONE,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (-iif(NULL, likelihood(degrees(4041010528813953889), 0.5), 4041010528813953889),'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;
WITH RECURSIVE empty(x) AS (SELECT 1 WHERE 1=0 UNION ALL SELECT x+1 FROM empty WHERE x<10) SELECT * FROM empty;
SELECT * FROM T AS a RIGHT JOIN T AS b ON a.rowid = b.rowid;
SELECT COUNT(*) FROM T;
DETACH DATABASE aux54;
SELECT COUNT(*) FROM T;
UPDATE T SET a = a + 1 WHERE rowid = 1;
UPDATE T SET a = json_object('k', a) WHERE a IS NOT NULL RETURNING *;
UPDATE T SET a = a + 1;
DELETE FROM T WHERE 0;
SELECT * FROM T;
CREATE  VIEW IF NOT EXISTS v_T_949 AS SELECT b FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T_4240 BEFORE UPDATE OF a ON T BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTILE(0) OVER (PARTITION BY c ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM T;
PRAGMA temp_store = 'MEMORY';
ALTER TABLE T RENAME COLUMN a TO a_r7606;
INSERT INTO T DEFAULT VALUES;
INSERT INTO T VALUES (NULL, NULL, NULL, NULL);
INSERT INTO T DEFAULT VALUES;
SELECT * FROM T;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_5148 AS SELECT a FROM T;
PRAGMA cache_spill = FALSE;
.quit
((ATTACH)) DATABASE ':memory:' AS aux54;
-- LEAD({c}, 2, 'default')

CREATE TABLE T (
  a NONE,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (-iif(NULL, likelihood(degrees(4041010528813953889), 0.5), 4041010528813953889),'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;
WITH RECURSIVE empty(x) AS (SELECT 1 WHERE 1=0 UNION ALL SELECT x+1 FROM empty WHERE x<10) SELECT * FROM empty;
SELECT * FROM T AS a RIGHT JOIN T AS b ON a.rowid = b.rowid;
SELECT COUNT(*) FROM T;
DETACH DATABASE aux54;
SELECT COUNT(*) FROM T;
UPDATE T SET a = a + 1 WHERE rowid = 1;
UPDATE T SET a = json_object('k', a) WHERE a IS NOT NULL RETURNING *;
UPDATE T SET a = a + 1;
DELETE FROM T WHERE 0;
SELECT * FROM T;
CREATE  VIEW IF NOT EXISTS v_T_949 AS SELECT b FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T_4240 BEFORE UPDATE OF a ON T BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTILE(0) OVER (PARTITION BY c ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM T;
PRAGMA temp_store = 'MEMORY';
ALTER TABLE T RENAME COLUMN a TO a_r7606;
INSERT INTO T DEFAULT VALUES;
INSERT INTO T VALUES (NULL, NULL, NULL, NULL);
INSERT INTO T DEFAULT VALUES;
SELECT * FROM T;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_5148 AS SELECT a FROM T;
PRAGMA cache_spill = FALSE;
.quit
((ATTACH)) DATABASE ':memory:' AS aux54;
-- LEAD({c}, 2, 'default')

CREATE TABLE T (
  a NONE,
  b TEXT,
  c REAL,
  d REAL
);
INSERT INTO T VALUES (-iif(NULL, likelihood(degrees(4041010528813953889), 0.5), 4041010528813953889),'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 TABLE T1 (
  a INTEGER,
  b REAL
);
CREATE TABLE T2 (
  a INTEGER,
  b REAL
);
INSERT INTO T1 VALUES (1,1.0);
INSERT INTO T2 VALUES (1,-1.0),(2,9e999);
INSERT OR REPLACE INTO T1
SELECT * FROM T2;
SELECT * FROM T1;
WITH RECURSIVE empty(x) AS (SELECT 1 WHERE 1=0 UNION ALL SELECT x+1 FROM empty WHERE x<10) SELECT * FROM empty;
SELECT * FROM T AS a RIGHT JOIN T AS b ON a.rowid = b.rowid;
SELECT COUNT(*) FROM T;
DETACH DATABASE aux54;
SELECT COUNT(*) FROM T;
UPDATE T SET a = a + 1 WHERE rowid = 1;
UPDATE T SET a = json_object('k', a) WHERE a IS NOT NULL RETURNING *;
UPDATE T SET a = a + 1;
DELETE FROM T WHERE 0;
SELECT * FROM T;
CREATE  VIEW IF NOT EXISTS v_T_949 AS SELECT b FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T_4240 BEFORE UPDATE OF a ON T BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTILE(0) OVER (PARTITION BY c ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM T;
PRAGMA temp_store = 'MEMORY';
ALTER TABLE T RENAME COLUMN a TO a_r7606;
INSERT INTO T DEFAULT VALUES;
INSERT INTO T VALUES (NULL, NULL, NULL, NULL);
INSERT INTO T DEFAULT VALUES;
SELECT * FROM T;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_5148 AS SELECT a FROM T;
ANALYZE;
INSERT OR ROLLBACK INTO T VALUES (4, 0, 'x', NULL);
INSERT OR FAIL INTO T VALUES ('x', -5, NULL, 6);
ALTER TABLE T ADD COLUMN extra_961 BOOLEAN COLLATE RTRIM;
SELECT b, (SELECT b FROM T LIMIT 1) AS first_val FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T1_7329 BEFORE UPDATE ON T1 BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
CREATE TRIGGER IF NOT EXISTS trg_T_3879 AFTER INSERT ON T BEGIN INSERT INTO T(d) VALUES (NULL); END;
PRAGMA secure_delete = FALSE;
UPDATE T1 SET a = NULL WHERE rowid = 1 RETURNING *;
SELECT NTILE(1) OVER (ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM T2;
CREATE  INDEX IF NOT EXISTS idx_T1_6676 ON T1((b + 1)) WHERE b > 0;
INSERT OR ROLLBACK INTO T1 VALUES (-10, 10);
SELECT TOTAL(c) FROM T;
INSERT INTO T1 VALUES (1, 1) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b;
WITH cte AS (SELECT CASE WHEN a > 0 THEN "pos" ELSE "neg" END AS sign FROM T2) SELECT * FROM cte;
SELECT NTILE(c) OVER (ORDER BY c RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS) FROM T;
DELETE FROM T1 WHERE 0 RETURNING *;
SELECT COUNT(*) OVER (PARTITION BY a ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM T2;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15),
  C BIGINT NOT NULL,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', 3000);
INSERT INTO T VALUES ('b', 'q', 9223372036854775807);
INSERT INTO T VALUES ('c', 'r', 1700);
INSERT INTO T VALUES ('e', 'q', -9223372036854775808);
INSERT INTO T VALUES ('f', 'r', 0);
SELECT B, COUNT(*) AS D, SUM(C) AS E, AVG(C) AS F FROM T GROUP BY B HAVING SUM(C) > 0;
INSERT INTO T1 SELECT * FROM T1;
SELECT * FROM T1 WHERE a IN (SELECT DISTINCT a FROM T1);
SELECT * FROM T2;
SELECT * FROM T WHERE C < (SELECT MIN(C) FROM T);
ROLLBACK TRANSACTION TO SAVEPOINT sp9627;
RELEASE SAVEPOINT sp9627;
PRAGMA case_sensitive_like = YES;
DETACH DATABASE aux76;
SELECT * FROM T2 AS a JOIN T2 AS b ON a.rowid = b.rowid;
SELECT * FROM T1 AS a LEFT JOIN T AS b ON a.rowid = b.rowid;
SELECT * FROM T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8538 AS SELECT b FROM T1;
WITH n AS NOT MATERIALIZED (SELECT * FROM T) SELECT * FROM n WHERE A > 0;
ALTER TABLE T RENAME COLUMN C TO C_r4293;
ROLLBACK TO sp1400;
RELEASE sp1400;
UPDATE T SET A = 'x';
WITH cte AS (SELECT * FROM T2), cte2 AS (SELECT * FROM cte) SELECT * FROM cte2;
ANALYZE;
```

## Actual output

```sql
defensive off
            dqs_ddl on
            dqs_dml on
        enable_fkey off
        enable_qpsg off
     enable_trigger on
        enable_view on
     fts3_tokenizer off
 legacy_alter_table off
 legacy_file_format off
     load_extension on
   no_ckpt_on_close off
     reset_database off
        trigger_eqp off
     trusted_schema on
    writable_schema off
0|-1|-1
```

## Expectation

```sql
attach_create on
       attach_write on
           comments on
          defensive on
            dqs_ddl off
            dqs_dml off
        enable_fkey off
        enable_qpsg off
     enable_trigger on
        enable_view on
     fts3_tokenizer off
 legacy_alter_table off
 legacy_file_format off
     load_extension on
   no_ckpt_on_close off
     reset_database off
  reverse_scanorder off
    stmt_scanstatus off
        trigger_eqp off
     trusted_schema off
    writable_schema off
0|-1|-1
```

## Flag

```

```

