Commit Graph

569 Commits

Author SHA1 Message Date
larrybr
55be21647e Fix straggler misspellings and tidy the custom dictionary. Also include pickups from [forum:/info/c61fb09afd|forum post c61fb09afd].
FossilOrigin-Name: 8c291d99946eb32b20b743921202f9c7cfb716268ff526817b27adbb7942e40b
2023-06-07 17:03:22 +00:00
larrybr
bc91738e66 Add a C-source spell-checking facility. make misspell (on Nix)
FossilOrigin-Name: 26c1bb4bd9e9f56613c3aa87407a7f562fd4ebde5bfd6dece02078001d9a45f8
2023-06-07 08:40:31 +00:00
drh
df542e0500 Enhance PRAGMA integrity_check so that it can detect that a NOT NULL column
contains a NaN value and report that as an error.
dbsqlfuzz f144b642fe6f1a1c196f258ac6e60118a0cb59b2.

FossilOrigin-Name: 7638d9755dc90fd353b874d03ed418fa8aaee4440290ff69b1b552eae84e5baa
2023-03-29 11:36:24 +00:00
drh
3594b2b303 Do not allow constant factoring during PRAGMA integrity_check, since the
constants might be stored in registers that are later reused for other
purposes.  dbsqlfuzz dc9ab26037cf5ef797d28cd1ae0855ade584216d.  Problem
discovered by a new assert() statement added in [6f8b97f31a4c8552].

FossilOrigin-Name: 0bba27b78112b2b2271e498f41c437df985aa2faab302ee5b29d9b60003a8379
2023-03-27 13:24:02 +00:00
drh
aa9192e6aa Improvements to register allocation, especially in the ANALYZE command.
New assert() statements added to help verify that memory allocation is
correct, and to help fuzzer find lingering errors.

FossilOrigin-Name: 6f8b97f31a4c8552312b4c98432ea356ae54c06d9cc929969f50c3c88360cd7b
2023-03-26 16:36:27 +00:00
drh
fe52615925 Fix a vdbe-coverage macro added by [f418bdd627e84e7d].
FossilOrigin-Name: 77f559d2647615379fed55ced5d69ae90515273e59811b92171bdd3089c90a22
2023-03-03 19:56:19 +00:00
drh
1b9db7f32d Enhance PRAGMA integrity_check so that it can detect when there are extra
bytes at the end of an index record, which might cause OP_IdxRowid to
malfunction.  dbsqlfuzz c1aa3986534d5feab8d21f28b3c1712df2ef358ba.  Test case
in TH3.

FossilOrigin-Name: f418bdd627e84e7d494f730d7124d8f4846ebcde031f5b2498685c9aceebb3c8
2023-03-03 18:35:00 +00:00
dan
20438431c8 Fix a problem causing "PRAGMA quick_check" to return spurious corruption errors for a WITHOUT ROWID for which all columns are either virtual or part of the primary key, and for which the order of the columns in the primary key definition is different from the order in the table.
FossilOrigin-Name: a7530f897127f35a212db6557edbcbbb286cc0e094754c1c1b74ce8dbf724470
2023-01-28 17:37:37 +00:00
drh
d0fe0fc531 Enhance PRAGMA integrity_check so that it verifies that the string values
stored in indexes are byte-for-byte identical to the values in the table, and
not just equivalent according to the collating sequence.
dbsqlfuzz 686e2e205e0c0594d3fb524bea0c25e621d1a870.

FossilOrigin-Name: 9302e4bfdce5905576b8f0af7d6b3a864e1dcd58ed89bb303010a1c4f826e915
2023-01-04 15:18:52 +00:00
drh
7e475e571f Disable the ability to change the schema_version cookie when
SQLITE_DBCONFIG_DEFENSIVE mode is enabled.  This is a security
enhancement inspired by the question in
[forum:/forumpost/2b9cc3dae1f1e5f6|forum post 2b9cc3dae1f1e5f6].

FossilOrigin-Name: 1d81381e8f5db5d7064cc313b8544ca3cb1ca9e8cd61e71368a2d2e598befc9c
2022-11-12 17:17:01 +00:00
drh
e995d2c226 Proposed optimization to the IS NULL and NOT NULL operators that avoids
loading the entire content of larges strings and BLOBs.  Response to
[forum:/info/3c08d4715dc05b00|forum post 3c08d4715dc05b00].

FossilOrigin-Name: 45f171565442f9fd6574fb93ae7abe83c168b20be68af42531bc55571450d3ab
2022-10-13 12:47:33 +00:00
drh
c9ef12f62b Code clean-up for the integrity_check enhancement.
FossilOrigin-Name: a140173102febe9ef8064ee9b95bee489db54caba149e577d69e4d75161bf390
2022-10-10 21:21:04 +00:00
drh
db6940ab45 Fix corner-case bugs in the new integrity_check logic. All tests pass now.
FossilOrigin-Name: dbab9d52a842085da67f5d0b8e96c665adc16331accf380b4c234e9b05bdb7fb
2022-10-10 19:38:01 +00:00
drh
49d77ee642 An attempt to enhance PRAGMA integrity check so that it does data type
checking on non-STRICT tables.  Specifically:  (1) Columns with TEXT affinity
should not contain numeric values, and (2) columns with numeric affinity should
not contain text values that can be converted to numeric.

FossilOrigin-Name: 8b1e7f0524637728cebe81c7d3ff8ad8a5a55782eac6409b425dad538024f596
2022-10-10 18:25:05 +00:00
drh
18a3a48db1 Experimental changes to put sqlite3_temp_directory behind a mutex.
FossilOrigin-Name: 5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d
2022-09-02 00:36:16 +00:00
drh
16b03c0196 Enhance the "PRAGMA integrity_check" statement so that it verifies the rows of
a WITHOUT ROWID table are in the correct order.

FossilOrigin-Name: 62f934bff495850d0763e07ffa44a557f066ecba9d039363f32287213cba819f
2022-08-17 18:07:52 +00:00
drh
0348fc722f Minor code simplification in the code generator for PRAGMA integrity check.
FossilOrigin-Name: a3b9c7a6c9be5c78a93e5125f16237d2d84b977eca81f527af0198e96435a995
2022-08-17 17:14:36 +00:00
drh
058e99502a Small performance increase and size reduction by splitting out the
sqlite3VdbeGetLastOp() from sqlite3VdbeGetOp().

FossilOrigin-Name: 92ac01d41d46ab73e189b1e5596ea63e5edb5b15639c5d7bdb981b95366c069b
2022-07-25 19:05:24 +00:00
drh
36d2d09023 Use unpacked keys for OP_Found in foreign key processing.
FossilOrigin-Name: 328dc76657eb5317f0201859d2b3abe6918103b894f7beaed0aca3058a9f2b64
2022-04-04 18:17:59 +00:00
drh
00946d7953 Avoid a harmless uninitialized variable warning in PRAGMA incremental_vacuum.
FossilOrigin-Name: 6d976f90dfe4886c3f4c062151af5c5ca7454d34b71172401b8c67acd2d663a0
2022-04-01 16:22:41 +00:00
drh
ceff761521 Fix a harmless compiler warning.
FossilOrigin-Name: 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b
2022-03-02 01:02:16 +00:00
drh
9606a13432 Invoking SQLITE_TESTCTRL_INTERNAL_FUNCTIONS causes the flags field of the
PRAGMA function_list to show all bits, including internal-use-only bits,
rather than just the bits that are part of the API.

FossilOrigin-Name: ad1be34828726bfef0dbc0ce16090400cf3530e7b5077849af96774d7428387b
2022-02-25 01:23:17 +00:00
drh
0c7d3d399d Remove many redundant checks for sqlite3.mallocFailed now that any OOM should
cause Parse.nErr to be non-zero.

FossilOrigin-Name: 1f7fa46126ea33ed30e93186aff3df51068aeb4be6f79a102bfe8c4e44941d71
2022-01-24 16:47:12 +00:00
drh
a4a871c286 Show the preferred schema table names in the output of "PRAGMA table_list".
FossilOrigin-Name: 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78
2021-11-04 14:04:20 +00:00
drh
5c9290423d Fix an issue in PRAGMA integrity_check associated reporting NULL values in
a NOT NULL column of type ANY in a STRICT table.

FossilOrigin-Name: 5dff1f66731ae35daf9633f8bb3ea942a7c29f4240e57bd2023ee7fc116e7c92
2021-11-03 11:43:09 +00:00
drh
dc88b40285 Fix the previous check-in so that it works with virtual tables that add new
shadow tables the first time they are referenced.

FossilOrigin-Name: f73b499e539b9551a70deecec4fc10c3a4af3830324977861cd0558f9782a1d3
2021-10-21 19:48:14 +00:00
drh
8ef0b84c37 Fix the new "table_list" pragma so that it shows the correct number of
columns for views and virtual tables even when the object has not been
previously used.

FossilOrigin-Name: fb0ed8c55f6362d2639687392a72cc3ed9dc318929e11893edd2a0f023929f7e
2021-10-21 17:01:10 +00:00
drh
bc98f904e3 Update requirement marks. No changes to code.
FossilOrigin-Name: 3a6887a543ac348d1a0d4b7f54b13c9dae929c3fa3408c5a44420943ba8c116f
2021-10-14 17:30:32 +00:00
drh
9966621da1 Use the IsOrdinaryTable() macro, not a test of tnum, to distinguish tables
from views and virtual tables.

FossilOrigin-Name: 6189b7809d774bf697d14e27a4bd961df5c318d261dce97db7801ce83f12c59a
2021-10-11 15:21:42 +00:00
drh
635e6a92a0 Add support for "PRAGMA writable_schema=RESET".
FossilOrigin-Name: a51b305bd068f8d8e85b9fc38d61cdf5957f3a2ad2eb2e77015547910088e681
2021-10-08 16:39:33 +00:00
drh
9d43db5b5c Fix an incorrect assert() on PRAGMA table_xinfo added by the previous check-in.
FossilOrigin-Name: f85cb287c52baa729aeb223038e979a3b74a1eb3d97bf59c01f5417998204f84
2021-10-07 14:19:32 +00:00
drh
f975107437 Protect all accesses to the FuncDef.u and Expr.u unions using nearby
assert()s or branches.

FossilOrigin-Name: 9af863f065e0bef491c2ab7525194505f9516f4e6dfc789d2e3a9d2c2438533a
2021-10-07 13:40:29 +00:00
drh
78b2fa8610 Protect every access to the Table.u union using a nearby assert() or branch.
FossilOrigin-Name: 50e08338aed7ac0cee600098d2ecd4b3b7bfd31a597bb26773badf3d2e2582c8
2021-10-07 12:11:20 +00:00
drh
2e50f67073 Add the "PRAGMA table_list" command with its corresponding eponymous
table-valued function: "pragma_table_list".

FossilOrigin-Name: 2c0e7ae541e9ecb86aa58fa7e7057def8aac1b1af1af1aa80b8bf2d260f9a2f9
2021-09-21 17:26:23 +00:00
drh
94b70d8343 Fix PRAGMA integrity_check so that it does not try to enforce types on
ANY columns in a STRICT table.

FossilOrigin-Name: 57384fda8db43964871be5e48ae1c72c67533046b523f161d60a41fdc8e96b9e
2021-09-08 19:25:21 +00:00
drh
71c770fbda Improved comments. Fewer opcodes for integrity_check on strict tables.
FossilOrigin-Name: 4ee57fb588b41ab76649c605f57c7bcf5b7b638435af458d69f69a8ccbb121e8
2021-08-19 16:29:33 +00:00
drh
9e1209d111 Enhance PRAGMA integrity_check so that it verifies the datatype of
all columns in STRICT tables.

FossilOrigin-Name: 97c9248b3b81facce569bfa3fb405d44a1d1041e87132e8f649458c95620ccb2
2021-08-19 02:58:15 +00:00
drh
cf9d36d1b3 Refactor field names in the Column object, zCnName and zCnColl, to make them
unique and thus easier to find amid all the other code.

FossilOrigin-Name: 8b781dcaf68e0cf12a844708c82eee00193e340195cbca915d077e4846983bf3
2021-08-02 18:03:43 +00:00
drh
f38524d20d Refactor the Table object to reduce its memory footprint.
FossilOrigin-Name: bbb6759bcf6e01d36dfc787a82a610d359f50aaeac8104b73883a84906d54e1f
2021-08-02 16:41:57 +00:00
drh
79cf2b7120 Refactor the way that DEFAULT expressions are stored on columns, in order
to save memory in the common case where the column has no DEFAULT clause.

FossilOrigin-Name: 8646547e54211d44c415663c33775c4268550f8332949c4731a4bb6ec9cc663a
2021-07-31 20:30:41 +00:00
drh
4f16ff9d06 Follow-up to [68db1ff9c44fa9c3]: The number of registers needed by
PRAGMA foreign_key_check was increased too late for an assert() deep
down inside of sqlite3ExprCode().  So move the size increase a little
earlier.
[forum:/forumpost/79c9e4797d|Forum post 79c9e4797d].

FossilOrigin-Name: 7072404ad0267b8ee774b2804ea59ea28e29316521d76d76a701595e51d1be97
2021-07-07 16:48:24 +00:00
drh
5c46a7e555 In the PRAGMA foreign_key_check, ensure that sufficient registers are
allocated for the virtual machine, even if one or more foreign keys reuses
the same column multiple times and has more columns than the table it is part
of.  [forum:/forumpost/a6b0c05277|Forum post a6b0c05277].

FossilOrigin-Name: 68db1ff9c44fa9c37690ce55ad304d4263ba6fac490063d9e08470de6c17cfe6
2021-07-03 02:55:47 +00:00
drh
099b385d17 Do not confuse the constant SQLITE_MAX_ATTACHED with the maximum number of
schemas.  Add the new SQLITE_MAX_DB constant for the maximum number of
schemas.  [forum:/forumpost/a006d86f72|Forum post a006d86f72].

FossilOrigin-Name: 7b65fb9f7bd616f834633afd64b3448bf9ca2b6e4cc6d6c01e75d1d877c88a79
2021-03-10 16:35:37 +00:00
drh
d96e3821e4 Fix a pair of assert()s in "PRAGMA foreign_key_check" that might have given
a false-positive following an OOM.

FossilOrigin-Name: 9ea3039b538ffd0f348c8fbc9452af1fbf899a1f668af9a2404bdd0f8dd21351
2020-09-16 19:48:23 +00:00
drh
99744fa4ab Add support for the sqlite3_txn_state() interface.
FossilOrigin-Name: ad195e3dd89d0f33b50070c18fb8f43c4eb24162515dfdd7c04d9e7d96b902a2
2020-08-25 19:09:07 +00:00
drh
ed109c06e1 Merge support for partial integrity checks.
FossilOrigin-Name: b5443b47af95f4f0ef527bee90f186ee25faa5df197dbcc3e14d48eee095e4aa
2020-07-23 09:14:25 +00:00
drh
17d2d592fb Add the ability to do a PRAGMA integrity_check (or quick_check) on a single
table by specifying the table name as the argument.

FossilOrigin-Name: 65dd321432e8f80bc1cb11be8ca06656b41ac997a74a5eb271c797cf0fbb764e
2020-07-23 00:45:06 +00:00
drh
e9261dbd53 Initial changes to allow database up to 281TB in size.
FossilOrigin-Name: 9cb7da9bdb666ea40771513b89591dca275f1e92092b39190df747e3797178a3
2020-07-20 12:47:32 +00:00
drh
a78d2c0528 Fix the table_info pragma so that it always checks the schema version and
reprepares, even if it is a no-op.

FossilOrigin-Name: 6da77973abc325ae8baf64615267a614a0b8bb8dfd0a01a9f7d6c3a8f359564f
2020-07-04 20:29:56 +00:00
drh
ec1650a239 Fix a problem with "PRAGMA foreign_key_check" where if a table in one
schema appears to have foreign key constraints against another table in
a different schema, the pragma will try to check the constraints even though
they do not apply because they are in different schemas.

FossilOrigin-Name: 81bc4b65ae2a68128b0be75a7a3d4f47f05cc588ff130ba56366ab9b16289228
2020-07-03 12:15:59 +00:00