Files
ast-project/part1/results/3/bug_d8f26c17-b6dc-4708-ac7d-fcd76780e6ac_logic.md
T
2026-06-24 13:47:14 +02:00

22 KiB

Summary

**No review yet**

Minimized query

ATTACH DATABASE ':memory:' AS aux79;
ATTACH DATABASE ':memory:' AS aux40;
.recover
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INseRt INTO T VALUES ('a','b',instr(NULL, tan(CAST('%' AS SMALLINT)))), ('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;
.echo on
.stats stmt
PRAGMA optimize;
PRAGMA journal_mode = 'MEMORY';
BEGIN EXCLUSIVE;
SAVEPOINT sp8818;
SAVEPOINT sp9957;
.exit -(pi() + acos(('true' + 0).7976931348623157e+308))
CREATE VIRTUAL TABLE t0 USING fts4("x", "y", "z");
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 NOT NOT (NOT C BETWEEN -1000 AND 1000) ORDER BY C ASC;
DROP TABLE t0;
PRAGMA temp_store = '2';
PRAGMA fullsync = FALSE;
PRAGMA read_uncommitted = round(9223372036854775807);
.cd bugs
CREATE TABLE "customer" (id UNSIGNED BIG INT PRIMARY KEY);
CREATE TABLE apr (id INT PRIMARY KEY, apr REAL);
CREATE VIEW v1 AS SELECT c.id, i.apr FROM customer c LEFT JOIN apr i ON i.id=c.id;
CREATE VIEW v1rj AS SELECT c.id, i.apr FROM apr i RIGHT JOIN customer c ON i.id=c.id;
CREATE VIEW v2 AS SELECT c.id, v1.apr FROM customer c LEFT JOIN v1 ON v1.id=c.id;
CREATE VIEW v2rj AS SELECT c.id, v1.apr FROM v1 RIGHT JOIN customer c ON v1.id=c.id;
CREATE VIEW v2rjrj AS SELECT c.id, v1rj.apr FROM v1rj RIGHT JOIN customer c ON v1rj.id=c.id;
INSERT INTO customer (id) VALUES (1);
INSERT INTO apr (id, apr) VALUES (1, 12);
INSERT INTO customer (id) VALUES (2);
INSERT INTO apr (id, apr) VALUES (2, 12.01);
PRAGMA automatic_index=ON;
SELECT id, (apr / 100), typeof(apr) apr_type  FROM v1;
SELECT * FROM customer WHERE id IN (SELECT id FROM customer LIMIT 0);
SELECT * FROM (SELECT * FROM customer) AS sub;
SELECT * FROM apr WHERE EXISTS (SELECT 1 FROM apr WHERE EXISTS (SELECT 1 FROM apr));
CREATE TRIGGER IF NOT EXISTS trg_customer_998 AFTER DELETE ON customer BEGIN INSERT INTO customer(id) VALUES (NULL); END;
SELECT * FROM customer WHERE id <> ANY (SELECT id FROM customer);
SELECT * FROM apr WHERE EXISTS (SELECT 1 FROM apr t2 WHERE t2.id = apr.id);
INSERT OR REPLACE INTO customer VALUES (NULL);
SELECT COUNT(*) FILTER (WHERE apr IS NOT NULL), SUM(rowid) FILTER (WHERE apr > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(apr) FILTER (WHERE apr > 0 AND apr < 100), COUNT(*) FILTER (WHERE typeof(apr) = "text") FROM apr;
UPDATE customer SET id = 52 WHERE rowid = 1;
INSERT INTO apr DEFAULT VALUES;
UPDATE apr SET id = CURRENT_TIMESTAMP;
ROLLBACK TRANSACTION TO SAVEPOINT sp9957;
RELEASE SAVEPOINT sp9957;
CREATE TABLE T (
  A VARCHAR(10) PRIMARY KEY,
  B VARCHAR(15),
  C BIGINT,
  UNIQUE (B, C)
);
INSERT INTO T VALUES ('a', 'p', -9223372036854775808);
INSERT INTO T VALUES ('b', 'q', 4000);
INSERT INTO T VALUES ('c', 'r', 1700);
INSERT INTO T VALUES ('d', 'r', 9223372036854775807);
INSERT INTO T VALUES ('e', 's', 0);
SELECT A, C FROM T WHERE C > 1200 AND C < 9999999999 ORDER BY C;
WITH cte AS (SELECT * FROM customer) SELECT * FROM cte;
INSERT INTO customer VALUES ('x') ON CONFLICT(id) DO UPDATE SET id = excluded.id;
SELECT * FROM customer;
SELECT STRING_AGG(id) FROM customer;
ROLLBACK TRANSACTION TO SAVEPOINT sp8818;
RELEASE SAVEPOINT sp8818;
SELECT COUNT(*) FILTER (WHERE apr IS NOT NULL), SUM(rowid) FILTER (WHERE apr > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(apr) FILTER (WHERE apr > 0 AND apr < 100), COUNT(*) FILTER (WHERE typeof(apr) = "text") FROM apr;
ANALYZE customer;
DELETE FROM customer WHERE rowid = 55 RETURNING *;
COMMIT;
INSERT INTO apr VALUES (NULL, NULL);
REINDEX;
INSERT INTO apr VALUES (NULL, NULL);
ANALYZE;
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 apr VALUES (1, 'x') ON CONFLICT(id) DO UPDATE SET id = excluded.id, apr = excluded.apr;
INSERT INTO T DEFAULT VALUES;
WITH a AS (SELECT id FROM customer), b AS (SELECT COUNT(*) AS cnt FROM a) SELECT * FROM b;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_T_651 ON T(A COLLATE NOCASE) WHERE A > 0;
ANALYZE;
CREATE TEMPORARY  VIEW IF NOT EXISTS v_customer_2839 AS SELECT id FROM customer;
SELECT * FROM T CROSS JOIN customer;
SELECT * FROM apr;
INSERT OR FAIL INTO customer VALUES (NULL);
SELECT * FROM customer AS a FULL OUTER JOIN customer AS b ON a.rowid = b.rowid;
SELECT COUNT(*) FILTER (WHERE id IS NOT NULL), SUM(rowid) FILTER (WHERE id > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(id) FILTER (WHERE id > 0 AND id < 100), COUNT(*) FILTER (WHERE typeof(id) = "text") FROM apr;
SELECT * FROM customer;
ALTER TABLE apr ADD COLUMN extra_3754 ANY NOT NULL DEFAULT 0;
SELECT * FROM apr AS a JOIN customer AS b ON a.rowid = b.rowid;
ALTER TABLE T RENAME TO T_r1287;
CREATE  INDEX IF NOT EXISTS idx_T_8324 ON T(B COLLATE NOCASE) WHERE B > 0;
ANALYZE customer;
INSERT INTO T VALUES (NULL, NULL, NULL);
CREATE TRIGGER IF NOT EXISTS trg_customer_3825 BEFORE INSERT ON customer BEGIN SELECT RAISE(ABORT, 'abort'); END;
INSERT INTO customer VALUES (1) ON CONFLICT(id) DO UPDATE SET id = excluded.id;
SELECT * FROM customer AS a INNER JOIN T AS b ON a.rowid = b.rowid;
SELECT TOTAL(id) FROM customer;
SELECT * FROM T AS a LEFT OUTER JOIN apr AS b ON a.rowid = b.rowid;
ALTER TABLE T ADD COLUMN extra_1657 UNSIGNED BIG INT COLLATE RTRIM;
DROP TRIGGER IF EXISTS apr;
INSERT INTO customer DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE apr IS NOT NULL), SUM(rowid) FILTER (WHERE apr > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(apr) FILTER (WHERE apr > 0 AND apr < 100), COUNT(*) FILTER (WHERE typeof(apr) = "text") FROM apr;
WITH RECURSIVE r AS (SELECT * FROM T LIMIT 1 UNION ALL SELECT t.* FROM T t JOIN r ON t.A = r.A LIMIT 10) SELECT * FROM r;
SELECT * FROM apr AS a FULL JOIN apr AS b ON a.rowid = b.rowid;
UPDATE apr SET id = id + 1 WHERE rowid = 1;
INSERT INTO apr VALUES (NULL, 'x') ON CONFLICT(id) DO UPDATE SET id = excluded.id, apr = excluded.apr;
DETACH DATABASE aux40;
SELECT NTILE(-1) OVER (PARTITION BY apr ORDER BY apr ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM apr;
ALTER TABLE T RENAME COLUMN C TO C_r4051;
VACUUM;
REINDEX apr;
INSERT OR ROLLBACK INTO apr VALUES ('', -2);

SELECT COUNT(*) FROM T;
REINDEX;
SELECT id, (SELECT MIN(id) FROM customer) AS min_val FROM customer;
PRAGMA vdbe_addoptrace = 0;
DETACH DATABASE aux79;
SELECT COUNT(*) FILTER (WHERE apr IS NOT NULL), SUM(rowid) FILTER (WHERE apr > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(apr) FILTER (WHERE apr > 0 AND apr < 100), COUNT(*) FILTER (WHERE typeof(apr) = "text") FROM apr;
CREATE TRIGGER IF NOT EXISTS trg_customer_4946 BEFORE INSERT ON customer FOR EACH ROW BEGIN INSERT INTO customer(id) VALUES (NULL); END;

Actual output

PRAGMA foreign_keys=OFF;
BEGIN;
PRAGMA writable_schema = on;
PRAGMA writable_schema = off;
COMMIT;
a|b|
a|c|-1.0
b|d|0.0
.stats stmt
PRAGMA optimize;
Number of output columns:            1
Column 0 name:                       optimize
Column 0 declared type:              (null)
Memory Used:                         197816 (max 775176) bytes
Number of Outstanding Allocations:   247 (max 564)
Number of Pcache Overflow Bytes:     37960 (max 70536) bytes
Largest Allocation:                  87200 bytes
Largest Pcache Allocation:           4360 bytes
Lookaside Slots Used:                73 (max 123)
Successful lookaside attempts:       1811
Lookaside failures due to size:      20
Lookaside failures due to OOM:       928
Pager Heap Usage:                    41304 bytes
Page cache hits:                     39
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   1808 bytes
Statement Heap/Lookaside Usage:      10656 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               8
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        3040
Bytes received by read():            10665
Bytes sent to write():               133
Read() system calls:                 14
Write() system calls:                3
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
PRAGMA journal_mode = 'MEMORY';
memory
Number of output columns:            1
Column 0 name:                       journal_mode
Column 0 declared type:              (null)
Memory Used:                         197816 (max 775176) bytes
Number of Outstanding Allocations:   247 (max 564)
Number of Pcache Overflow Bytes:     37960 (max 70536) bytes
Largest Allocation:                  87200 bytes
Largest Pcache Allocation:           4360 bytes
Lookaside Slots Used:                70 (max 123)
Successful lookaside attempts:       1817
Lookaside failures due to size:      20
Lookaside failures due to OOM:       928
Pager Heap Usage:                    41304 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   1808 bytes
Statement Heap/Lookaside Usage:      10272 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               8
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            10762
Bytes sent to write():               1583
Read() system calls:                 16
Write() system calls:                4
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
BEGIN EXCLUSIVE;
Number of output columns:            0
Memory Used:                         197816 (max 775176) bytes
Number of Outstanding Allocations:   247 (max 564)
Number of Pcache Overflow Bytes:     37960 (max 70536) bytes
Largest Allocation:                  87200 bytes
Largest Pcache Allocation:           4360 bytes
Lookaside Slots Used:                69 (max 123)
Successful lookaside attempts:       1820
Lookaside failures due to size:      20
Lookaside failures due to OOM:       928
Pager Heap Usage:                    41304 bytes
Page cache hits:                     4
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   1808 bytes
Statement Heap/Lookaside Usage:      10144 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               6
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2528
Bytes received by read():            10860
Bytes sent to write():               3059
Read() system calls:                 18
Write() system calls:                5
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
SAVEPOINT sp8818;
Number of output columns:            0
Memory Used:                         197816 (max 775176) bytes
Number of Outstanding Allocations:   247 (max 564)
Number of Pcache Overflow Bytes:     37960 (max 70536) bytes
Largest Allocation:                  87200 bytes
Largest Pcache Allocation:           4360 bytes
Lookaside Slots Used:                71 (max 123)
Successful lookaside attempts:       1825
Lookaside failures due to size:      20
Lookaside failures due to OOM:       928
Pager Heap Usage:                    41304 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   1808 bytes
Statement Heap/Lookaside Usage:      10272 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               3
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            10958
Bytes sent to write():               4419
Read() system calls:                 20
Write() system calls:                6
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
SAVEPOINT sp9957;
Number of output columns:            0
Memory Used:                         197816 (max 775176) bytes
Number of Outstanding Allocations:   247 (max 564)
Number of Pcache Overflow Bytes:     37960 (max 70536) bytes
Largest Allocation:                  87200 bytes
Largest Pcache Allocation:           4360 bytes
Lookaside Slots Used:                72 (max 123)
Successful lookaside attempts:       1830
Lookaside failures due to size:      20
Lookaside failures due to OOM:       928
Pager Heap Usage:                    41304 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   1808 bytes
Statement Heap/Lookaside Usage:      10272 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               3
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            11056
Bytes sent to write():               5780
Read() system calls:                 22
Write() system calls:                7
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
.exit -(pi() + acos(('true' + 0).7976931348623157e+308))

Expectation

.dbconfig defensive off
BEGIN;
PRAGMA writable_schema = on;
PRAGMA foreign_keys = off;
PRAGMA encoding = 'UTF-8';
PRAGMA page_size = '4096';
PRAGMA auto_vacuum = '0';
PRAGMA user_version = '0';
PRAGMA application_id = '0';
PRAGMA writable_schema = off;
COMMIT;
a|b|
a|c|-1.0
b|d|0.0
.stats stmt
PRAGMA optimize;
Number of output columns:            1
Column 0 name:                       optimize
Column 0 declared type:              (null)
Memory Used:                         196296 (max 1017592) bytes
Number of Outstanding Allocations:   209 (max 631)
Number of Pcache Overflow Bytes:     37984 (max 78728) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4368 bytes
Lookaside Slots Used:                63 (max 111)
Successful lookaside attempts:       533
Lookaside failures due to size:      2
Lookaside failures due to OOM:       0
Pager Heap Usage:                    41352 bytes
Page cache hits:                     21
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Temporary data spilled to disk:      0
Schema Heap Usage:                   1512 bytes
Statement Heap/Lookaside Usage:      3040 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               8
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        3040
Bytes received by read():            11229
Bytes sent to write():               312
Read() system calls:                 15
Write() system calls:                4
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
PRAGMA journal_mode = 'MEMORY';
memory
Number of output columns:            1
Column 0 name:                       journal_mode
Column 0 declared type:              (null)
Memory Used:                         196296 (max 1017592) bytes
Number of Outstanding Allocations:   209 (max 631)
Number of Pcache Overflow Bytes:     37984 (max 78728) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4368 bytes
Lookaside Slots Used:                60 (max 111)
Successful lookaside attempts:       539
Lookaside failures due to size:      2
Lookaside failures due to OOM:       0
Pager Heap Usage:                    41352 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Temporary data spilled to disk:      0
Schema Heap Usage:                   1512 bytes
Statement Heap/Lookaside Usage:      2656 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               9
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            11326
Bytes sent to write():               1812
Read() system calls:                 17
Write() system calls:                6
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
BEGIN EXCLUSIVE;
Number of output columns:            0
Memory Used:                         200904 (max 1017592) bytes
Number of Outstanding Allocations:   215 (max 631)
Number of Pcache Overflow Bytes:     37984 (max 78728) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4368 bytes
Lookaside Slots Used:                59 (max 111)
Successful lookaside attempts:       542
Lookaside failures due to size:      2
Lookaside failures due to OOM:       0
Pager Heap Usage:                    41352 bytes
Page cache hits:                     4
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Temporary data spilled to disk:      0
Schema Heap Usage:                   1512 bytes
Statement Heap/Lookaside Usage:      2528 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               7
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2528
Bytes received by read():            11424
Bytes sent to write():               3308
Read() system calls:                 19
Write() system calls:                8
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
SAVEPOINT sp8818;
Number of output columns:            0
Memory Used:                         200904 (max 1017592) bytes
Number of Outstanding Allocations:   215 (max 631)
Number of Pcache Overflow Bytes:     37984 (max 78728) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4368 bytes
Lookaside Slots Used:                61 (max 111)
Successful lookaside attempts:       547
Lookaside failures due to size:      2
Lookaside failures due to OOM:       0
Pager Heap Usage:                    41352 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Temporary data spilled to disk:      0
Schema Heap Usage:                   1512 bytes
Statement Heap/Lookaside Usage:      2656 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               4
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            11522
Bytes sent to write():               4704
Read() system calls:                 21
Write() system calls:                10
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
SAVEPOINT sp9957;
Number of output columns:            0
Memory Used:                         200904 (max 1017592) bytes
Number of Outstanding Allocations:   215 (max 631)
Number of Pcache Overflow Bytes:     37984 (max 78728) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4368 bytes
Lookaside Slots Used:                62 (max 111)
Successful lookaside attempts:       552
Lookaside failures due to size:      2
Lookaside failures due to OOM:       0
Pager Heap Usage:                    41352 bytes
Page cache hits:                     0
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Temporary data spilled to disk:      0
Schema Heap Usage:                   1512 bytes
Statement Heap/Lookaside Usage:      2656 bytes
Fullscan Steps:                      0
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               4
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        2656
Bytes received by read():            11621
Bytes sent to write():               6101
Read() system calls:                 23
Write() system calls:                12
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
.exit -(pi() + acos(('true' + 0).7976931348623157e+308))

Flag