/ View Ticket
Login
2015-06-16
16:39 Fixed ticket [873cae2b]: Schema corruption after aborted CREATE TABLE AS plus 5 other changes (artifact: 8c915fd4 user: drh)
16:39
Ensure that the CREATE TABLE AS statement correctly undoes partial changes to the sqlite_master table if the SELECT on the right-hand side aborts with an error. Fix for ticket [873cae2b6e25b] (check-in: 400e025e user: drh tags: trunk)
16:27 New ticket [873cae2b] Schema corruption after aborted CREATE TABLE AS. (artifact: bdeb3094 user: drh)

Ticket UUID: 873cae2b6e25b1991ce5e9b782f9cd0409b96063
Title: Schema corruption after aborted CREATE TABLE AS
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2015-06-16 16:39:22
Version Found In: 3.8.10.2
User Comments:
drh added on 2015-06-16 16:27:47:

When a CREATE TABLE AS statement is part of a larger transaction and it aborts due to an error condition in the SELECT on the right-hand side, this can leave the sqlite3_master table with a blank entry which subsequent database connections will interpret as a corrupt database. The following SQL illustrates the problem:

BEGIN;
CREATE TABLE t1 AS SELECT zeroblob(2e20);
COMMIT;
PRAGMA integrity_check;

This problem predates SQLite 3.5.1 (circa 2007).