should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
# name: test/sql/storage/encryption/wal/encrypted_wal_blob_storage.test
# description: Test BLOB with persistent storage with an encrypted WAL
# group: [wal]
foreach cipher GCM CTR
load __TEST_DIR__/any_file.db
statement ok
PRAGMA disable_checkpoint_on_shutdown
statement ok
PRAGMA wal_autocheckpoint='1TB';
# # load the DB from disk
statement ok
ATTACH '__TEST_DIR__/encrypted_blob_storage_${cipher}.db' AS enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
# create a table with hugeints
statement ok
CREATE TABLE enc.blobs (b BLOB);
statement ok
INSERT INTO enc.blobs VALUES('a'), ('\xAA'), ('\xAA\xFF\xAA'), (''), (NULL), ('\x55\xAA\xFF\x55\xAA\xFF\x55\xAA\xFF\x01'), ('\x55\xAA\xFF\x55\xAA\xFF\x55\xAA\xFF\x01')
statement ok
DETACH enc
statement ok
ATTACH '__TEST_DIR__/encrypted_blob_storage_${cipher}.db' AS enc (ENCRYPTION_KEY 'asdf');
query I
SELECT * FROM enc.blobs
----
a
\xAA
\xAA\xFF\xAA
(empty)
NULL
U\xAA\xFFU\xAA\xFFU\xAA\xFF\x01
U\xAA\xFFU\xAA\xFFU\xAA\xFF\x01
restart
endloop

View File

@@ -0,0 +1,45 @@
# name: test/sql/storage/encryption/wal/encrypted_wal_lazy_creation.test
# description: Verify the Encrypted WAL is lazily created when attaching
# group: [wal]
# If we enable alternative verification, then we disable checkpointing on shutdown.
# Thus, we'll keep the WAL alive when detaching the database.
foreach cipher GCM CTR
require no_alternative_verify
require noforcestorage
require skip_reload
statement ok
ATTACH '__TEST_DIR__/attach_no_wal_${cipher}.db' AS attach_no_wal (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
CREATE TABLE attach_no_wal.integers(i INTEGER);
statement ok
INSERT INTO attach_no_wal.integers FROM range(10000);
statement ok
DETACH attach_no_wal;
statement ok
ATTACH '__TEST_DIR__/attach_no_wal_${cipher}.db' AS attach_no_wal (ENCRYPTION_KEY 'asdf');
# Verify that we don't have a WAL after attaching.
query I
SELECT COUNT(*) FROM glob('__TEST_DIR__/attach_no_wal_${cipher}.db.wal');
----
0
# Verify that we checkpointed the WAL.
query I
SELECT COUNT(*) FROM attach_no_wal.integers;
----
10000
restart
endloop

View File

@@ -0,0 +1,133 @@
# name: test/sql/storage/encryption/wal/encrypted_wal_pragmas.test
# description: test encrypted wal debug PRAGMAS
# group: [wal]
foreach cipher GCM CTR
load __TEST_DIR__/any_wal_db.db
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
PRAGMA disable_checkpoint_on_shutdown
statement ok
PRAGMA wal_autocheckpoint='1TB';
# create a table and add a column to it
statement ok
CREATE TABLE enc.test (a INTEGER, b INTEGER);
statement ok
INSERT INTO enc.test VALUES (11, 22), (13, 22), (12, 21)
statement ok
ALTER TABLE enc.test ALTER b TYPE VARCHAR
query IT
SELECT * FROM enc.test ORDER BY 1
----
11 22
12 21
13 22
statement ok
INSERT INTO enc.test VALUES (10, 'hello')
statement ok
DETACH enc
# WAL replay succeeds
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf');
statement ok
DETACH enc
# now set debug pragma at the start
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_new_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
PRAGMA disable_checkpoint_on_shutdown
statement ok
PRAGMA wal_autocheckpoint='1TB';
statement ok
CREATE TABLE enc.test (a INTEGER, b INTEGER);
statement ok
INSERT INTO enc.test VALUES (11, 22), (13, 22), (12, 21)
statement ok
ALTER TABLE enc.test ALTER b TYPE VARCHAR
query IT
SELECT * FROM enc.test ORDER BY 1
----
11 22
12 21
13 22
restart
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_new_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf');
query IT
SELECT * FROM enc.test ORDER BY 1
----
11 22
12 21
13 22
restart
# now disable, but then directly enable
# this should work
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_disable_enable_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
PRAGMA wal_autocheckpoint='1TB';
statement ok
CREATE TABLE enc.test (a INTEGER, b INTEGER);
statement ok
INSERT INTO enc.test VALUES (11, 22), (13, 22), (12, 21)
statement ok
ALTER TABLE enc.test ALTER b TYPE VARCHAR
query IT
SELECT * FROM enc.test ORDER BY 1
----
11 22
12 21
13 22
statement ok
INSERT INTO enc.test VALUES (10, 'hello')
restart
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_disable_enable_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
query IT
SELECT * FROM enc.test ORDER BY 1
----
10 hello
11 22
12 21
13 22
restart
endloop

View File

@@ -0,0 +1,76 @@
# name: test/sql/storage/encryption/wal/encrypted_wal_restart.test
# description: test wal restart
# group: [wal]
foreach cipher GCM CTR
load __TEST_DIR__/any_wal_db.db
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
PRAGMA disable_checkpoint_on_shutdown
statement ok
PRAGMA wal_autocheckpoint='1TB';
# create a table and add a column to it
statement ok
CREATE TABLE enc.test (a INTEGER, b INTEGER);
statement ok
INSERT INTO enc.test VALUES (11, 22), (13, 22), (12, 21)
restart
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
statement ok
PRAGMA disable_checkpoint_on_shutdown
statement ok
PRAGMA wal_autocheckpoint='1TB';
statement ok
ALTER TABLE enc.test ALTER b TYPE VARCHAR
query IT
SELECT * FROM enc.test ORDER BY 1
----
11 22
12 21
13 22
statement ok
INSERT INTO enc.test VALUES (10, 'hello')
query IT
SELECT * FROM enc.test ORDER BY 1
----
10 hello
11 22
12 21
13 22
restart
# statement error
# ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'xxxx', ENCRYPTION_CIPHER '${cipher}');
# ----
statement ok
ATTACH '__TEST_DIR__/encrypted_wal_restart_${cipher}.db' as enc (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER '${cipher}');
query IT
SELECT * FROM enc.test ORDER BY 1
----
10 hello
11 22
12 21
13 22
endloop
restart