Commit Graph

23182 Commits

Author SHA1 Message Date
drh
b4d9b2b537 Demonstration code to show how NOT NULL and CHECK constraints can be
verified after an ALTER TABLE ADD COLUMN.

FossilOrigin-Name: 039f540373b03af9e0c87499e5e0423eb093d1d343829282a5ac1de2d600b881
2021-07-20 07:35:07 +00:00
drh
53fa02507b It does not work to deserialized into TEMP, so do not allow it. The
sqlite3_deserialize() routine now returns SQLITE_ERROR if you try.

FossilOrigin-Name: 18068cc60698d4944a9d682cdf34b14b4d4b32f043f8d584dbf41c2bb5ac6220
2021-07-20 02:02:24 +00:00
mistachkin
f5b70d06ea Fix compilation of 'threadtest3' for some older versions of MSVC.
FossilOrigin-Name: b5ede6a68891820bd5b6d051b1b641bc1cd49104cad2466db184134d14f58f5b
2021-07-20 00:18:22 +00:00
drh
de3246176b More precision in comparing integers and floating point values while
processing the integer primary key for OP_SeekGE and similar.
[forum:/forumpost/2bdb86a068|Forum post 2bdb86a068].

FossilOrigin-Name: f9c6426de3b413ff8fcf04a00931ca5f123f996c572b35181af114afa8d811d7
2021-07-19 20:52:31 +00:00
dan
bb2d2a50f9 Updates so that "threadtest3[.exe]" can be built for windows with MSVC.
FossilOrigin-Name: 4ce585fb07274284e3add6adcb66ed06e4b109584704d1ec7152bf43ca8d5d85
2021-07-19 16:49:13 +00:00
dan
73983658c9 In defensive mode, allow statements that write to shadow tables to be prepared from with virtual-table xSync() calls.
FossilOrigin-Name: c8601d83fbecf84ca7991d339449b380deb5a7620dc84756a91c2880f030b423
2021-07-19 14:00:29 +00:00
mistachkin
05de5048b4 Fix minor spacing issues in the MSVC makefile.
FossilOrigin-Name: d78c272b3966cc1b12bc7e83fbe909a3c517d553a942d7f1c07bddf69f2e2164
2021-07-19 03:38:13 +00:00
drh
ef8344c6a5 Try to omit the ORDER BY clause in subqueries if doing so does not change
the result in any way. See
[forum:/forumpost/2d76f2bcf65d256a|Forum post 2d76f2bcf65d256a] for
details and history.

FossilOrigin-Name: 85ddaf1b59a19cbd9efe7724a163b30c14bafabfaf2cfced07b463e76f73e494
2021-07-16 22:43:00 +00:00
drh
ee612e2a5d Minor comment improvements.
FossilOrigin-Name: 6854b5919beefa43da21ba739e82d583183c8cdfe5dd63e27a810ac1ffe2330b
2021-07-16 20:16:19 +00:00
larrybr
d51a2d8b8f De-typo sqlite3_expanded_sql() doc
FossilOrigin-Name: 56b0f5418dad34d1e83d53741916e2a38a5448369031d959b8a44867774be657
2021-07-16 17:11:21 +00:00
drh
e46ec734c7 Modify the generate_series() table-valued functions so that its first
argument (the START value) is required.  Throw an error if that argument
is not supplied.  In this was the series.c loadable extension can be used
as a demonstration of how to code an xBestIndex function to require certain
parameters.  Compile with -DZERO_ARGUMENT_GENERATE_SERIES to obtain the
legacy behavior.

FossilOrigin-Name: 459d85a2898d6a53f43b4ad48d2f39edd1bbe37a4f97426a5d666c39c52576a4
2021-07-16 17:04:17 +00:00
drh
111c3cc9fb Fix the "main.mk" makefile so that "series.c" is a dependency of "shell.c".
FossilOrigin-Name: ff959917918495ef352ce48c240b1de6da162f2a5e76e37dcc53fa50bce27642
2021-07-16 15:30:19 +00:00
drh
0fb78f0cca Get the "omit ORDER BY in FROM-clause subqueries" optimization working for the
core test cases.

FossilOrigin-Name: e31c5888659ffd4c6d8b68627123df3bbb84bb010b7766b0a74877bf3ba1e52b
2021-07-16 01:19:19 +00:00
mistachkin
e13dfe4b19 By default, do not emit #line directives in the amalgamation.
FossilOrigin-Name: bacfa93677fbe014737fab7dbdb4e7a168a310bc5b914b17896ae2a48435c7b1
2021-07-15 23:34:14 +00:00
drh
bb30123178 Attempt to omit ORDER BY clauses from FROM-clause subqueries if those ORDER BY
clauses do not affect the output.  See
[forum:/forumpost/2d76f2bcf65d256a|forum thread 2d76f2bcf65d256a] for
discussion.  This can help the query flattener in
some cases, resulting in faster query plans.  The current implemention does
not always work.

FossilOrigin-Name: ef97c3e7c3ea2cf1a4db6591328fe7ce3f1d189afc2d578159135824ec89e620
2021-07-15 19:29:43 +00:00
drh
480f5e3e6e Change references to the schema table in sqlite3_analyzer to the new
SQLITE_SCHEMA name.

FossilOrigin-Name: 3beb77d6a792d07ca605ec8e5402b8a305860cba4044fcafeed00b9fa862fa16
2021-07-15 16:39:42 +00:00
dan
20235e56f7 Fix a use-after-free error in ioerr.test caused by an error in test code.
FossilOrigin-Name: 1594056aab068b9fae82f6b885828c7127d9bedcc37c4340486e32791bc87c7a
2021-07-14 21:18:31 +00:00
mistachkin
acae2b485e Enhance comments pertaining to the interface linkage / calling convention macros.
FossilOrigin-Name: c378e99250fe06fae8ca40c62185b607f004d6806e07dbb9f964dd849b4e55f8
2021-07-13 22:49:02 +00:00
mistachkin
696555d7b5 Further revisions to #line handling for amalgamation builds.
FossilOrigin-Name: 9a84321229ad499ee0f7c85732c2728afb4476c72073a510401a559dda9be38f
2021-07-13 21:59:22 +00:00
larrybr
06a0ea9a68 Get correct #line tags into amalgamation for other builds too.
FossilOrigin-Name: 999eb80018f1bb8a8ad73483610400faf5fb37b1be446ce30edbf7028340f50b
2021-07-13 20:55:26 +00:00
larrybr
09b2196d97 Get #line tags into amalgamation, subject to configure.
FossilOrigin-Name: 5d81b598a7cd2cea2553fdf6ca38d2f65f0f1b2d5a8eea8a01c1800f68aa2422
2021-07-13 11:59:17 +00:00
larrybr
4902235796 Merge from trunk, rename tool option for its effect
FossilOrigin-Name: 9327f73c1b87fb9ca78e261d16b092763f497bb9c6f9784a33eabdc961b06343
2021-07-13 11:55:07 +00:00
dan
f1cacb76b7 Do not attempt to run Tcl sessions tests unless both SQLITE_ENABLE_PREUPDATE_HOOK and SQLITE_ENABLE_SESSIONS are defined.
FossilOrigin-Name: 385db794477e046b5dde726489375786d7565b113084f6e730efb050b08f9a6e
2021-07-13 11:30:46 +00:00
larrybr
4b1c3eb5f9 Amalgamation has #line directives by default. Minor mksqlite3c.tcl changes
FossilOrigin-Name: ba3eff71973064cbc0ddf51aa822a246c162bbb65387e9523692c60e5340acda
2021-07-13 01:45:04 +00:00
larrybr
a73c306065 Clarify comment on sqlite3.h's interface decaration macros.
FossilOrigin-Name: 7cb09aef49c0b98c0c5e332d953a2eeb71ae9e243b1e37ab1c8ed4af15d46f50
2021-07-09 23:12:42 +00:00
dan
8eed584786 Fix an assert() that might fail if sqlite3_create_function_v2() is invoked with NULL xStep and xFinal callbacks and a non-NULL xDestroy.
FossilOrigin-Name: ab1550a608684b6b9104b555a975482cfabca5053b7d7dcc60d63a0e3a8d707d
2021-07-09 14:59:12 +00:00
drh
62f560f805 Enhance the sqlite3_create_function() interfaces to assume a value of
SQLITE_UTF8 is presented with a nonsense value for the preferred encoding.
This is undocumented behavior added for robustness.

FossilOrigin-Name: c1bb5cff527af6a97b025d646581c68ac9b56924ae199f86964026a7bc9724fd
2021-07-09 13:52:01 +00:00
dan
f33e7795b3 Add the usual "#ifdef __cplusplus" magic to header file ext/misc/carray.h. Also update carray.h/carray.c to use SQLITE_API in the usual way.
FossilOrigin-Name: 0f97c2a459bfadc2fe19e710e8845039b4434010656d311074b9594b02d0826a
2021-07-09 11:52:53 +00:00
larrybr
a13c0c73c5 Allow CLI shell build to #include same user-specified header as library build.
FossilOrigin-Name: eb8af9a494fb68c0a1c600b3ac71467645b51b296fc6e2116d7d855319d59a59
2021-07-09 00:12:05 +00:00
mistachkin
b523159f40 Rename optional SQLITE_CUSTOM_INC define to SQLITE_CUSTOM_INCLUDE.
FossilOrigin-Name: 060aec37accae858ced5b081a2ff76dccdd8f8bcefc63d1fe2e7478257c69e76
2021-07-08 23:35:20 +00:00
larrybr
f382e1dc59 Allow library build to #include a user-specified header.
FossilOrigin-Name: 71e6490bbe59939cd15f0094e507dd8a2e167fdd8de675c3ebfeaf528a01f87a
2021-07-08 22:12:27 +00:00
dan
bd24e8faa3 Preserve and return to the user any error message returned by a failed xConnect() call on an eponymous virtual table that prevents a query from being compiled.
FossilOrigin-Name: bbbbeb59a6a14b94dcbaf218cbcfbd39feba4a1df5b37c0e1a955391393eeec4
2021-07-08 18:29:25 +00:00
drh
77ea22300b Fix an issue with the SQLite Expert extension when a column has no
collating sequence.
[forum:/forumpost/78165fa250|Forum post 78165fa250].

FossilOrigin-Name: b1e0c22ec981cf5f8a6597abc6711b1a25019dd51de31129fbc504d3dc743bb4
2021-07-08 12:12:39 +00:00
drh
9d41caf361 Fix a harmless compiler warning in the "fuzzcheck" test program.
FossilOrigin-Name: 8c432642572c8c4b7251f413def0725b3b8e9e7fe10230aa0aabe86b58e5902d
2021-07-07 19:44:32 +00:00
drh
7098859031 Fix a harmless compiler warning - duplicate local variable named "pRHS".
FossilOrigin-Name: 5bc05faf279e0c98be83cb6d56f669a60ff515c8244fca6280991ed0dc5e7ae7
2021-07-07 19:40:18 +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
dan
2931a66ece Fix a recently introduced segfault that might occur if a sub-select were used as a term on the RHS of an IN(...) operator for which the LHS is a row-value.
FossilOrigin-Name: f586c06a5d03943db32add4d3d058a5aa09c819870b29cd8b54cf69433a8cdb1
2021-07-07 15:52:44 +00:00
dan
74777f994d Improve the error message in cases where there is a row-value on the LHS of an IN() operator, the RHS is a list (not a sub-select) and at least one element of the list is not a row-value with the correct number of elements.
FossilOrigin-Name: 6b22f4e71dbc14c887ebbda67095b5faaa8079cac87cd4ab5a2ae90c71cd9633
2021-07-07 13:53:55 +00:00
dan
cc516af4cc Instead of disallowing writes to fts5 tables if there are fts5vocab cursors open on them (commit [c49a6ed7]), abort any fts5vocab queries if the on-disk structure of the fts5 table changes.
FossilOrigin-Name: 9dbdc9001e3258e71ca995fbcdebf66ab95890ded87fa7125c6cb4bd43010aaf
2021-07-07 11:51:03 +00:00
dan
9289f5103d Handle "<vector> IN (<vector>, <vector> ...)" in the same way as "<vector> IN (VALUES(<vector>, <vector>, ...)".
FossilOrigin-Name: 981d230ece98ce89502dab02aa44f73699a9d0e4fce3e9e9dfd47444a5a9990f
2021-07-06 20:44:32 +00:00
dan
b9324fea07 Do not allow writes to an fts5 table if there are any open fts5vocab cursors.
FossilOrigin-Name: c49a6ed78a917d4972e048e2a9bbe4d400691f97ce7e022f0e4436ceaed7fb73
2021-07-05 19:01:09 +00:00
drh
a612c1c9bc Add the ATOMIC_INTRINSICS compile-time output output. Move sqlite3Int.h
in front of ctime.c so that default values that are not overridden are
shown in PRAGMA compile-time option output.

FossilOrigin-Name: e306952690bfb140e2c404a74b05ff2d070c487f7e52c62d62a004505fba0e15
2021-07-05 18:37:37 +00:00
dan
0f56f891dd Revert [5204c2c4a7b73a64], restoring the old pre-processor logic for determining the availability of the __atomic_store_n()/__atomic_load_n() primitives.
FossilOrigin-Name: e690abb9e4e189c41182ac813115d55d811135013f5ce94ec0c45a547597f8ad
2021-07-05 17:15:38 +00:00
dan
5daf69e5f4 Allow sub-queries in the FROM clause of an UPDATE...FROM statement to access the object being updated without using an alias, as is required in the parent query.
FossilOrigin-Name: 740cb43025449b7d7b47a97ad00885e54b7701cbcb14f4a50c7523022e3936d5
2021-07-05 11:27:13 +00:00
drh
e46292a920 Improved rebustness in sqlite3ExprListDup() when it contains a vector assignment
from an UPDATE where the initial term is omitted.  This can happen during a
UNION ALL query flattening while processing a virtual table update in which
the first term of the vector is repeated.
[forum:/forumpost/16ca0e9f32|Forum post 16ca0e9f32].

FossilOrigin-Name: 2547cfe38f8fb35109b3fc5bdfada387fe4b2b8a304156b704ab7f03f1f71198
2021-07-05 02:40:29 +00:00
drh
10f08270e1 Ensure that TK_SELECT_COLUMN Expr nodes always have their iTable field set to
to the number of columns in the vector. This is not strictly necessary. It
just simplifies the state description and make the code easier to reason about.

FossilOrigin-Name: 026f08d4cff19a95e0f38f2ef431cacd65c7c77ed92e30d7f2ded84651f47150
2021-07-05 01:11:26 +00:00
drh
105c4b5ced Fix an incorrect comment on testcase misc1-27.0. No changes to code.
FossilOrigin-Name: 49829ae3229b7c7c7adeaa970a84aebd5157bc93b38fd6d80d86cc03f5fdde6f
2021-07-05 00:07:39 +00:00
drh
4a4e02bc52 Enhance the treeview debugging mechanism so that it correctly deals with
TK_ROW expression nodes.

FossilOrigin-Name: e87fdb6514b6f6775a5a36ca0ec5c920eeaba9e3b842dffa327e970b27cd036d
2021-07-04 22:33:08 +00:00
drh
24384d88d6 Fix a (harmless) typo in a comment. No code changes.
FossilOrigin-Name: d2b9b8daa3b87c3dba1329e2f2f44b60d6b5bb9a49d741045aa20cc7813446b2
2021-07-03 18:57:40 +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
dd51365408 Put ALWAYS() on a branch that is always true due to [d4097364c511709b].
Fix a testcase precondition associated with the same check-in.

FossilOrigin-Name: 55e2fbebb0a2c9991feef46f31e79b82a24de272aae836bf4d3c06ee06ef1a70
2021-07-02 12:25:30 +00:00
drh
4d466698a2 Fix a harmless assertion fault discovered by
[https://oss-fuzz.com/testcase-detail/5517690440646656|OSSFuzz].  The
assertion fault is harmless because the assert() checks a condition that
that is harmless if false and the assert() is disabled in production
builds.

FossilOrigin-Name: 79443aabe1db8cc2ff9537fde0dac0e858eae3f3848ee9cc1b8fba47b824bf08
2021-07-02 12:08:12 +00:00
dan
b9248ef5c7 Allow unqualified "rowid" references to be used in join queries, provided that only one of the source objects has a rowid.
FossilOrigin-Name: d4097364c511709b1874881a0c036640777d1f724165416adf6f53a41f8c6e40
2021-07-01 18:19:17 +00:00
drh
3832ac9f51 Import the updated nmakehlp.c file used by the TCL Extension Architecture (TEA)
builds in the amalgamation tarballs.
[forum:/forumpost/5a5001f20a|Forum post 5a5001f20a].

FossilOrigin-Name: 595bf95bf8884c545e85e3feee6f43503b59d3c6d69073f0aaba4473c7c61cac
2021-07-01 16:57:48 +00:00
dan
90d3b24a16 Fix a memory leak in fts5 that could occur when processing a query containing multiple classes of error.
FossilOrigin-Name: 7c279670f544a5bb9733a88862d9e490062b07415cd790e0d6d1e2cb584d2007
2021-06-30 14:04:25 +00:00
dan
c629e21786 Fix an assert() in fts5 that might fail when dealing with corrupt records.
FossilOrigin-Name: 9e760e256089c0ebbf816a8de8b186f62e1ffcd6b8b0e76dab8387798cd4d0e1
2021-06-30 12:11:19 +00:00
drh
14a1b1c132 Do not enforce the SQLITE_LIMIT_FUNCTION_ARG limit for internally generated
SQL.  This prevents problems with statements like ALTER TABLE if the
function argument limit is set too low.
[forum:/forumpost/17735aa21f3ddab2|Forum post 17735aa21f3ddab2].

FossilOrigin-Name: 763fdec5b3151eeab001c50e78f654cd9b4b4c10e81e50a663046a70e64d5339
2021-06-30 11:53:21 +00:00
dan
cf1e25566b When generating data for a RETURNING clause, avoid assuming cursor number 0 is available for use.
FossilOrigin-Name: 4b2c59acce6ff1bb6c9c04c45c80945ae23a26588718cc20635d60f7497adabb
2021-06-28 15:25:17 +00:00
drh
4422b3a646 The OP_ReopenIdx opcode should clear the cursor if the cursor is being
reused.  This prevents leaving the cursor in an initialized state which
could cause problems for a subsequent OP_SeekScan opcode.
Fix for ticket [6dcbfd11cf666e21] and the OP_SeekScan optimization
of check-in [4a43430fd23f8835].

FossilOrigin-Name: d4bf5243f2bf0a2bc77ad12f3e1e4797cb62f2745f9d54eee5f675c3b5f80880
2021-06-25 14:48:24 +00:00
drh
81640a226e Remove a redundant "ANALYZE" line from the ".fullschema" output.
FossilOrigin-Name: 7b47f420954000ce46d05adde6e91a2fbdab8dd528ebd8089cca4fcf9d8a3605
2021-06-25 11:21:21 +00:00
drh
69935c0935 Fix a bug in the ".fullschema" dot-command of the CLI brought to light by
check-in [a2ddb89b206c1387] - raising an error on at attempt to access the
rowid of a subquery or view.

FossilOrigin-Name: 36875827a416067e1b8ffba0ff0ff88313177f8d84dd8e5bc9c23ea3f2d587ba
2021-06-25 11:14:10 +00:00
larrybr
83cb9eb48e Document sqlite3_wal_hook() return.
FossilOrigin-Name: 8acaf7964551b4524fcdbb8d01fae7b0911508ecf6dcf23c3e0f8d8c790b78d8
2021-06-25 00:25:38 +00:00
drh
dff34ab96f Allow the SQLITE_OPEN_EXCLUSIVE flag in sqlite3_open(). Return the
SQLITE_CANTOPEN_EXISTS extended code to indicate that the open failed because
the database already exists.

FossilOrigin-Name: d091150ff80709a1e50e0431aa33021f036979e4a88e9769eeec431dfad6d5f5
2021-06-24 18:23:54 +00:00
larrybr
c06836c3b1 Make conditional nature of sqlite3_normalized_sql() better known.
FossilOrigin-Name: 0e0ece7111945d61278e60385f883303b593ed0d64beeb951b9c49f243531628
2021-06-23 17:41:38 +00:00
larrybr
10496f7657 Fully incorporate *_changes64() API improvement.
FossilOrigin-Name: 6699a2f6bec9dfcdc456ff1cd8e652588b144ec28b7eac6e403a63eab61b416e
2021-06-23 16:07:20 +00:00
drh
9b9f235165 Show CROSS JOINs in the TreeView debuggingn output.
FossilOrigin-Name: 72e09b6c9b74c8226b231fec021228af6bc191fc1b5798d0ff2e893f4ba203bf
2021-06-23 11:39:00 +00:00
dan
a261c02d44 Fix a problem handling ORDER BY terms of the form "ORDER BY likely(<integer>)" within window frames.
FossilOrigin-Name: 710f75b98bb4ac5bfdfa745c1de832dd1e4d9fb387da52b2f0d1353613f5cdc3
2021-06-23 11:12:48 +00:00
drh
415ac68ae8 When an index is used by all branches of the WHERE_MULTI_OR optimization and
becomes a covering index, make sure the index has been created prior to
NULLing it in the OP_NullRow opcode of a LEFT JOIN.  See
[forum:/forumpost/0575376e07|forum post 0575376e07]. The covering-index for
WHERE_MULTI_OR optimization was added by [62678be3df35cdcb].  Test cases are
in the orindex01.test module of TH3.

FossilOrigin-Name: 787c76a865dc51dbca4f30432d64783199c2efb1df4619e4bbaf32182977321e
2021-06-22 23:24:58 +00:00
dan
2c7188732d Add the sqlite3_changes64() and sqlite3_total_changes64() API functions.
FossilOrigin-Name: 48fdec22c966003f5577e0bf52906ef90df11e4e395723a646304e67ed976f37
2021-06-22 18:32:05 +00:00
dan
020c4f3830 Fix a problem causing sqlite3_changes() to return an incorrect value following a "DELETE FROM tbl" command on an intkey table (because internal b+tree cells were being included in the count).
FossilOrigin-Name: f662ff4746aaa43e63e20710b8cbfeeceab3183e953ac1685c41846d2e9d124c
2021-06-22 18:06:23 +00:00
dan
b9f8a187de Ensure that the cell array used in balance_nonroot() is always large enough, even if the pages being balanced are corrupt.
FossilOrigin-Name: 53f64e83b39cb56ac7211ffc80d06da13318e1da9dbca7b9123954f5be229a0d
2021-06-22 14:59:34 +00:00
drh
4d2c20331a Load recent dbsqlfuzz cases into test/fuzzdata8.db.
FossilOrigin-Name: a766bba0eead47e9ff24b6afd152a7fbd331261e04dd76feb9510585a08c5786
2021-06-20 22:52:51 +00:00
drh
b915418134 Remove a NEVER() that is reachable by a corrupt database.
dbsqlfuzz 8456a0f88e39a49fb675d8f77394979ebb2a03c1.  Test case in TH3.

FossilOrigin-Name: 1c41e86fa102ec2b73fb7a55357ba6328fda37af316215e8808be88e2d1fd75f
2021-06-20 22:49:26 +00:00
drh
41d26396bb Do not allow an SQLITE_CORRUPT error to mask a prior SQLITE_IOERR in
balance_nonroot().  dbsqlfuzz 5e1c86e7f18023f2b9abe3429977d7ea726f50d8

FossilOrigin-Name: 50e818767e423991b99b3155cb15a0d1c1b744ab6139a8273f9348aab9a53d9c
2021-06-20 22:17:49 +00:00
drh
5d8ade1f67 Remove unnecessary (redundant) variable initialization from
sqlite3BtreeInsert() for a small size reduction and performance increase.

FossilOrigin-Name: 70d1836474207fa045ff7aa513839c9df26ea6e180eb898b30d89bd5b3833f58
2021-06-19 20:20:23 +00:00
drh
f51bad45f0 The previous check-in is a significant change to btree, so go ahead and
increment the version number for the next development cycle.

FossilOrigin-Name: 2eb6697051c13bf0cc3772fd6c16bfdea0be3b01c0d985e05004c04eaf7a4a48
2021-06-19 18:35:20 +00:00
drh
42a410dcad Split the sqlite3BtreeMovetoUnpacked() routine into two separate routines
sqlite3BtreeTableMoveto() and sqlite3BtreeIndexMoveto(), since we usually
know the type of btree in advance.  This results in less branching and
better performance.

FossilOrigin-Name: 3b0d34e5e5f9a16c3397e4551f3b534729b1b375770f05f6ed5847818b1f4c0b
2021-06-19 18:32:20 +00:00
drh
6d72858e79 Version 3.36.0
FossilOrigin-Name: 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5
2021-06-18 18:36:39 +00:00
drh
9c32c914b8 Add an ALWAYS on a branch in STAT4-only logic that is now always
true due to check-in [c21bc5a2353e660f].

FossilOrigin-Name: 7bd55eee1ac63cf6d5699ce85bc5a29bf51afdf7a80bce44937fa833947a40f4
2021-06-16 19:23:24 +00:00
dan
755708538d Omit a handful of tests from pager1.test when testing SQLITE_ENABLE_ZIPVFS builds.
FossilOrigin-Name: c3036c28259c1375cd2c480c9ca0ce7f9aa1e952be4f110dde49b2b7d72a43b7
2021-06-16 18:58:01 +00:00
dan
7379b455a5 Do not run test file sessionbig.test on 32-bit platforms. It uses too much memory.
FossilOrigin-Name: 75e53215fe436999cdc70434c6ae96d3ce6642c71528cce9f5715fe1b1b81876
2021-06-16 16:56:56 +00:00
drh
a4df1bd5ff Adjust the mkshellc.tcl script so that the generated code always uses
unix-style line endings.

FossilOrigin-Name: 9f69af4dbcb273519fa87b7868f3792560fb71b192f4ffe53b8b465334da5ae4
2021-06-16 15:56:09 +00:00
larrybr
d95a652025 Avoid ominous warning in showdb.c
FossilOrigin-Name: f8d7ac0104b76555142ce0d32714594f42d19b311dce2f77f42f92756b5e0c93
2021-06-16 13:26:40 +00:00
drh
cbe83495ee Adjustments to requirement markings in comments. No changes to code.
FossilOrigin-Name: be00e45b723adf64bc78927dc12de3116fd04912a52e5c105a52f235c57698f5
2021-06-16 12:26:01 +00:00
drh
236bcdf3e4 Enhanced defense against integer overflow in ALTER TABLE.
FossilOrigin-Name: fb7f094e4e0f03622c2e7fa02483c17671a8899c7ad8aba8659177180f406704
2021-06-16 11:32:54 +00:00
drh
82f62e8324 Fix some #ifdefs so that builds work for all supported compile-time options.
FossilOrigin-Name: ca7d78f7818b4754fd04ea2b618dee1f01e11c6a5acb54951217c0d03df8e187
2021-06-15 20:10:25 +00:00
drh
9d82a2ccfe Fix an incorrect ifdef in the previous check-in.
FossilOrigin-Name: 4b2bb46730393292364b2be7db4e73fc8f93cd5a141aaf04f20fe0119deb5ab3
2021-06-15 20:07:16 +00:00
drh
f54e79405e Fix some minor #ifdef issues so that all of the supported compile-time
options continue to build.

FossilOrigin-Name: d8cf407046f20b0398f19acd0dab6acb6c742911e21e1003cb5b194dd668d98e
2021-06-15 18:46:06 +00:00
drh
17adf4e5a1 Update the "nmakehlp.c" utility program sources associated with the TCL
Extension Architecture, obtained from
[https://core.tcl-lang.org/sampleextension/file].  Perhaps this new
version will sit better with salmonx's static analyzer
[forum:/forumpost/7f0beca9797ee23a|(ref1)],
[forum:/forumpost/7d5c8b19231ad57f|(ref2)].

FossilOrigin-Name: 603b851d7d923d71543760b09a55d72dbbc185ac9c353c954c331c0454992c80
2021-06-15 15:36:05 +00:00
drh
a959bf5311 Add NULL checks on all sqlite3_vfs_find(0) calls. This is not strictly
necessary.  There are no vulnerabilities here.  However, adding these
checks avoids unnecessary static analyzer complaints.
[forum:/forumpost/ce1193be15|Forum post ce1193be15].

FossilOrigin-Name: 272a15b9f418fb0b31a9808f7c42c20cf52318035ff98935d8e8519634357e8d
2021-06-15 15:15:40 +00:00
drh
972da42749 Prevent an infinite loop in the trim() SQL function if the second argument
is a carefully malformed UTF8 string.

FossilOrigin-Name: 829343c26ed7b87fafc70de3369625209bad91e79bb7ca2946d5c8d61cc1c3c4
2021-06-15 14:34:21 +00:00
drh
11e489d6cb Fix typos in testcase() macros from check-in [c09d90eec2a49b94].
FossilOrigin-Name: d4d9869c30710914b7ba51221b2c2223a9cf16b913bd6f3866ae747494a116af
2021-06-14 20:49:33 +00:00
drh
93fd5420d0 In the authorizer, use SQLITE_DROP_INDEX, not SQLITE_DROP_TEMP_INDEX
when dropping an index in an attached database.

FossilOrigin-Name: e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70
2021-06-14 20:41:20 +00:00
dan
ac67f56726 Fix an ALTER TABLE problem with handling infinite loops of CTEs in the database schema.
FossilOrigin-Name: c09d90eec2a49b948c60971294d146db5c82438855cd3fa48ddc3d2e6b44c26c
2021-06-14 20:08:48 +00:00
dan
09612a5bb8 Fix a test script problem in corruptN.test.
FossilOrigin-Name: 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b
2021-06-14 14:52:27 +00:00
drh
21571a94c1 An index on the expression "likely(X)" should store the true value of X,
even if X is a real number with no fractional part.  The optimization of
storing some REAL indexed values as INT (see [10d851353c2abead]) should
be omitted for index columns that are expressions.
[forum:/forumpost/3b940c437a|Forum post 3b940c437a].

FossilOrigin-Name: 791473bc6677c2ae76f558082a4b43ca1eaf9895b76624d5b55d58f2af898ff3
2021-06-14 14:00:09 +00:00
drh
de5f21d0a8 Avoid allocating oversized column names in the sqllimit1.test module.
FossilOrigin-Name: 7068f1f69b4feef49260e80902e6bdae47c21a0daa16c96ed1a0984dd1f14cdc
2021-06-14 11:20:30 +00:00
drh
0d08402f34 The opcode that preceeds OP_SeekScan is usually OP_IdxGT but can sometimes
be OP_IdxGE.  Adjust asserts accordingly.  Follow-up to
[9a2ab6092d644fc3].  dbsqlfuzz e41762333a4d6e90a49e628f488d0873b2dba4c5

FossilOrigin-Name: d6803ed8dc4b1eb4d4dc100728acb4a4aa1479732f0fcb94eb23b7f7702ef65c
2021-06-13 19:14:14 +00:00
drh
7a7cefa0b8 Improved defense against OOM errors in sqliteInitOne().
dbsqlfuzz 429db39cd5777c46479641e8637c48c62890042d

FossilOrigin-Name: b6c57e0e2a9658417a0a5548e73007faa59c837b9ad87293bc216feef980717a
2021-06-13 17:55:58 +00:00
larrybr
bd0d62c35b Correct link in .ar help.
FossilOrigin-Name: de9d0f9548106f5a59c57dbf947fc63c0411b1e975033a4c4097cefbbe86ee5f
2021-06-13 08:23:28 +00:00
drh
a2078e025b The sqlite3WithPush() routine might destroy its second argument if there was
a prior OOM.  Do not use the second argument of sqlite3WithPush() if this
happens.

FossilOrigin-Name: baa3f96250763b42391fbb4dea283a4b6140fdbf775d85081a9efd6e6258f7b4
2021-06-12 18:12:59 +00:00
drh
24ce9446a8 This is an alternative approach to the use-after-free problem fixed
by [193b14a58e378ab3], saved here for historical reference.

FossilOrigin-Name: 6796b7a2485eca279db9d777595a886bc0d1dd7ec9551e1797e0032ef5493559
2021-06-12 17:45:32 +00:00
drh
35e6cd09f2 Reapply two recent ALTER TABLE error checks that turned out to be necessary
after all.  dbsqlfuzz fc5a9deefda00dda914748985155a6d4c44174e5.

FossilOrigin-Name: 230fedd923c87741d20caf55f29e8464cc6df344536f9b89331e0a0059a926f7
2021-06-11 13:18:56 +00:00
drh
cf145047b0 Avoid bugs in some implementations of dlopen() by avoiding calls to
dlopen() with a filename argument that exceeds FILENAME_MAX bytes.
[forum:/forumpost/08a0d6d9bf|Forum post 08a0d6d9bf].

FossilOrigin-Name: 01f3877c7172d52225705d2461addc6129fe9cdb04e6f643518fc74bb4b526e4
2021-06-11 12:41:14 +00:00
dan
d03d3a9b74 Fix a crash in new ALTER TABLE code that could follow an OOM.
FossilOrigin-Name: 6f1f2a0a9cd75ca43b81cc325296b843ccefe6f8040da8f2e873f49928423f10
2021-06-11 12:14:58 +00:00
dan
6065686d9c Remove an unreachable branch added by the previous commit.
FossilOrigin-Name: 852ee0e91ceae090157c4ab2805530f5d7985a490ce77f54d7b148f56e466f79
2021-06-11 12:02:00 +00:00
dan
26d61e5adf Fix problems with ALTER TABLE and schemas that contain views with some recursive CTEs, or CTEs that reference other CTEs.
FossilOrigin-Name: 8b1f9a51e962cd9a5593a1ecf4da6c86e34c4f9ff96ffcea0fb421880c8836cb
2021-06-11 11:14:24 +00:00
drh
75016050f3 Improved robustness following OOM in the constant propagation optimization.
dbsqlfuzz 001a20255c0df7495c21df62a20ea5b51e22c390.

FossilOrigin-Name: 8658a64d414db6900b55281f5e67180ea74b82627199b927634a727ed28030c2
2021-06-10 14:36:23 +00:00
drh
d622855e34 Set the database connection error code for an oversize argument to
sqlite3_bind_blob64() or sqlite3_bind_text64().
[forum:/info/a636276f0d451667|Forum post a636276f0d451667] and
[forum/forumpost/33821c8db543c|33821c8db543c].

FossilOrigin-Name: 56ff58c0b8905aa10c85f1418da8d6089d23fd9a220c5cb17027d46affe05002
2021-06-09 14:45:02 +00:00
dan
8d2a9c3b3a Add defensive code to better handle corrupt records in fts5.
FossilOrigin-Name: a99c29b5efaf17e34506cda5ce017ec0112b3cb24bf8a2f1831f0c14a8aa8d30
2021-06-09 13:39:11 +00:00
drh
18f9be897d Remove two assert()s in FTS5 that checks for database corruption right before
actual code does the same check.
dbsqlfuzz 9680db8f5338cb9b6060eb3a02d984555d4472e3.

FossilOrigin-Name: f3f82967b2e9fd4168d86300138ac4bbcd6ffd7a3ff5ecf20acdc29e5356ac3b
2021-06-08 23:46:59 +00:00
drh
26ec568d28 Try to avoid a double-free in the showdb utility program when running
pgidx on a corrupt database.
See [forum:/forumpost/a60ea5a4d4|forum post a60ea5a4d4] for context

FossilOrigin-Name: e3188a866362894d98521b3006fb5b9a63fe4a3bb2ff4f1b58acb6eb4e52da8f
2021-06-08 17:56:16 +00:00
drh
9025af1603 Add an assert() to prevent the value of the SQLITE_VTABRISK macros from being
changed in a way that would break logic.

FossilOrigin-Name: 33babdb582ca712cc089165a953972096b57d1cb683954fa830df5e7befaadba
2021-06-08 12:22:24 +00:00
dan
822810b95a Avoid a buffer overread in fts3 that could occur when handling corrupt data structures.
FossilOrigin-Name: 45f459d2fa4be97d9bbb970efbc0b5d40efaf93f52ed111fd0fcdc572c24327b
2021-06-08 12:15:56 +00:00
dan
bc85a51595 Fix a buffer overread that could occur in fts5 when handling corrupt records.
FossilOrigin-Name: 078962a2164a784b135bacee51ef10973dc2e30de04353d48698d0e72edd63d8
2021-06-07 17:36:57 +00:00
dan
ec73546103 Fix a buffer overrun in fts3 that could occur when handling corrupt records and '^' queries.
FossilOrigin-Name: 9d0b6b0f42a47a3892ebc765250756fb8b844e8399d992a8b65f55af3800ea06
2021-06-07 15:28:33 +00:00
drh
09c69fc1b3 Add recent dbsqlfuzz test cases to test/fuzzdata8.db.
FossilOrigin-Name: 162022003c2b4a393296939e2616bd3c7bbfd65b198ba6c9894e4234de2d3122
2021-06-07 14:21:03 +00:00
drh
ccf0bb49bb Avoid use of uninitialized memory while running defragmentPage() on a
corrupt database file.
dbsqlfuzz 4c45cecc0b255aaf2ea85453ccd17e814fd0b6b2

FossilOrigin-Name: 35e40d75754ec6fb93fe57c6ecbe731104e77c997d7e17ef1a22984837dfcab2
2021-06-07 13:50:36 +00:00
drh
fe972341a5 Fix an assert() in the OP_ParseSchema opcode that might fail on a corrupt
database file when running with PRAGMA writable_schema=ON.
dbsqlfuzz e7d743ca65f2767e415095f0c5a49166a0f55eea.

FossilOrigin-Name: 10801f65af495a999ef61741322ea82dc20bd92ea8e55e4016c409096f38b0d1
2021-06-07 11:50:23 +00:00
drh
9a4127a8c1 Remove unnecessary end-of-line whitespace from the regexp.c extension.
FossilOrigin-Name: 17e26a1f5e3cc4e96b9265dcdbf54f376304b0908f3ff0a0d3df33653e77e5b6
2021-06-07 00:54:38 +00:00
drh
9ae57841d0 Omit the unnecessary highlighting of the security implications of
SQLTIE_DIRECTONLY in the sqlite3_create_function() documentation.
No changes to code.

FossilOrigin-Name: 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f41819
2021-06-07 00:41:18 +00:00
drh
06258a4260 A better fix for the problem addressed by [4eb80b0cc61526c1]. This fix
also avoids reading uninitialized variables.

FossilOrigin-Name: 1c71de43dbc68002c4a6229e7efffb019655baff67a51fe922571fe420c95835
2021-06-04 23:26:56 +00:00
larrybr
e427fe5210 Make MSVC build examples work when taken literally, and say when they do.
FossilOrigin-Name: b53ca8ed8336d9e442a920e1c05a17a38dadc2fd1e0cb73e68d380ef34c87af8
2021-06-04 21:46:29 +00:00
drh
946b65793c Improvements to the OP_SeekScan optimization. Added the
SQLITE_TESTCTRL_TUNE test-control.

FossilOrigin-Name: 9a2ab6092d644fc3effc4ab4aca33efb2b4dd4213b2154d518a3e87eec4d3983
2021-06-04 17:47:08 +00:00
drh
50dce5e82f Add the (missing) dependency of regexp.c to the shell.c rule in the makefiles.
This dependency should have been added by [5d4535bfb603d7c8] but was missed.

FossilOrigin-Name: c93be7e66039e4c27b86f49d29f5c653cc6c02f6cbc6ad02d8bb1d32d0240863
2021-06-04 16:17:38 +00:00
drh
abc15f1b9a Fix harmless compiler warnings.
FossilOrigin-Name: 83aca2d8704e51eeed5652b1506c6fc883c0397728cda456f229369788b8608a
2021-06-04 16:11:19 +00:00
drh
9718bca77f Fix more cases in the regexp extension where the 0x00 terminator at the end
of the input string is being pattern matched.
[forum/forumpost/9104f0d9e7|Forum post 9104f0d9e7].

FossilOrigin-Name: 569e00d4acd426667990d675ca5da48a1859ac84af2412464ecd29c7c5da828c
2021-06-04 15:56:43 +00:00
drh
2d26cfcc4a Revamp SQLITE_TESTCTRL_TUNE to provide visibility of current turning
parameter values.

FossilOrigin-Name: 677e645e69e1f06487c26da6671fc03f0fb89a0f8e0d35712e6bdcf7279bdfc4
2021-06-04 13:40:26 +00:00
drh
f3c1256a4d Add support for SQLITE_TESTCTRL_TUNE and the ".testctrl tune ID VALUE" command
in the CLI.

FossilOrigin-Name: f1199d58b9cfdcddb83bc35544ce38299ac4ed50d7ab90d33463f6ccce526feb
2021-06-04 13:16:46 +00:00
drh
2540a7482a Merge recent trunk enchancements into the seekscan-improvements branch.
FossilOrigin-Name: d9e85fe80cdd3d798a583a5f99148235d0c3f39adfabbc661615893c387e6e45
2021-06-04 12:29:22 +00:00
dan
19e4eefbca Fix a case where combining row-value UPDATE FROM syntax with window functions over aggregates can cause an error.
FossilOrigin-Name: 4a587c3492faa99490fd67ca1de9fceafcdc12d220f42817791923be258b73f1
2021-06-03 18:56:42 +00:00
drh
a6df0e693f Fix the truncate optimization so that PRAGMA count_changes and changes()
return correct values even for a WITHOUT ROWID table.
[forum:/forumpost/07dedbf9a1|Forum post 07dedbf9a1].

FossilOrigin-Name: 820ae3b117c2d8c117c0c5a4e440a7d06886772516c7fc0a84606388f91be195
2021-06-03 18:51:51 +00:00
drh
6468990e7b Add the regexp() and regexpi() extension functions to the CLI.
FossilOrigin-Name: 5d4535bfb603d7c8229ef60f99666459f2997e02e186bc1e52b7ec1320251d67
2021-06-03 13:51:31 +00:00
drh
de30a3d2e1 Fix a bug in the regexp extension in which the "." wildcard would match
the 0x00 terminator at the end of the comparison string.

FossilOrigin-Name: fa23108b299fc70e80540c449500e50ac6344a152f4f6b9c1b1f568bbda8f6e1
2021-06-03 13:44:19 +00:00
drh
75f7317722 Fix the case-insensitive version of the regexp() function so that it does not
use the prefix optimization incorrectly.
[forum:/forumpost/983b43ef8e|Forum post 983b43ef8e].

FossilOrigin-Name: 1a8e43cc1b7969c40140dd7fd481d5ffd9de80e214eb494567c286d93a2b06e5
2021-06-03 12:31:08 +00:00
drh
3074faabed Add an optimization control bit to disable the OP_SeekScan optimization.
FossilOrigin-Name: f674c41e5cbbb08ffc3cc00ab449229b672054c872e209337f12e7eacb531fe5
2021-06-02 19:28:07 +00:00
drh
9966439879 Fix an ALWAYS which can be false.
FossilOrigin-Name: a87f8ecd6db11ea40a15314b875fc78289c19ab2dec6f738b4bf37f4aafa7bbd
2021-06-02 18:50:39 +00:00
drh
e847164f55 Tighten assert() restrictions on the OP_SeekScan opcode.
FossilOrigin-Name: dbc33d3ae30de5427a4351824a11026145f778fad95bd0b825bd0a4b63059677
2021-06-02 17:32:51 +00:00
drh
eda790d28b Never use WHERE_IN_SEEKSCAN for the 2nd or subsequent IN operator.
FossilOrigin-Name: d0b98619082038ed451912bcdf56568835a8577989a25cacf25591f2366d4f52
2021-06-02 17:14:50 +00:00
drh
b034a24140 This is an attempt to address the OP_SeekScan performance issue identified by
[forum:/forumpost/b4fcb8a598|forum post b4fcb8a598].

FossilOrigin-Name: d58efb3f21a4150b8136197e43837c7b646c42d492a7c24ddc7591dba415a2c8
2021-06-02 12:44:26 +00:00
mistachkin
f9ac1ab1e7 Fix issue in 'mkopcodeh.tcl' tool that prevented its termination in rare circumstances.
FossilOrigin-Name: a8d921136f8ab132279984a77d0eeaf355342cdb0a98d7e1e59c8e6c8ed9459c
2021-06-01 21:07:49 +00:00
dan
b56a09079e Fix a problem with running ALTER TABLE against schemas that contain compound SELECT statements with ORDER BY clauses containing one or more references to the second or subsequent component SELECT statements.
FossilOrigin-Name: 587a3044468a40707c714d013cb766d8a4d9eb13bb20871846a0e8c34bea8cf4
2021-06-01 15:37:14 +00:00
drh
d65b7e36ec Do not confuse the ">" operator with IS NOT NULL when checking to see if
a partial index is usable.
[forum:/forumpost/d813704d7c|Forum post d813704d7c].

FossilOrigin-Name: 8cc23931d61b7d78521acce93fc2603649c5813c7a0869cb2c1bde2c8c4e51b4
2021-05-29 23:07:59 +00:00
drh
d36bcec9ad Fix a subtle error in an assert().
dbsqlfuzz eefbd0215c0c1b4bcc32b8141b48b35f7b431300

FossilOrigin-Name: a5ec81eb49e55fc03591666f336c09e5469785c8680f253ec3cc5366ac2fa45a
2021-05-29 21:50:05 +00:00
drh
e9de65201c Make a deep copy of the result of a subquery in case the subquery is
reused.  Fix for the problem reported by
[forum:/forumpost/28216b36ac|forum post 28216b36ac] and introduced by
check-in [f30fb19ff763a7cb].  Further changes to try to optimize the new
OP_Copy opcode back into either OP_SCopy or OP_Move will be attempted
separately.  A test case will be in TH3.

FossilOrigin-Name: c9f0b9cb0aef107265435e22c164dd3c974eadfd00abf7cfd4fc7ec95c0dd7d0
2021-05-28 12:48:31 +00:00
drh
d2f55773f1 Fix a potential memory leak in json_group_object() following an error.
dbsqlfuzz cd32630de3ff039d97089592b63cb3616f8ec9dd

FossilOrigin-Name: 21676731cedae27d1ab9fe62b269001ae6e3eeb3caa87b4f5536f777631a8bbc
2021-05-28 12:15:19 +00:00
drh
48a296c589 Add the merge-test.tcl script to ease verification of LTS branches.
FossilOrigin-Name: f958ffbc61c693b71538cc3aa5f95ce0f0b5d4906efbb0c075f543e19883a669
2021-05-27 16:31:04 +00:00
drh
342cb33b23 Improved comment on the prpagateConstants() routine. No changes to executable
code.

FossilOrigin-Name: d61a875df48d8baab3ada0174c8e0312a9268bbd11bf104b4385eff9e2744266
2021-05-27 14:09:01 +00:00
drh
48f4f27cfb Remove a NEVER that is reachable following OOM in writable_schema=ON mode
with a corrupt schema.

FossilOrigin-Name: 4eb80b0cc61526c1ff7478b1b855b29fa4326daee61facd1d85e4297bb32ac9d
2021-05-27 10:23:16 +00:00
drh
7d11e647ad Improvements to the constant-propagation optimization in order to better
deal with unusual affinities.  See
[forum:/forumpost/6a06202608|forum post 6a06202608] for more detail.

FossilOrigin-Name: 9be208a6d70582c6808abe6e016ab9cd8d10f0deefb8c7a8c0543372cca15b12
2021-05-26 23:10:19 +00:00