Commit Graph

28119 Commits

Author SHA1 Message Date
drh
ebf9702b34 Avoid unnecessary recursion in sqlite3ExprDeleteNN(). This complicates the
code, but it is needed to prevent nuisance "stack overflow" reports from
OSSFuzz while it is running the latest ASAN.

FossilOrigin-Name: 70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371
2024-05-06 19:04:46 +00:00
dan
f4744ff1ff Add new sessions API sqlite3changegroup_add_change().
FossilOrigin-Name: 5eaab43ce48bb8d710f784ecd6aa9a4b3e708b44b0f7e49daf66a3f8bc2b9873
2024-05-06 17:55:19 +00:00
dan
cbea8d5c3f Edit comments in sqlite3session.h.
FossilOrigin-Name: 49f84878e21f85d44d8429cdc2908f87383e59737e1af3fdbccf0c276d883567
2024-05-06 17:32:26 +00:00
dan
0f78aafec8 Add tests for sqlite3changegroup_add_change().
FossilOrigin-Name: 9d67bedc20c3a59e5488f0eaea6a6611940a9cb63f7cf5e687b061cb5d510943
2024-05-06 17:21:23 +00:00
dan
1002bcff43 Fix problem in sqlar_uncompress() when being used to extract symbolic links.
FossilOrigin-Name: 4d90c3f179a3d7355b6b0202faf56f0be4be56986920576e528208cb84daa4af
2024-05-06 11:27:47 +00:00
drh
1aa94b5821 Add comment to the test/lemon-test01.y file indicating that it does not work
and is for historical reference only.

FossilOrigin-Name: 9bdf73a8d4a3b4a72f2882252f9ed29a6f1a26d3f50c071f27455bcf10458c4b
2024-05-05 10:00:02 +00:00
dan
5b80dbe6b3 Add new sessions API sqlite3changegroup_add_change().
FossilOrigin-Name: 73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c
2024-05-04 21:10:24 +00:00
dan
c52c00f670 Add test cases to test/in7.test. No code changes.
FossilOrigin-Name: 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50
2024-05-04 16:50:47 +00:00
drh
e8ba446a9a Assume that an SQL function is able to return a subtype if any of its
arguments are SQL functions that are able to return subtypes.  This closes
a corner-case hole in the patch at [ba789a7804ab96d8].

FossilOrigin-Name: b36d499e4cdb41a5d7e44a1c4347a059d7654f85ade9c5c04d18ac95ddc09fde
2024-05-04 15:10:37 +00:00
drh
2eb9adb564 Assume that a function is able to return a subtype if either (1) it is itself
marked with SQLITE_RESULT_SUBTYPE, or (2) one of its arguments is a function
that is able to return a subtype.  This check-in backs out the code changes
from the previous two on this same branch, but keeps the test cases from
the previous two.

FossilOrigin-Name: f16b200f25a0ec59ad765d254d81c3ffdba21f79e6e82807a7b80d00627952e2
2024-05-04 15:04:45 +00:00
drh
5b9b7cba22 Functions that pass through the sqlite3_value of one of their arguments must
also be marked as SQLITE_RESULT_SUBTYPE, in case one of their arguments has
a subtype.

FossilOrigin-Name: 2f9fba931d9f80b3d5dffb175180098756bccc6a8f665d7aaf8826970ab60d72
2024-05-04 11:31:34 +00:00
drh
0901571f0a The coalesce(), ifnull(), and iif() functions pass through subtype values
from their arguments, and hence need to have the SQLITE_RESULT_SUBTYPE flag
set.  This fixes an corner-case for the patch at [ba789a7804ab96d8].

FossilOrigin-Name: cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da
2024-05-03 19:35:43 +00:00
dan
9c0d777a9f Fix a problem with queries that use "IN(...) ORDER BY ... NULLS LAST" or similar introduced by [d7648e21605a0b38].
FossilOrigin-Name: 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e
2024-05-02 19:22:23 +00:00
dan
72814933b9 Avoid an assert failure accessible only when internal testing features are enabled. dbsqlfuzz crash-66abacda6bca6bd531e25595e8c8068e2c710326.txt.
FossilOrigin-Name: fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10
2024-05-02 18:16:23 +00:00
dan
01508c814c Fix a case where the recovery extension might write uninitialized data to the recovered database.
FossilOrigin-Name: 8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56
2024-05-02 17:46:52 +00:00
dan
aeb62886c5 Avoid an OP_Next in cases where an IN(...) query against a UNIQUE index may return at most 1 row.
FossilOrigin-Name: d7648e21605a0b381b1935a47e5a77bdfacc4cc96f03d6bb7956f8f4e6a40648
2024-05-02 14:48:58 +00:00
drh
d059774365 Fix the CREATE TABLE performance issue described by
[forum:/forumpost/4cf69794d9dfff7c|forum thread 4cf69794d9dfff7c] in two
different ways:  (1) Omit the call to PRAGMA integrity_check('X') that was
being done after CREATE TABLE "X" because the result was being ignored and
the integrity_check was not doing anything other than burning CPU cycles.
(2) Do not interpret the argument to PRAGMA integrity_check as a number if it
is in fact a string that looks like a number.

FossilOrigin-Name: 71f08b912251c8a3ac1bd8e344903336648e4187f7493f8c126e60b3b51b9f09
2024-05-02 12:14:31 +00:00
drh
9b4e7898d7 Add a test case to the fix to PRAGMA integrity_check in the previous check-in.
FossilOrigin-Name: 39a57b596d309d9e2d4c59409fe5d36e0665781ce0307d157ff8b6e883161bbb
2024-05-02 12:00:36 +00:00
drh
78bc1339ac Do not accept a string that looks like a number used as an argument to
PRAGMA integrity_check as a number.  Treat it as a table name that just
happens to look like a number.

FossilOrigin-Name: b04e7a23478f1012e501a810f3e09cca81a66e802f5f72cae80c81120174e2cb
2024-05-02 11:52:31 +00:00
drh
2ae4531c89 Omit the OP_SqlExec to "PRAGMA integrity_check" added by [348fa7aaf7958b3f]
because it is a no-op.  Even if the integrity_check failes, the CREATE TABLE
is stull successful.  The OP_SqlExec just burns CPU cycles for no reason.

FossilOrigin-Name: 532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe
2024-05-02 11:51:26 +00:00
dan
f3ea92cceb Avoid an OP_Next in cases where an IN(...) query against a UNIQUE index may return at most 1 row.
FossilOrigin-Name: 560f64157d2fe40e107582eebb6526185c9c43305e364f4132e182dbec5b210a
2024-05-01 19:48:24 +00:00
dan
2ad1e92858 Fix another problem in the recovery extension where a corrupt sqlite_schema table could lead to excessive memory consumption.
FossilOrigin-Name: 1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be
2024-05-01 16:25:46 +00:00
dan
19ca99eea4 Fix a problem causing the recovery extension to use excessive memory and CPU time in some cases.
FossilOrigin-Name: 8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26
2024-05-01 14:42:20 +00:00
dan
8d5fe073d2 Avoid 32-bit overflow when calculating ncycle for ".scanstats vm".
FossilOrigin-Name: 2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4
2024-04-30 19:34:15 +00:00
drh
b11daa50f9 Fix issues in [/info/1e227ad9f413227f|LIMIT/OFFSET support for virtual tables].
The first problem was reported by
[forum:/forumpost/c243b8f856|forum post c243b8f856].  That report prompted
an enhancement to the generate_series() (also included in this merge) which
in turn identified other similar issues.

FossilOrigin-Name: 5f6c079d847e3664ec5acaf1b3e989efe0d548c211ae4a18936162b36df89065
2024-04-26 19:10:15 +00:00
stephan
b95c1d0ac9 Internal JS doc touchups. No functional changes.
FossilOrigin-Name: 626b997b4e727554d7ec8b60fb37b2a94cb861a87325da4ae484bd9aa8961ca5
2024-04-26 18:42:50 +00:00
stephan
6c290ccd49 Additional internal docs in the wasm utilities.
FossilOrigin-Name: 5a2245a9ebae6d23cd343e46b9d730f66ec4d5ffc91b83ed11a0fbd2194ad807
2024-04-26 18:24:23 +00:00
dan
4c3ab545a9 Allow virtual table implementations to handle OFFSET but not LIMIT, but not LIMIT but not OFFSET.
FossilOrigin-Name: 90e5c8226a695e838e8c1703a9b8598e654d216799e8806c4d1a1f20c28c6486
2024-04-26 18:13:11 +00:00
dan
297472a2fc Have where.c ignore any plan from a virtual table that tries to use LIMIT/OFFSET without also using all WHERE constraints.
FossilOrigin-Name: 7d30596496c6a7a37b925f13d8d94d5de224ec31bb86594fa4cc07b10082e776
2024-04-26 17:19:59 +00:00
drh
d3a4dbe4b8 Further fixes and improvements to the generate_series() enhancements on
this branch.

FossilOrigin-Name: b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e
2024-04-26 17:09:33 +00:00
drh
84a231eb61 Use hex flag masks rather than decimals in ext/misc/series.c.
FossilOrigin-Name: a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396
2024-04-26 14:36:28 +00:00
dan
3afd5b6d65 Fix a problem allowing a LIMIT constraint to be passed to a virtual table in cases where there exist WHERE terms that cannot also be passed.
FossilOrigin-Name: 72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7
2024-04-26 14:32:58 +00:00
drh
99ac2324aa Fix handling of LIMIT and OFFSET in virtual tables that are part of
a compound SELECT.

FossilOrigin-Name: 40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30
2024-04-26 13:38:43 +00:00
drh
317b7416a6 Enhance the generated_series() table-valued-function to respond to
LIMIT and OFFSET.  Use this to add new test cases for LIMIT and OFFSET
on virtual tables in a compound SELECT.

FossilOrigin-Name: 408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e
2024-04-26 13:30:48 +00:00
dan
d591a5b93d Add test demonstrating the problem at [forum:/forumpost/c243b8f856|forum post c243b8f856]. No fix yet.
FossilOrigin-Name: 1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766
2024-04-26 12:01:17 +00:00
drh
fed13d50a9 Fix the TreeView display of a LIMIT clause on a compound query. Debugging
code only - not part of production builds.

FossilOrigin-Name: 38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14
2024-04-26 11:32:50 +00:00
drh
ec14ef80b0 Improvement to the way that affinity is determined for columns of a
compound subquery.  The affinity is the affinity of the left-most
arm of the compound subquery that has an affinity other than NONE, adjusted
to accommodate the data types coming out of the other arms.

FossilOrigin-Name: e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e
2024-04-25 23:26:11 +00:00
drh
ddc6bd9f21 Further improvements to the computation of affinity for compound subqueries:
make sure that the selected affinity is compatible with a literal values in
arms to the left of the arm that is used to determine affinity.

FossilOrigin-Name: bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a
2024-04-25 17:52:10 +00:00
drh
23afc2c4ec Back out the previous change on this branch. In its place: Determine the
affinity of a subquery by the left-most arm of the subquery that has an
affinity other than NONE.  In other words, scan from left to right looking
for an arm of the compound subquery with an affinity of BLOB, TEXT, INTEGER,
or REAL and pick the first one found.  Or stay with NONE if no arm has a
defined affinity.  Test cases added.

FossilOrigin-Name: b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5
2024-04-25 16:55:53 +00:00
stephan
c859f0267c wasm: add a makefile comment about the static sqlite3.h/c version info injected into the JS files possibly differing from the runtime-emited version info when a user provides their own sqlite3.c.
FossilOrigin-Name: d99a01a0f6e1f70f70c9a0625aeaa8a8015eba352bcfb3978eafca6df10ba5a8
2024-04-25 06:52:19 +00:00
drh
f8e195159f An experimental minor tweak to the way affinities are computed for compound
subqueries, when the actual affinity is ambiguous.

FossilOrigin-Name: 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb
2024-04-24 19:49:52 +00:00
drh
0868d58e2c If a RETURNING clause contains a subquery that references the table that is
being updated in the statement that includes the RETURNING clause, then mark
the subquery as correlated sot hat it is recomputed for each result and not
just computed once and reused.  See
[forum:/forumpost/2c83569ce8945d39|forum post 2c83569ce8945d39].

FossilOrigin-Name: 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e
2024-04-24 16:36:37 +00:00
dan
dfa6289153 Fix a case where a corrupt stat4 record could go unrecognized due to integer overflow.
FossilOrigin-Name: 240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d
2024-04-24 14:18:20 +00:00
drh
35b771e221 Add comments linking the assert() added in [cef4d9e3ba586735] to the places
where the precondition that the assert() tests are actually required.

FossilOrigin-Name: 6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1
2024-04-24 11:51:51 +00:00
dan
5b27ecafbc Avoid slowdown when exprNodeIsConstant() is called on deeply nested SQL functions.
FossilOrigin-Name: 1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1
2024-04-24 11:40:47 +00:00
drh
b065eceb56 Ensure that temporary SrcItem objects created by trigger processing have
either SrcItem.zName or SrcItem.pSelect defined.  Every SrcItem should have
one or the other.

FossilOrigin-Name: cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c
2024-04-24 11:21:27 +00:00
stephan
99200b2f07 Remove an undocumented feature from the JS Worker1.open API because it relies on broken behavior which has no VFS-agnostic workaround.
FossilOrigin-Name: 3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9
2024-04-24 06:43:17 +00:00
drh
14602eafa7 Fix a problem with vector IN operators used with an index where the affinities
and collations for the various vector terms are different.

FossilOrigin-Name: 86e8c782e7494377de3c27b750cd83a7eb2302c1182ee2004d3864db50fca557
2024-04-23 12:02:03 +00:00
dan
0309fb919a Fix an uninitialized variable problem in the new code on this branch.
FossilOrigin-Name: 85625b38718c6e4cf7aa97fa3c52153bd25c810b68f19e7924e1f4b709c6a05d
2024-04-23 11:56:20 +00:00
stephan
3ac612dd7d Remove some dead WASM-side code.
FossilOrigin-Name: 0a07ee27bd6021a6fc1d81133012592351530ffcf6ae09322ea74624cff910df
2024-04-23 06:49:47 +00:00