## 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 pragma_list;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',json_pretty(1.0)), ('a','c',-1.0), ('b','d',0.0);
SELECT
COALESCE(a,'e') AS d,
COALESCE(b,'f') AS e,
SUM(c) AS f
FROM T
GROUP BY a,b;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;
BEGIN;
SAVEPOINT sp7901;
.import corrupt001.db main
PRAGMA automatic_index;
PRAGMA vdbe_trace = TRUE;
.read commands.sql
PRAGMA short_column_names = NO;
ATTACH DATABASE ':memory:' AS aux48;
ATTACH DATABASE ':memory:' AS aux24;
.exit instr(randomblob(load_extension(soundex(-CAST(randomblob(1) AS UNSIGNED BIG INT)))), randomblob(2))
BEGIN;
ATTACH DATABASE ':memory:' AS aux68;
PRAGMA empty_result_callbacks = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
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 (NOT NOT (NOT y=2)) ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE +y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_quote('string'));
CREATE TABLE t2(y,z);
INSERT INTO t2 VALUES(2,3);
CREATE INDEX t2y ON t2(y);
SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
INSERT INTO t1 VALUES (NULL);
ALTER TABLE t2 ADD COLUMN extra_5812 NUMERIC NOT NULL DEFAULT 0;
REINDEX;
SELECT * FROM t2 WHERE y = (SELECT y FROM t2 t2 WHERE t2.y = t2.y LIMIT 1);
SELECT * FROM t1 AS a RIGHT JOIN t1 AS b ON a.rowid = b.rowid;
ALTER TABLE t2 RENAME TO t2_r6010;
DELETE FROM t1 WHERE rowid = 73 RETURNING *;
DETACH DATABASE aux68;
INSERT INTO t1 VALUES (NULL);
SELECT DENSE_RANK() OVER (PARTITION BY x ORDER BY x ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_1109 ON t2((y + 1)) WHERE y IS NOT NULL;
INSERT INTO t1 DEFAULT VALUES;
COMMIT TRANSACTION;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);

CREATE INDEX t1bc ON t1(b, c);

PRAGMA writable_schema = ON;

.imposter t1bc t2

SELECT * FROM t2;

SELECT b, c FROM t1 ORDER BY b, c;

.quit
WITH RECURSIVE vals(x) AS (SELECT z FROM t2 WHERE z IS NOT NULL UNION ALL SELECT z FROM t2 WHERE z IS NOT NULL LIMIT 10) SELECT * FROM vals;
DETACH DATABASE aux24;
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;
DETACH DATABASE aux48;
WITH cte AS (SELECT z FROM t2) SELECT * FROM cte WHERE z IS NOT NULL;
DROP VIEW IF EXISTS T;
SELECT COUNT(*) FILTER (WHERE y IS NOT NULL), SUM(rowid) FILTER (WHERE y > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(y) FILTER (WHERE y > 0 AND y < 100), COUNT(*) FILTER (WHERE typeof(y) = "text") FROM t2;
SELECT A FROM T INTERSECT SELECT A FROM (SELECT * FROM T) AS sub;
SELECT GROUP_CONCAT(b) FROM t1;
ALTER TABLE T ADD COLUMN extra_2035 VARCHAR(255) DEFAULT (abs(random()) % 1000);
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;
ALTER TABLE t1 DROP COLUMN a;
ROLLBACK TRANSACTION TO SAVEPOINT sp7901;
RELEASE SAVEPOINT sp7901;
CREATE  INDEX IF NOT EXISTS idx_t2_5276 ON t2(y) WHERE y > 0;
INSERT INTO t2 VALUES (NULL, NULL) ON CONFLICT(y) DO UPDATE SET y = excluded.y, z = excluded.z;
ROLLBACK;
WITH a AS (SELECT d FROM t1), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
INSERT OR IGNORE INTO t2 VALUES (0, '');
SELECT COUNT(c) FROM t1;

ALTER TABLE T DROP COLUMN B;
CREATE TRIGGER IF NOT EXISTS trg_T_9922 AFTER UPDATE OF A ON T BEGIN SELECT RAISE(IGNORE); END;
REINDEX;
VACUUM;
SELECT GROUP_CONCAT(y, '|') FROM t2;
```

## Actual output

```sql
analysis_limit
application_id
auto_vacuum
automatic_index
busy_timeout
cache_size
cache_spill
case_sensitive_like
cell_size_check
checkpoint_fullfsync
collation_list
compile_options
count_changes
data_version
database_list
default_cache_size
defer_foreign_keys
empty_result_callbacks
encoding
foreign_key_check
foreign_key_list
foreign_keys
freelist_count
full_column_names
fullfsync
function_list
hard_heap_limit
ignore_check_constraints
incremental_vacuum
index_info
index_list
index_xinfo
integrity_check
journal_mode
journal_size_limit
legacy_alter_table
locking_mode
max_page_count
mmap_size
module_list
optimize
page_count
page_size
pragma_list
query_only
quick_check
read_uncommitted
recursive_triggers
reverse_unordered_selects
schema_version
secure_delete
short_column_names
shrink_memory
soft_heap_limit
synchronous
table_info
table_list
table_xinfo
temp_store
temp_store_directory
threads
trusted_schema
user_version
wal_autocheckpoint
wal_checkpoint
writable_schema
1
1
```

## Expectation

```sql

```

## Flag

```

```

