1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00
Commit Graph

2101 Commits

Author SHA1 Message Date
drh
877051b246 Better optimize queries that use parameters in the LIMIT clause.
FossilOrigin-Name: b44f2676716be37d85eb6f207e187d997fc9d7493883bd7f1541cc7ae52475be
2024-06-06 16:06:21 +00:00
drh
efb848d53b Fix table-valued functions so that they will work as the right table
in a LEFT JOIN.  Ticket [2ae0c599b735d59e]

FossilOrigin-Name: 1f97086d628b6f52e6f9a87cd9d2c365f3c51f5b33c5c36a3f83889ec08765be
2024-04-02 18:31:48 +00:00
drh
214750470c Remove Window objects from the corresponding Select.pWin list when they are
deleted, as they are, for example, when the ORDER BY clause is optimized out.

FossilOrigin-Name: f9c6e6a7102689b2a5cf32996a02853e346bcebaed6af0265a7422260fa3358c
2023-11-29 16:07:59 +00:00
drh
a524a71639 Back-port omit-unused-subquery-column enhancements into the 3.28 branch.
FossilOrigin-Name: 57a4e91f4343b612c346a4d284c0354deee364f83951e64b009e79cd20aedb47
2023-02-16 19:04:40 +00:00
drh
239befa5fc Improve the ability of the query planner to recognize covering indexes even
on tables with more than 63 columns and where the index is over columns
beyond the 63rd column.

FossilOrigin-Name: 3d1992de4733d4e155f2d6d5268323410d1104ab56db50f08a2bb26bf87d926b
2022-10-24 13:50:04 +00:00
drh
f44f3290df If a query uses an index where one or more of the columns of the index is
an expression and if the corresponding expression is
used elsewhere in the query, then strive to read the value of the expression
out of the index, rather than recomputing it.  This is the
"Indexed Expression Optimizations".

FossilOrigin-Name: 3da1032878bdc93f69b02926fb7243b31fe6b1a0ee93af68df52b203b0603dad
2022-10-19 11:22:21 +00:00
drh
118eb6e27a Merge the branch-3.28a fixes into branch-3.28.
FossilOrigin-Name: ba6bf331476d0217f4132b73cb3da559e75bfb21856ec94f82c0f0150a53592b
2022-08-10 17:03:43 +00:00
dan
79410ac8ef Fix a defect in the query-flattener optimization identified by
ticket [8f157e8010b22af0]. This fix is associated with CVE-2020-15358.

FossilOrigin-Name: 9e001b635f3cff672e591204ab90deefe01baaefe64ff121bd2c32edd2d03675
2021-07-12 14:38:35 +00:00
drh
01908c6eeb (no comment)
FossilOrigin-Name: 263293f1e6db26039d94c9ed7efa2cdea25df5e5f42673a116ce2d03b9fadff4
2020-10-22 18:58:33 +00:00
dan
296f59ae54 When doing an UPDATE or DELETE using a multi-column index where only a few
of the earlier columns of the index are useful for the index lookup,
postpone doing the main table seek until after all WHERE clause constraints
have been evaluated, in case those constraints can be covered by unused
later terms of the index, thus avoiding unnecessary main table seeks.

FossilOrigin-Name: 0ecda433718f0bc973078099b19955dcfb0dcd15b68455e53156ac708e9d92e5
2020-08-17 21:03:53 +00:00
drh
39ca0d51e5 More restrictions on changes to shadow tables when in defensive mode.
FossilOrigin-Name: b302b260ca9a4ca3d84771d9157fb1fc0b0e1ba175638f0c006cdf94f92a19c9
2020-01-17 15:33:47 +00:00
drh
3b96ec9d07 Validate the type, name, and tbl_name fields of the sqlite_master table when
loading the schema, unless writable_schema is engaged.

FossilOrigin-Name: 3d13fbf248e6bcb997c301530ee834c6f1fc21add7f46b673d0f63e986c60680
2020-01-17 15:24:13 +00:00
drh
c3dcdba387 Improved reporting of SQLITE_TOOBIG errors while parsing.
FossilOrigin-Name: ea2d4b65e20e44e19219c821bf68e97ff3af1760b3b4762250d020ba2a5a6343
2019-04-09 21:32:46 +00:00
drh
4e61e88348 Only preserve rowid values for VACUUM INTO. Keep the legacy behavior of
renumbering rowids for ordinary VACUUM.

FossilOrigin-Name: 13a0ea6466b051ea5281865ed5285b8b5a99ec4307f400c5f7b03692723f1cd1
2019-04-04 14:00:23 +00:00
drh
94809086e5 Use a separate bit on db->dbOptFlags to disable the xInverse optimization on
window functions, rather than reusing the query-flattener disable bit.

FossilOrigin-Name: bc0fb1c324be2fd668bc4398c7d364b7e3c5a98537fe5fb58a125b66f3e6d041
2019-04-02 17:45:56 +00:00
drh
d137f4e6e5 Recover a some of the performance lost by window function alias fix two
check-ins back.

FossilOrigin-Name: 965cbcea117835d2c6d2ec58c8025b227f491c35805e282cb31228436bc6bec1
2019-03-29 01:15:11 +00:00
dan
4ded26a53c Prevent aliases of window functions expressions from being used as arguments to aggregate or other window functions.
FossilOrigin-Name: 1e16d3e8fc60d39ca3899759ff15d355fdd7d3e23b325d8d2b0f954e11ce8dce
2019-03-28 16:15:05 +00:00
drh
fc15f4c528 Improved TreeView display of Window objects.
Change the Window.eType field to Window.eFrmType to avoid confusion with
other "eType" values.

FossilOrigin-Name: ec2f207dedb223077bbd3e4584499250eb12219712c917e930acccfa2c46e23b
2019-03-28 13:03:41 +00:00
dan
bf84515a2b In order to identify the first row of each partition, check if the rowid in the ephemeral table is 1 instead of using a dedicated flag register.
FossilOrigin-Name: f2d5f7a24c7aa483c579706c5bd7268a74da6d53025d78fa8642908c2aed1707
2019-03-16 10:15:24 +00:00
dan
d35300f9b6 Parse EXCLUDE clauses in window frames. They do not yet work.
FossilOrigin-Name: d03c7533a1e993f1b12392a5193b2127484307b27072236a1255e7a30849a381
2019-03-14 20:53:21 +00:00
dan
a0f6b83300 Add things to this branch that will be required to support the EXCLUDE clause.
FossilOrigin-Name: 7d66cd2013206ebad50c7cdb7dab9211fa8b47f5cb7067dcb314b3e0180875f8
2019-03-14 16:36:20 +00:00
dan
b6f2deac3c Avoid allocating excessive registers for the PARTITION BY expressions when processing window functions.
FossilOrigin-Name: 180be266238e18c01f8bd52c75dd9aa3e26e553620258141cd95189a0ae59ddb
2019-03-13 17:20:27 +00:00
dan
cc7a850f2e Remove "cache mode" from the window frame code generator. Handle the same cases by editing the window frame specification itself.
FossilOrigin-Name: 081263538332bb9c07e62630629007ccbba31bef5dc890f60b4ba58a355f70ac
2019-03-11 19:50:54 +00:00
dan
b33487b0b6 Improvements to the way built-in window functions are handled.
FossilOrigin-Name: e8eee566dfca6f4c8af074731dfe91f7fbcd9ca72f0303235b52e4e2e80d5b71
2019-03-06 17:12:32 +00:00
dan
4e72e62f3b Merge trunk changes into this branch.
FossilOrigin-Name: 9b4d561f68febdab6624d8c567fb4357bf67dda500664cf708d16a76f37b8ec1
2019-03-04 21:08:53 +00:00
dan
680f6e8e2e Support some "ROWS BETWEEN N PRECEDING AND M FOLLOWING" window functions without caching entire partitions.
FossilOrigin-Name: e7a91f12282afb5d5d7d78397a11d18e0268ee0c931d85e21fce00d13929494e
2019-03-04 21:07:11 +00:00
drh
50ef6716d2 Make all ephemeral tables built to hold the RHS of an IN operator be
index-btrees, never table-btrees, regardless of whether or not they are
used as IN_INDEX_LOOP or IN_INDEX_MEMBERSHIP.  That way, the same ephmerial
table can be reused for both cases.

FossilOrigin-Name: c2d50df8fd1a1fdae6226a3e77296ded09b53a74540caedd4868e686a93cbc10
2019-02-22 23:29:56 +00:00
dan
e7c9ca41b2 Add support for chaining of WINDOW definitions.
FossilOrigin-Name: c155125fd5dddb438c09d40f5137c47d88defb7a6ede4261f09d7bdaad250d37
2019-02-16 17:27:51 +00:00
drh
1cf197583d Give the sqlite3 object a pointer to the current Parse so that if an OOM
occurs, it can automatically set the Parse.rc value to SQLITE_NOMEM.  This
avoids a frequent extra test of db.mallocFailed in the innermost parser loop.

FossilOrigin-Name: 5c6638040b3017c6be016441422d965a3ca00dd6ae1f78cadc0b54562978f64e
2019-02-08 14:55:30 +00:00
drh
e5989723ba Honor key query parameters for SEE on the URI filename for ATTACH
and VACUUM INTO.

FossilOrigin-Name: 2e01096b8933a2315e3dffcd7d0de84c744c1b4be1d909388c61f0fd636ddb99
2019-02-02 15:59:49 +00:00
drh
23a885956e Add the SQLITE_CONFIG_MEMDB_MAXSIZE configuration option for configuring
the default maximum size of an in-memory database created using
sqlite3_deserialize().  This is necessary to make the interface reasonably
testable.

FossilOrigin-Name: cb72ee0478ce98c48aae059fd5de4e36caf2b8c953e08fcb799bfd119ad46b73
2019-01-31 15:38:53 +00:00
drh
9b747068ba Improvements to "PRAGMA parser_trace=ON": Make it a flag pragma, and then
use the flag to show the complete SQL text at the beginning of the parse.

FossilOrigin-Name: 507c43537f00d089efb3c3020fb6e826e8f89f3efa2caaa12c5309d35dd0c22e
2019-01-31 01:39:01 +00:00
drh
8d40673c84 Detect if two indexes of the same table share a common rootpage while
parsing the schema, and throw an error immediately.

FossilOrigin-Name: f21c6f1343edc4ba68f9f8e68caac34da0d1c651526ecaf61c0e2d66593a555e
2019-01-30 18:33:33 +00:00
drh
29c992cb04 Revamp the SrcList allocator routines to be methods of Parse instead of
being methods of the "sqlite3" object, so that they can leave better error
messages when the SrcList object grows too large.

FossilOrigin-Name: df08d472b090b212fb77ce2aae0e1ffe79ae5db4b1accf55e6fdb18e8b0a7098
2019-01-17 15:40:41 +00:00
drh
51d35b0fa9 The keywords TRUE and FALSE should only act as boolean literal values if
unquoted.

FossilOrigin-Name: 5547f39de993c708f72301ef25df190a2f007e0c4253799bdd9e86bb1ae41777
2019-01-11 13:32:23 +00:00
drh
5f913ecb62 Use the new SQLITE_IDXTYPE_IPK values (3) on Index.idxType to indicate the
fake INTEGER PRIMARY KEY index used during query planning.

FossilOrigin-Name: e22d2f905fe840bea51b536ebedc9b637190ea0a37f16559668d99a61e971411
2019-01-10 13:56:08 +00:00
drh
885eeb676b Enhance the ALTER TABLE RENAME COLUMN feature so that it works on tables
that have redundant UNIQUE and/or PRIMARY KEY constraints.
Fix for ticket [bc8d94f0fbd633fd9a051e3]

FossilOrigin-Name: f09aa3248e2b4a32ff5b5d37084cb2a27445322cb06a3354cef723f4f0b2cd34
2019-01-09 02:02:24 +00:00
drh
6b86e51eea If the OP_ParseSchema opcode with a non-NULL P4 operand does not parse any
rows out of the sqlite_master table, that indicates that the sqlite_master
table is corrupt, so raise an SQLITE_CORRUPT error.

FossilOrigin-Name: 598d7358e7329f0de6e3defc217665909e46874258ac29592ee2fd53e6411cda
2019-01-05 21:09:37 +00:00
drh
ee751fab4c Raise an error if the argument to VACUUM INTO is an identifier.
FossilOrigin-Name: 6c6fb1c6ea452c70b56fd4ac796affebee21512adba0455ae81c291b715f544f
2019-01-02 14:34:46 +00:00
drh
0de6efe59e Merge enhancements and bug fixes from trunk.
FossilOrigin-Name: 9fb646f29c05bca5f677a2c7c4f45c36bfe0a0c6a88cb7968b4a0459bdd63bb2
2018-12-31 18:30:41 +00:00
drh
d1d158bf5a Additional small performance increase and size reduction to the
sqlite3VdbeMakeLabel() mechanism.

FossilOrigin-Name: 1bdee199a71e0a6c247b85e72de9e3a3099b7179c33288735721facef3b96459
2018-12-29 14:23:22 +00:00
drh
ec4ccdbcb1 A new implementation of sqlite3VdbeMakeLabel() is faster and makes fewer
memory allocations by deferring memory allocation until 
sqlite3VdbeResolveLabel() is called, at which point the code generator has
a better idea of how big the relocation table needs to be.
The sqlite3VdbeMakeLabel() routine now takes a Parse* parameter instead of
Vdbe*.

FossilOrigin-Name: 4a0929ac76d8aa5dd65eac3b83d6bbf41e505e01d175ca0fb2b19ba02d439415
2018-12-29 02:26:59 +00:00
drh
01e92df41e Merge performance enhancements from trunk.
FossilOrigin-Name: 0f1b9ff9e1e6f13e03045fcb7d0907227085054f9eb0b0b8471fb26b0094b13a
2018-12-28 21:32:35 +00:00
drh
b6991796b4 Move the nOpAlloc field from Parse into Vdbe to avoid an extra pointer
deference on the fast path in sqlite3VdbeAddOp3().

FossilOrigin-Name: 8f10efc29dea7b816b1ba401726c268950d6671d890f686911269082a241d8d9
2018-12-28 20:14:03 +00:00
drh
2c04131ca7 Experimental code that tries to put the computation of subqueries inside a
subroutine, and reuse that subroutine if the same subquery is evaluated more
than once.  Current code does not work for CHECK constraints.

FossilOrigin-Name: 6c44838adbe5dc482bc010e91a6dd7a0f777c989f443dd600740d2c783208e0d
2018-12-24 02:34:49 +00:00
drh
85bcdce270 Split the code generation for the RHS of IN operators and for SELECT and
EXISTS expressions into two separate subroutines, because there is now little
commonality between those to functions. This is intended to help make the
code easier to read and maintain.

FossilOrigin-Name: 2b6494b1509f0d0189f98aa34c990eee99c775ff57826e79b2c5b0a12b4c97ad
2018-12-23 21:27:29 +00:00
dan
1ea0443c2d Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for preparing
statements that are not allowed to use any virtual tables. Use this to prevent
circular references in triggers on virtual table shadow tables from causing
resource leaks.

FossilOrigin-Name: 25666e3d03950caf753295cdb55df162e07dbcf6840b05875c6e0b127c469ecb
2018-12-21 19:29:11 +00:00
drh
1a6c2b1d38 Further refinements to the sqlite3_normalized_sql() interface. TH3 now
gives 100% MC/DC on that interface.

FossilOrigin-Name: c96bf6cca220e363b099455ce35195ce7e89d374a52dc787f56e7b11e587bced
2018-12-10 20:01:40 +00:00
drh
643d855da9 Refactor the sqlite3_normalized_sql() implementation. This is a
work-in-progress. There are still issues.

FossilOrigin-Name: a4c890b0af9786295e6df05022009d8946550adb873535c610be805c2b7a4083
2018-12-10 16:00:57 +00:00
drh
2f6239ed4e Allow the INTO clause of VACUUM to be a text-valued expression.
FossilOrigin-Name: af172b53b46759f491f522356e14c5e2374d3f25ec70fbc1e100cadded8f9b22
2018-12-08 00:43:08 +00:00