1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
# name: test/sql/storage/wal/wal_view_storage.test
# description: Create and drop a view over different runs
# group: [wal]
require skip_reload
# load the DB from disk
load __TEST_DIR__/view_storage.db
statement ok
set enable_view_dependencies=true
statement ok
PRAGMA disable_checkpoint_on_shutdown
# Make sure the WAL doesn't get flushed by a checkpoint
statement ok
PRAGMA wal_autocheckpoint='1TB';
# Create a schema containing a table and a view
statement ok
CREATE SCHEMA test;
CREATE TABLE test.t (a INTEGER, b INTEGER);
CREATE VIEW test.v AS SELECT * FROM test.t;
# read the info from the view
query IIIIII
PRAGMA table_info('test.v')
----
0 a INTEGER 0 NULL 0
1 b INTEGER 0 NULL 0
# Try to drop the table
statement error
drop table test.t;
----
view "v" depends on table "t".
# Now with CASCADE
statement ok
drop table test.t cascade;
statement error
PRAGMA table_info('test.v')
----
Catalog Error: Table with name v does not exist!
statement ok
CREATE VIEW test.v2 AS SELECT 42
statement ok
DROP VIEW test.v2
loop i 0 2
# restart the system, causing the database to restore from the WAL
restart
# the view no longer exists
statement error
PRAGMA table_info('test.v')
----
Catalog Error: Table with name v does not exist!
statement error
SELECT * FROM test.v
----
# after recreating the table, we can query the view again
statement ok
CREATE TABLE test.t (a INTEGER, b INTEGER);
statement ok
SELECT * FROM test.t
# We created the table, but the view still doesn't exist
statement error
SELECT * FROM test.v
----
Catalog Error: Table with name v does not exist!
statement ok
CREATE VIEW test.v AS SELECT * FROM test.t;
query IIIIII
PRAGMA table_info('test.v')
----
0 a INTEGER 0 NULL 0
1 b INTEGER 0 NULL 0
# Try to drop the table
statement error
drop table test.t;
----
view "v" depends on table "t".
# Now with CASCADE
statement ok
drop table test.t cascade;
statement error
SELECT * FROM test.v2
----
endloop
|