## 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 aux84;
PRAGMA synchronous = '1';
ATTACH DATABASE ':memory:' AS aux94;
BEGIN;
ATTACH DATABASE '' || (':memory:') AS aux85;
-- typeof(randomblob(1))

.auth OFF
PRAGMA count_changes = OFF;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a CHARINT PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(tanh(-(-(NULL)))), -concat_ws('|', 'a', NULL, 'b'));
INSERT INTO t1 VALUES (exp(unicode(CAST(x'ec53ac57fa' AS INT))), 'von', sqrt('}'), power((pi() + 0.0), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;
PRAGMA legacy_alter_table = ON;
CREATE TABLE t1(a DOUB PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (-(-(NULL)), 'Wernher', json_quote(123), 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
BEGIN EXCLUSIVE;
CREATE TABLE map_integer (id INT, name);
INSERT INTO map_integer VALUES(lower('你好'),'a');
CREATE TABLE map_text (id TEXT, name);
INSERT INTO map_text VALUES('4','e');
CREATE TABLE `data` (id TEXT, name);
INSERT INTO data VALUES(3547739615393531126,'abc');
INSERT INTO data VALUES('4','xyz');
CREATE VIEW idmap as WITH _m AS MATERIALIZED (WITH _m AS MATERIALIZED (SELECT * FROM map_integer) SELECT * FROM map_text) SELECT * FROM _m UNION SELECT * FROM _m;
CREATE TABLE mzed AS SELECT * FROM idmap;
PRAGMA automatic_index=ON;
SELECT * FROM data JOIN idmap USING(id);
SELECT * FROM data AS a LEFT JOIN map_integer AS b ON a.rowid = b.rowid;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_6193 AS SELECT name FROM map_integer;
CREATE  VIEW IF NOT EXISTS v_data_9060 AS SELECT name FROM data;
INSERT INTO data SELECT * FROM data;
PRAGMA ignore_check_constraints = 0;
ALTER TABLE data ADD COLUMN extra_9221 TINYINT DEFAULT '';
CREATE TEMPORARY  VIEW IF NOT EXISTS v_map_text_5459 AS SELECT name FROM map_text;
COMMIT;
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;
CREATE TRIGGER IF NOT EXISTS trg_map_text_8647 AFTER DELETE ON map_text FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END;
SELECT NTH_VALUE(id, 0) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM map_integer;
REINDEX map_integer;
DELETE FROM map_integer WHERE NOT NOT (0) ;
UPDATE map_text SET id = 'x' WHERE rowid = 1;
DELETE FROM map_integer WHERE rowid = 41;
CREATE  VIEW IF NOT EXISTS v_data_9250 AS SELECT name FROM data;
ALTER TABLE data DROP COLUMN id;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15) NOT NULL,
  C INTEGER,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 700);
INSERT INTO T VALUES ('c', 'r', 0);
INSERT INTO T VALUES ('d', 's', 2147483647);
INSERT INTO T VALUES ('e', 't', -1);
INSERT INTO T VALUES ('f', 'u', 1);
SELECT * FROM T WHERE C BETWEEN -1000 AND 1000 ORDER BY C ASC;
INSERT INTO map_text VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
PRAGMA foreign_key_list(users);
SELECT COUNT(*) FROM data;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T_7942 AS SELECT C FROM T;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_map_text_1196 ON map_text(id) WHERE id > 0;
SELECT COUNT(C) FROM T;
DELETE FROM T WHERE rowid = 20 RETURNING *;
INSERT OR REPLACE INTO data VALUES (-8, 'x');
SELECT * FROM map_text;
WITH a AS (SELECT a FROM T1), b AS (SELECT a FROM a), c AS (SELECT a FROM b) SELECT * FROM c;
REINDEX map_text;
SELECT SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM map_text;

PRAGMA foreign_keys = NO;
VACUUM main;
ALTER TABLE data RENAME TO data_r5580;
DETACH DATABASE aux85;
INSERT INTO T2 DEFAULT VALUES;
ALTER TABLE t1 RENAME COLUMN d TO d_r9282;
WITH RECURSIVE pair(a,b) AS (VALUES(0,1) UNION ALL SELECT b, a+b FROM pair WHERE b<100) SELECT * FROM pair;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T2_5688 AS SELECT a FROM T2;
SELECT COUNT(*) FILTER (WHERE name IS NOT NULL), SUM(rowid) FILTER (WHERE name > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(name) FILTER (WHERE name > 0 AND name < 100), COUNT(*) FILTER (WHERE typeof(name) = "text") FROM map_integer;
CREATE TEMP  VIEW IF NOT EXISTS v_map_integer_262 AS SELECT id FROM map_integer;
CREATE TRIGGER IF NOT EXISTS trg_map_integer_3732 AFTER DELETE ON map_integer FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'abort'); END;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_T2_5226 AS SELECT b FROM T2;

VACUUM;
UPDATE map_text SET name = 52 WHERE name BETWEEN 0 AND 100;
SELECT name, (SELECT name FROM data LIMIT 1) AS first_val FROM data;
COMMIT TRANSACTION;

SELECT COUNT(*) FROM map_text;
CREATE TRIGGER IF NOT EXISTS trg_T2_8749 AFTER INSERT ON T2 BEGIN SELECT RAISE(IGNORE); END;
DETACH DATABASE aux94;
PRAGMA case_sensitive_like = OFF;
ALTER TABLE t1 DROP COLUMN d;
DROP TRIGGER IF EXISTS T1;
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
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 WHERE ROW_NUMBER() OVER (ORDER BY b) = 1);
REINDEX map_integer;
INSERT INTO t1 VALUES ('x', 'x', NULL, 1) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE data ADD COLUMN extra_1045 MEDIUMINT DEFAULT (random());
WITH cte AS (SELECT B FROM T INTERSECT SELECT B FROM T) SELECT * FROM cte;
VACUUM;
SELECT * FROM map_integer AS a JOIN T1 AS b ON a.rowid = b.rowid;
SELECT * FROM T2 AS a RIGHT JOIN data AS b ON a.rowid = b.rowid;
VACUUM;
SELECT * FROM map_integer WHERE (id) IN (SELECT id FROM map_integer);
DETACH DATABASE aux84;
ALTER TABLE T ADD COLUMN extra_9789 INTEGER COLLATE NOCASE;
DELETE FROM data WHERE 0;
ANALYZE;
SELECT MAX(id) FILTER (WHERE id IS NOT NULL) OVER (PARTITION BY id ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM map_integer;
INSERT INTO t1 SELECT * FROM t1;
PRAGMA empty_result_callbacks = OFF;
INSERT OR ABORT INTO t1 VALUES (NULL, -1, '', 'x');
CREATE TEMP  VIEW IF NOT EXISTS v_data_7477 AS SELECT id FROM data;
SELECT LAG(a, a) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
WITH a AS (SELECT b FROM T1), b AS (SELECT b FROM a WHERE b IS NOT NULL), c AS (SELECT COUNT(*) AS cnt FROM b) SELECT cnt FROM c;
VACUUM main;
INSERT INTO data VALUES (1, 'x') ON CONFLICT(id) DO UPDATE SET id = excluded.id, name = excluded.name;
```

## Actual output

```sql
CREATE TABLE "t2"("b","c","_ROWID_",PRIMARY KEY("b","c","_ROWID_"))WITHOUT ROWID;
WARNING: writing to an imposter table will corrupt the "t1bc" index!
Braun|30|2
von||1
Braun|30
von|
```

## Expectation

```sql

```

## Flag

```

```

