## 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 vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), 'Wernher', -9223372036854775808, 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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);
PRAGMA vdbe_addoptrace = TRUE;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (unistr(NULL), '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
PRAGMA reverse_unordered_selects = YES;
CREATE TABLE t1(n int, log int);
BEGIN;
INSERT INTO /**/ t1 VALUES(like('%2%', 1.7976931348623157e+308, '%'), 1);
INSERT INTO t1 VALUES(3, 1);
INSERT INTO t1 VALUES(4, 1);
INSERT INTO t1 VALUES(4, 3);
SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log) FROM t1;
SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log;
SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y);
SELECT log, count(*) FROM t1 GROUP BY log HAVING count(*)>=4 ORDER BY log;
SELECT log, count(*), avg(n), max(n+log*2) FROM t1 GROUP BY log ORDER BY max(n+log*2)+0, min(log,avg(n))+0;


DELETE FROM t1 WHERE NOT NOT (1) ;
ANALYZE;
VACUUM main;
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
CREATE  VIEW IF NOT EXISTS v_t1_1308 AS SELECT n FROM t1;
CREATE  INDEX IF NOT EXISTS idx_t1_3077 ON t1(log);

CREATE  INDEX IF NOT EXISTS idx_t1_5776 ON t1((log + 1)) WHERE log IS NOT NULL;
SELECT COUNT(*) FILTER (WHERE log IS NOT NULL), SUM(rowid) FILTER (WHERE log > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(log) FILTER (WHERE log > 0 AND log < 100), COUNT(*) FILTER (WHERE typeof(log) = "text") FROM t1;

ALTER TABLE t1 RENAME COLUMN log TO log_r7139;
```

## 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|3
von|20|2
Braun|30
von|20
```

## Expectation

```sql

```

## Flag

```

```

