Commit Graph

27086 Commits

Author SHA1 Message Date
drh
51b358e5e5 Add SQLITE_TESTCTRL_FK_NO_ACTION.
FossilOrigin-Name: 563cf5f782cdddbbd7f727c65118edfd109aeb731c8aaf0d6ee5ee7030e61ea9
2023-10-21 12:54:37 +00:00
drh
a35a54b824 Adjust an EXPLAIN QUERY PLAN output in scanstatus2.test to account for a
different loop order taken due to the removal of the view-scan optimization.

FossilOrigin-Name: 9deb8b6915e794bf9c5de88f2727ef9857351eaf905f8ab56754bc4d399c88b4
2023-10-21 11:43:54 +00:00
drh
813159e2ea Compress the content of the status line in testrunning.tcl so that all the
same status information appears but with less punctuation and with "zero"
values omitted, so that the status line will fit comfortably on an 80-column
terminal window.

FossilOrigin-Name: 966351311682a319ec796c07d407ce90cd1aa0cea9e904ba1085a4ebadbdf925
2023-10-21 11:34:59 +00:00
drh
531ca6058e Create the new string_agg(X,Y) aggregate function which is an alias for
the two-argument group_concat(X,Y) function, for compatibility with
SQL-Server and PostgreSQL.

FossilOrigin-Name: a3b3df8a9e43f1880a904b76027db56ed504a84622831c96ba1962a19bbed762
2023-10-21 11:13:47 +00:00
drh
266e5d034b Avoid an unnecessary malloc() for the page usage bitmap when running
a partial integrity_check.

FossilOrigin-Name: 2904fcbeebba9189cebc48e58d12fc46f78ee23d8c4d46644606691f8cabb80c
2023-10-21 11:06:03 +00:00
drh
51bb5dec6c Fix a test case broken by the previous check-in.
FossilOrigin-Name: 1e61864c3bffec133632f4575d59d11936e8bafc089c4d84a129dcaf7e9b6d7d
2023-10-21 11:00:57 +00:00
drh
d5e040b6f0 Add string_agg(X,Y) as an alias for group_concat(X,Y), for compatibility
with SQLServer and PG.

FossilOrigin-Name: b91c19bf2680f60d7826ab5d9e7902e2dc2a55d847bbea565a6489d47f2cc8f1
2023-10-20 20:19:30 +00:00
dan
71bae9f19f Fix a problem allowing a COMMIT following an OOM to cause fts5 corruption.
FossilOrigin-Name: fba3129d1362dd3ee04d61cb3d3c48518cd98dde3febc85298f411776d60073e
2023-10-20 19:59:12 +00:00
drh
81656b15c9 Fix PRAGMA integrity_check so that it does not raise an error if the
schema contains a CREATE VIRTUAL TABLE that does not have its module
loaded.

FossilOrigin-Name: 5cb61c6788d7c0170b587e4667ee57d588c991a9901951762e33b97c6a135a82
2023-10-20 19:06:04 +00:00
drh
e98f62fb3f Omit some redundant calls to strlen() used to find the size of
Expr.u.zToken in sqliteExprDup().  This inefficiency was seen while working
on the previous check-in, and I thought it best to fix it while it was
fresh in mind.

FossilOrigin-Name: b7a84eff5dcdf5b2ff81331097cdc64d0c5d16a4ae224320f39b64541ec72dc7
2023-10-20 18:09:08 +00:00
drh
ab3eb5b770 Improvements to the sqlite3ExprDup() logic for faster performance and better
run-time error detection.  This check-in fixes the 5x oversize memory allocation
bug from [f371e4c0f8ea73ae] as well as all other known issues that result from
handing the ORDER BY clause of an aggregate function off of the pLeft pointer
of the Expr object.

FossilOrigin-Name: f5c01676fd281e938181b846dd2024d050f597dc6a7a91928beab9d8553dfdb5
2023-10-20 17:15:15 +00:00
dan
17c3408e0e Add the SQLITE_CHANGESETAPPLY_FKNOACTION flag to sqlite3session.h, for passing to sqlite3changeset_apply_v2() to cause all foreign key constraints to behave as if they were declared NO ACTION.
FossilOrigin-Name: fc9f82ea084159eaf3dd1757b96d17d1201b00c4e06455a7dcd8067172b25f28
2023-10-20 17:06:39 +00:00
drh
90e4a3b7fc Simplifications and optimizations to the Expr object duplication logic.
The 5x multiplier crutch from [f371e4c0f8ea73ae] is still present.  More
fixes are still needed.

FossilOrigin-Name: 56142a78163b755f16afc05201f623a7a19d9a4b0620a67f7fa20d2a965a288d
2023-10-20 15:47:30 +00:00
drh
0a261eb4bb Omit an unused constant from sessionfuzz.c to prevent a compiler warning.
FossilOrigin-Name: a0cf7e24f928183866ac54f0d6cd83c859d487a19dc87572ab0188d90d2ff87d
2023-10-20 14:05:26 +00:00
stephan
11223e0cff Correct the opfs-sahpool VFS's xGetLastError() method to return the previous error code, not 0, on success.
FossilOrigin-Name: 95a1dde63117d696323c775580b9c04f044a5b8d609e9174b739ac03ecc1336c
2023-10-20 12:23:49 +00:00
drh
d707e012f0 Use sqlite3ParserAddCleanup() instead of calling sqlite3ExprListDelete()
directly when disposing of an unused ORDER BY in an aggregate function,
to avoid disrupting ALTER TABLE data structures.

FossilOrigin-Name: d083e42086733ecd79aba8c268e020b01782bfe1cfa9684ce1c277af9c8bf92a
2023-10-20 10:18:03 +00:00
drh
dcf76a8bbd Remove a faulty assert() that was added just a few check-ins ago by
[8b6fffb552c30f9c].

FossilOrigin-Name: 18e7c826f08bce51719ef045daa60200b33790f2fe312c6853f9ef6c7e9d5030
2023-10-19 20:06:20 +00:00
drh
5f53f85e22 For TK_ORDER expression nodes to always be full-size.
FossilOrigin-Name: a5c73b46f4772f214ffbfa31cb87dce82ebd690addabef539bd09def26b7744d
2023-10-19 19:57:57 +00:00
drh
5080397e67 Fix an adverse interaction between the new aggregate ORDER BY logic and the
expression compressor.

FossilOrigin-Name: f371e4c0f8ea73aee9ea0645f396e3da20f1eb97be34c83de9d94c9cbb959934
2023-10-19 19:19:59 +00:00
drh
d8b840a4f4 In the TreeView logic (used for debugging only) do not show unnecessary fields
of the Window object when a function has a FILTER.

FossilOrigin-Name: d2c6b82c346dbf39e07f09d187e4a8216a56caa7df3dcfafc82e32f676a1db8a
2023-10-19 19:08:33 +00:00
dan
ee3c55471c Fix an fts3 problem caused by reducing the page size using the undocumented "nodesize" option, then running an incremental-merge.
FossilOrigin-Name: 2875dcb1ac86db2704ad377d719f308c8837e196b49c98b20ceda1324f2d27ea
2023-10-19 18:23:17 +00:00
drh
4e254641ff Simplify the Expr compression logic slightly by adding the new EP_FullSize
property to expressions that are exceptions to the rule and should not be
compressed.

FossilOrigin-Name: d5ae82ec52eafed5e3dc8c9d99685f6523fce7d973ef7e8d9d75ed9b8912426a
2023-10-19 18:07:58 +00:00
drh
0588385799 Simplification to sqlite3GetVarint32() to avoid confusing gcov.
FossilOrigin-Name: 89862c51ad9715bedf5b029db484602e740f0db7404970d482ce503c1b9a0ed2
2023-10-19 13:35:22 +00:00
drh
11877c6ba4 Fix an error in a debugging routine used inside of testcase(). Does not
appear in production.  Problem discovered by scan-build.

FossilOrigin-Name: c6c9d7ed6dbc71b998aeaaa1bdeb36b1bb9b902f9d6088ad36db29f8ea8b7ef6
2023-10-19 13:00:41 +00:00
drh
266178f369 New assert() statements to help verify correctness of the ORDER BY aggregate
code.

FossilOrigin-Name: 8b6fffb552c30f9cbf7102c2e26a7b486c4c9edd9f494d803de7004db3018277
2023-10-19 12:36:59 +00:00
drh
519017f25a Fix the sqlite3ReferencesSrcList() routine so that it recognizes columns
in the ORDER BY clause of an aggregate.  Fixes a problem with
[634286828dad873d] discoverd by dbsqlfuzz.

FossilOrigin-Name: 3d26f1aaa4876f21f2c3abf13bbc37933c8f32471153e29019880cc9530cb011
2023-10-19 12:12:49 +00:00
drh
d9451051f1 Add support for ORDER BY on the argument list of aggregate functions.
FossilOrigin-Name: 634286828dad873dba244751441aa729cd37b6ed5899fa5875643d4af03c006c
2023-10-19 01:26:34 +00:00
drh
0b633640fa Merge the latest changes from trunk.
FossilOrigin-Name: d18bc400146812c8c5048af7eaf4a5371ddd80fc9ce895d253b6114b9eae7fc3
2023-10-19 01:09:49 +00:00
drh
69ff726d4d Fix a false-positive in run-time error checking.
FossilOrigin-Name: cd63eec0758960d9ee63d7b964ec62e2bd622f8c94a58bd9556046381ffa18d0
2023-10-19 00:25:35 +00:00
drh
d05e54efff Changes for test coverage.
FossilOrigin-Name: ddfa09c6031afd4391a9888381bf09214cd542a826b431eeb1537a070f65c5f9
2023-10-18 23:48:24 +00:00
drh
42f5ea354e Test case for alter column that is used in the ORDER BY of an aggregate.
FossilOrigin-Name: 648ddb3a8eb358fc6c95aaa561ae68476c77996abda23890054ac07166278cef
2023-10-18 22:53:22 +00:00
drh
ce51b31367 Deal with an OOM condition while processing aggregate ORDER BYs.
FossilOrigin-Name: b6d44427ec0184880ad14919667e2f526777c5085ffa636f6734cb5951a31225
2023-10-18 22:27:59 +00:00
drh
20b95f8d3f Make sure all terms of the ORDER BY within an aggregate go through aggregate
analysis.  Do not attach an aggregate ORDER BY to a window function.

FossilOrigin-Name: 16f3805514a741405f70e0ee3b5a6b67720bc75719372e82daa4136fe411ea2b
2023-10-18 22:03:48 +00:00
drh
49dc1be96f Basic test cases.
FossilOrigin-Name: 6cccf86c362631ada0c6cbaf661520648f8bbf7ae2b137b3d7d959647387e5c2
2023-10-18 19:44:59 +00:00
drh
0021079ceb Fix one minor error in order to get all legacy tests to pass.
FossilOrigin-Name: 5a885139c433a143302ab43dc5aaac1fed9db61548b4ff7d4b19b3a6a46c8fcc
2023-10-18 19:07:45 +00:00
drh
59a0d0bbf9 ORDER BY on aggregates seem to work, at least for simple smoke tests. Lots
more testing is needed though.  Surely there are many bugs.

FossilOrigin-Name: 64c12a835b6f1df8f2f5f4a41de083f6b3fc7f8030042c6aac0082382cd9cc4d
2023-10-18 18:11:11 +00:00
drh
db19f48b69 Basic error checking. Resolve symbols in the aggregate ORDER BY expressions.
FossilOrigin-Name: c83a53a574d312130d1238c05ffa449d8bed2535d5ef5b5d9cf02f894494cca4
2023-10-18 13:58:31 +00:00
drh
f8202f1ff3 Enhance the parser so that it can accept an ORDER BY clause on a function
invocation.  For this incremental check-in, the ORDER BY clause is currently
ignored.

FossilOrigin-Name: 3a98ff24bf468ed42d410a9a12d9f9b2ca154c7babe99fd6bc6f7b0565e0d132
2023-10-18 13:18:52 +00:00
stephan
0b4de1acac JS: replace one errant reference to 'self' with 'globalThis' and remove a separate dead-code 'self' reference.
FossilOrigin-Name: da1a47932ea96755b1e11fc2547ce11780b87846af6885857318ff18f1e62c31
2023-10-17 23:35:47 +00:00
drh
43dc31cf1f Fix a harmless compiler warning about variant types for a pointer function.
FossilOrigin-Name: 37ff0d8e7f91c32e8c53bb015280be47c66bf599281b640a8d3fd41335b55289
2023-10-17 19:33:52 +00:00
drh
6db4e5ed4c Make a new branch in the SqlExec opcode reachable by tests.
FossilOrigin-Name: 023ad470b68b7c09e159244493a6d0285d706efdecd8719a71e6885509d4750c
2023-10-17 18:59:13 +00:00
drh
42b49a3138 Omit an unreachable branch when SQLITE_ENABLE_API_ARMOR is not defined.
FossilOrigin-Name: 5f8b807b568f4f9ec65f1c924e0e1ac2f996f405e045204145ad7116be7580ee
2023-10-17 18:28:27 +00:00
drh
4c827feba1 Changes to sqlite3IntFloatCompare() in an attempt to better measure
branch coverage in the face of aggressive compiler optimization.

FossilOrigin-Name: 5781d043ffeccda03357ee530564987443dc1deb6111a4028701b4a98fdfe16d
2023-10-17 17:53:46 +00:00
drh
52d934e316 Fix a JSON bug introduced by the optimization of [df099ad713011b67] and
first appearing in 3.43.0.  The problem occurs when doing a JSON_EXTRACT()
on an array element that was added by JSON_SET() without first reparsing.
Reported by [forum:/forumpost/fc0e3f1e2a|forum post fc0e3f1e2a].

FossilOrigin-Name: e5099c549a1d8959d4015516f090b8e6438e517a64b20651175bf5413d94fb58
2023-10-17 13:41:41 +00:00
drh
5e0b11bda7 Enhance the documentation of sqlite3_deserialize() to make it clear that
the input database may not be in WAL mode.
[forum:/forumpost/a7e272cee9ac469f|Forum post a7e272cee9ac469f]

FossilOrigin-Name: e754789971e019647e7068f76dc6f9778675e4849fe51d8b25b39d3edf2379e5
2023-10-17 11:57:36 +00:00
drh
11095bcb89 When an I/O or similar error occurs during a transaction with
journal_mode=MEMORY, attempt to rollback before closing the journal, as
all rollback information is forgotten when a memory rollback journal is
closed.

FossilOrigin-Name: 1d67f75de259e5a26b751a50432822a268ebe367cda6510891ab81a15e5daa1c
2023-10-17 10:47:42 +00:00
stephan
b866f98346 Harden API_ARMOR checks for sqlite3_stmt_scanstatus_v2().
FossilOrigin-Name: d3f38e813ba3b887e973af034713cd58fdfbe07da375b154accc7b5790cfaeda
2023-10-17 02:15:49 +00:00
stephan
08747d44a2 JNI: add aggregate function support to the wrapper1 API.
FossilOrigin-Name: 15b28b340a5c5efdbfe3fbed16ee0b699561edaeebb77446addf2374bdf9357e
2023-10-16 16:04:23 +00:00
stephan
626d0a9fda JNI: add scalar UDF support to the wrapper1 API.
FossilOrigin-Name: a850535766d2243d9475e1523c753615875a2da9c9d82a41a9fb61b141c6334a
2023-10-16 14:31:13 +00:00
stephan
f2d7e961d9 JNI: initial draft (untested - requires more infrastructure first) of a UDF argument/result-handling interface which completely hides the C-style API from the client.
FossilOrigin-Name: 43b10a5cf9cb8be53d62914f340d533e60a70bf4caa8b9b91c0f867fa0f70493
2023-10-16 13:04:42 +00:00