summaryrefslogtreecommitdiff
path: root/test/sql/bdb_pragmas.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql/bdb_pragmas.test')
-rw-r--r--test/sql/bdb_pragmas.test194
1 files changed, 192 insertions, 2 deletions
diff --git a/test/sql/bdb_pragmas.test b/test/sql/bdb_pragmas.test
index 4d1c2b00..eca3a655 100644
--- a/test/sql/bdb_pragmas.test
+++ b/test/sql/bdb_pragmas.test
@@ -257,7 +257,7 @@ do_test bdb_pragma-5.3 {
} {100}
# Test invalid value
-if {$tcl_platform(wordSize) == 4} {
+if {$tcl_platform(pointerSize) == 4} {
# On 32-bits platform, the max memory size is (4GB - 1),
# Too-large size will be truncated.
do_test bdb_pragma-5.4 {
@@ -283,7 +283,7 @@ do_test bdb_pragma-5.5 {
} {1 {Invalid value bdbsql_shared_resources -1}}
# Test invalid value
-if {$tcl_platform(wordSize) == 4} {
+if {$tcl_platform(pointerSize) == 4} {
# On 32-bits platform, the max memory size is (4GB - 1)
do_test bdb_pragma-5.6 {
execsql {
@@ -494,5 +494,195 @@ do_test bdb_pragma-7.10 {
}
} {1 {Cannot set bdbsql_single_process after accessing the database}}
+# Test that pragma bdbsql_log_buffer
+#
+reset_db
+
+# Check the initial value
+do_test bdb_pragma-8.1 {
+ execsql {
+ PRAGMA bdbsql_log_buffer;
+ }
+} {0}
+
+do_test bdb_pragma-8.2 {
+ execsql {
+ CREATE TABLE t1(x);
+ PRAGMA bdbsql_log_buffer;
+ }
+} {32000}
+
+reset_db
+
+# Set the value and confirm it sticks.
+do_test bdb_pragma-8.3 {
+ execsql {
+ PRAGMA bdbsql_log_buffer=1048576;
+ }
+} {}
+
+do_test bdb_pragma-8.4 {
+ execsql {
+ PRAGMA bdbsql_log_buffer;
+ }
+} {1048576}
+
+do_test bdb_pragma-8.5 {
+ execsql {
+ CREATE TABLE t1(x);
+ PRAGMA bdbsql_log_buffer;
+ }
+} {1048576}
+
+# Check for reasonable error after open
+do_test bdb_pragma-8.6 {
+ catchsql {
+ PRAGMA bdbsql_log_buffer=64000;
+ }
+} {1 {Cannot set bdbsql_log_buffer after accessing the database}}
+
+# Test the pragma large_record_opt, which enables blob files
+#
+reset_db
+
+set ::blob_dir "test.db-journal/__db_bl"
+
+# Note, the subdirectory structure may change in the future.
+set ::blob_file_dir "$::blob_dir/__db1"
+set ::blob_sub1_dir "$::blob_file_dir/__db5"
+set ::blob_sub2_dir "$::blob_file_dir/__db8"
+set ::blob_sub3_dir "$::blob_file_dir/__db10"
+set ::blob_file "$::blob_sub1_dir/__db.bl002"
+
+# Check the initial value
+do_test bdb_pragma-9.1 {
+ execsql {
+ PRAGMA large_record_opt;
+ }
+} {0}
+
+# Set to 100 bytes
+do_test bdb_pragma-9.2 {
+ execsql {
+ PRAGMA large_record_opt=100;
+ }
+} {100}
+
+# Enable multiversion, which is illegal with blobs
+do_test bdb_pragma-9.3 {
+ set v [catch { execsql {
+ PRAGMA multiversion=ON;
+ }} msg]
+ lappend v $msg
+} {1 {Cannot enable both multiversion and large record optimization.}}
+
+# Blobs and encryption cannot be enabled together.
+if {[sqlite3 -has-codec] == 0} {
+ # Create a table and add a record < 100 bytes, which is too
+ # small to be a blob file
+ do_test bdb_pragma-9.4 {
+ execsql {
+ create table t1(blob a);
+ insert into t1 values(zeroblob(10));
+ }
+ } {}
+
+ # Check that the blob directory exists
+ do_test bdb_pragma-9.5 {
+ file exists $::blob_dir
+ } {1}
+
+ # Check that the blob file directory does not exist
+ do_test bdb_pragma-9.6 {
+ file exists $::blob_file_dir
+ } {0}
+
+ # Add a record > 100 bytes, which will create a blob
+ # file.
+ do_test bdb_pragma-9.7 {
+ execsql {
+ insert into t1 values(zeroblob(1000));
+ }
+ } {}
+
+ # Check that the blob subdirectory exists
+ do_test bdb_pragma-9.8 {
+ file exists $::blob_sub1_dir
+ } {1}
+
+ # Disable blobs by setting the value to 0
+ do_test bdb_pragma-9.9 {
+ execsql {
+ PRAGMA large_record_opt=0;
+ }
+ } {0}
+
+ # Create a table and add a record > 100 bytes
+ do_test bdb_pragma-9.10 {
+ execsql {
+ create table t2(blob a);
+ insert into t2 values(zeroblob(10000));
+ }
+ } {}
+
+ # Check that the blob subdirectory does not exist
+ do_test bdb_pragma-9.11 {
+ file exists $::blob_sub2_dir
+ } {0}
+
+ # Close and reopen, the large_record_opt value will be
+ # reset to 0, which will cause all new tables to be
+ # created without blob support, while existing tables
+ # with blob support will still support blobs.
+ do_test bdb_pragma-9.12 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ insert into t1 values (zeroblob(10000));
+ }
+ } {}
+
+ # Check that a blob file was created
+ do_test bdb_pragma-9.13 {
+ file exists $::blob_file
+ } {1}
+
+ # Create a new table and add a record > 100 bytes,
+ # since large_record_opt == 0, this table will not
+ # support blobs.
+ do_test bdb_pragma-9.14 {
+ execsql {
+ create table t3(blob a);
+ insert into t3 values(zeroblob(10000));
+ }
+ } {}
+
+ # Check that a blob directory does not exist for this database
+ do_test bdb_pragma-9.15 {
+ file exists $::blob_sub3_dir
+ } {0}
+}
+
+reset_db
+
+# Test the encryption pragma, "key". When encryption is enabled the test suite
+# automatically sets the key to "1234". In this test the pragma is used to
+# change the key before creating the database, then attempts to re-open the
+# data with the default key, resulting in an "access denied" error.
+if {[sqlite3 -has-codec]} {
+ do_test bdb_pragma-10.1 {
+ execsql {
+ PRAGMA key="1111";
+ create table t1(a);
+ }
+ db close
+ sqlite3 db test.db
+ set v [catch { execsql {
+ create table t2(a);
+ }} msg]
+ lappend v $msg
+ } {1 {access permission denied}}
+}
+
finish_test