## 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
.explain auto
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10) UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;
PRAGMA recursive_triggers = 0;
.import employee.db main
CREATE TABLE T1 (
  A VARCHAR(CAST(20 AS VARCHAR(255))) PRIMARY KEY,
  X VARCHAR(10)  UNIQUE
);
CREATE TABLE T2 (
  A VARCHAR(20) PRIMARY KEY,
  Y VARCHAR(10) UNIQUE
);
INSERT INTO T1 VALUES ('a', 'm');
INSERT INTO T1 VALUES ('b', 'n');
INSERT INTO T1 VALUES ('c', 'o');
INSERT INTO T2 VALUES ('b', 'k');
INSERT INTO T2 VALUES ('c', 'l');
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-2.5), (3,0.0);
CREATE INDEX c
ON T(b);
SELECT * FROM T WHERE b >= -2.5 AND b < 2.0;
SELECT A FROM T1 INTERSECT SELECT A FROM T2;
BEGIN DEFERRED;
CREATE TABLE T (
  a TINYINT,
  b INTEGER,
  c REAL
);
INSERT INTO T VALUES ('a',CAST(1 AS CHARACTER(20)),2.0), ('a',2,-3.0), ('b',1,4.5);
SELECT a,b,c,
SUM(c) OVER (
  PARTITION BY a
  ORDER BY b
) AS d
FROM T;
WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<28) SELECT SUM(x) FROM cnt;
INSERT INTO T SELECT * FROM T;
ANALYZE T;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T t1 JOIN (SELECT * FROM T) AS sub ON t1.a = sub.a;
INSERT INTO T VALUES (NULL, NULL, NULL);
SELECT * FROM T AS a RIGHT OUTER JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
ANALYZE;
ROLLBACK;
INSERT INTO T SELECT * FROM T;
INSERT INTO T1 VALUES (NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, X = excluded.X;
REINDEX T2;
CREATE TEMP  VIEW IF NOT EXISTS v_T1_8000 AS SELECT A FROM T1;
DROP VIEW IF EXISTS T2;

ALTER TABLE T2 ADD COLUMN extra_6977 INT2 UNIQUE;
CREATE TABLE T (
  A VARCHAR(20),
  B VARCHAR(30),
  C VARCHAR(30),
  PRIMARY KEY (A, B),
  UNIQUE (A, C)
);
INSERT INTO T VALUES ('a', 'p', 'x');
INSERT INTO T VALUES ('a', 'q', 'y');
INSERT INTO T VALUES ('b', 'p', 'z');
INSERT INTO T VALUES ('c', 'r', 'w');
INSERT INTO T VALUES ('d', 's', 'v');
SELECT A, COUNT(DISTINCT B) AS D FROM T GROUP BY A HAVING COUNT(DISTINCT B) >= 1;
ALTER TABLE T1 RENAME COLUMN A TO A_r9820;
WITH cte AS (SELECT X, ROW_NUMBER() OVER (ORDER BY X) AS rn FROM T1) SELECT * FROM cte WHERE rn <= 5;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_T_9820 ON T(B);
```

## 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
```

