Commit Graph

24498 Commits

Author SHA1 Message Date
drh 1cc5c4ac84 The same restrictions on the use of WHERE clause terms to drive indexes
in the presence of RIGHT JOINs also apply to the use of WHERE clause terms
to manufacture automatic indexes.  This fixes a problem identified by
[forum:/forumpost/51e6959f61|forum post 51e6959f61].

FossilOrigin-Name: 342c501f532523347e6c339351e02043dd6ee9e11a291224b65ea72bd6c2ba40
2022-06-10 16:41:54 +00:00
stephan e45b87a9b7 fiddle: minor style tweaks, including using swapped colors for the input/output fields to help (hopefully) reduce the "which field is which?" dissonance.
FossilOrigin-Name: e25dad868f9ef2c7847319c9f6f106999ba8b0a3e09ed9edfbd25e8fc6f3c10e
2022-06-10 15:43:03 +00:00
drh 958fcd417c Do not allow constant propagation between WHERE-clause terms and ON-clause terms
as this can confuse RIGHT JOIN.  Fix for the problem reported by
[forum:/forumpost/8e4c352937e82929|forum post 8e4c352937e82929].

FossilOrigin-Name: cab9b4cccd13bf0ab2bc38dc9a9c04ddd34e29c65ab6aef07b6bb3c31a43bece
2022-06-10 11:28:52 +00:00
drh a27e350b6f Fix a faulty assert() statement identified by
[forum:/forumpost/0b91a75039|forum post 0b91a75039].

FossilOrigin-Name: 1f132bb03a22479ceeca0fd14940e2a1b29ce54b7784d5b0133450056813d877
2022-06-10 10:10:31 +00:00
stephan 0c2b00b0d6 fiddle: modernized the UI based on related code in fossil's /pikchrshow. Changed the color scheme to match sqlite.org.
FossilOrigin-Name: c4523ffcc076e9cddba62c3b832f9a04d4f3c5595a312ac74099927aae085a52
2022-06-10 09:31:12 +00:00
drh 65458dc146 Do not allow the subtype of a value to cross a subquery boundary. This
fixes the problem identified by
[forum:/forumpost/3d9caa45cbe38c78|forum post 3d9caa45cbe38c78].

FossilOrigin-Name: bbaf1f2eb1e1637b356ed7ab1d1cf5bbc8e1fe3bb2fb46a8f37de091726f38af
2022-06-09 20:26:06 +00:00
drh e5dea28482 Prevent subtype values from slipping across a subquery boundry when the
subquery is implemented as a co-routine.

FossilOrigin-Name: 9e51a6c0fbfb1899b2b01888430125fba6d4da9bad9eeaa3ad41e29fca54bbe5
2022-06-09 17:17:14 +00:00
drh 8878f8a8d3 The subtype of a value should not propagate across a subquery boundary.
Proposed fix for the problem reported by
[forum:/forumpost/3d9caa45cbe38c78|forum post 3d9caa45cbe38c78].
Additional works is needed as not all cases are covered.

FossilOrigin-Name: 08af1fe27ebd0edf6e0f1ac477deea033e7f7c813f1016b75196836daf02d2e4
2022-06-09 16:19:01 +00:00
drh 0483668007 Move an #ifdef in shell.c to avoid a harmless "unused function"
compiler warning.

FossilOrigin-Name: 5abb5ef500f52c52dac33e54d824cf89481fec1643c27943f34f0ca4560a7e00
2022-06-08 18:29:23 +00:00
dan 0a841a2b85 Avoid zeroing the value returned by sqlite3_changes() when a DML statement is automatically reprepared in sqlite3_step().
FossilOrigin-Name: 09c8f9f1970cd5b369d98a2b38f0b04d44ed095cb0bda80f7968bb6be4e0263b
2022-06-08 18:20:36 +00:00
drh 8a5469b6f5 Improved comments on the new query flattener restriction of the previous
check-in.  Also a NEVER() macro on an unreachable branch.

FossilOrigin-Name: 8c9e2d6315fde014bd6e25a7fa58ba054f5328c8a56e9d3d1c2d069c025a1b03
2022-06-08 17:48:14 +00:00
drh 40357f0d5d Fix the query flattener so that it refuses a flattening that might leave both
an inner-join and outer-join ON-clause constraint (or equivalent) on the same
term of the FROM clause.

FossilOrigin-Name: f6c4fb48b65c2e8659aa0a1119c330e8bad5e42b2db2030850bfc9c04afef5c8
2022-06-08 15:38:16 +00:00
drh 5c118e3946 Add restriction (29) to the query flattener - do not allow flattening that
would leave both EP_InnerON and EP_OuterON constraints on the same join term.

FossilOrigin-Name: c585d6a4678b04f4cedc08852d01c44cdf52ae2c8ccd1174c3d5a395088bf528
2022-06-08 15:30:39 +00:00
drh a341bae948 New test cases refute check-in [3f45007d544e5f78].
FossilOrigin-Name: 12d3c96c39d12f6b01b77456eb874fff445ebfc60f50aada51b06ed37af364ea
2022-06-08 13:13:12 +00:00
drh 093dd41e97 Do not allow a partial index scan on the left table of a RIGHT JOIN, because
since the index is partial, some rows will be omitted from the scan, and
those rows will subsequently be picked up by the no-match logic in the
right-join post-processing loop.
[forum:/forumpost/c4676c4956|forum post c4676c4956].

FossilOrigin-Name: 615c0026119f7870c3b6ef9dcb57ce4ecf5acedea3e2b5cfc25aa450eb8f17a0
2022-06-08 12:46:58 +00:00
drh f6bee94e22 Minor fix to test/index9.test so that it can be invoked with other
index tests using a wildcard.

FossilOrigin-Name: ccbd6e774903f9202f9311954979f6fcc3b13eba1f3402a549a7aee6ed1d55eb
2022-06-08 12:35:39 +00:00
drh 644817721e Update the routine that determines whether or not a partial index can be used
so that it is not specific to LEFT JOIN.

FossilOrigin-Name: 5a107fd7fa01554d73fefc0611e5797b8c23e782ce0df3aeba7e2f288675b2ce
2022-06-08 12:20:49 +00:00
drh 33b2cb9aec Fix the query flattener to deal with a RIGHT JOIN corner case described
by [forum:/forumpost/323f86cc30|forum post 323f86cc30].

FossilOrigin-Name: 3f45007d544e5f787d5837b4d9f484ba473d69cdba83c229228e9c2f6b972b75
2022-06-07 13:09:58 +00:00
drh bb1369037b Test cases for [forum:/forumpost/323f86cc30|forum post 323f86cc30] added
to join8.test, though commented out so that they do not (yet) run.

FossilOrigin-Name: 7f97cb67d01a11f1b7e5b5f05824f9adbc6e4689d1809d60ceda50a595ba6d4a
2022-06-07 11:02:43 +00:00
drh d580bea7d4 Preserve the database encoding on the CAST operator in the
sqlite3ValueFromExpr() routine.
[forum:/forumpost/800eecf5e6cdc3f4|Forum thread 800eecf5e6cdc3f4].
Test case in TH3.

FossilOrigin-Name: 3f6a442099b8264cc788e8aa2b12cc583439a5263c4fe433fd22b7af1be2458e
2022-06-07 10:14:22 +00:00
drh 6fdac75127 More precise determination of when a WHERE clause can be used to drive an
index on an outer join.

FossilOrigin-Name: 318543a91108c6fd0764d7ee7beee49838f54d44c54dae3dc9d4cb8336d52fe1
2022-06-06 23:22:06 +00:00
drh 16828c8c12 More precise determination of when a WHERE/ON clause term can be used as an
indexed join constraint.  Testcase macros added to ensure test coverage.

FossilOrigin-Name: f419e98c515e704efa11728192b2594e962cb0e6d2d1837f99a8caf65f4d93cb
2022-06-06 22:33:44 +00:00
dan 93c4087ffe Extra test cases for outer joins.
FossilOrigin-Name: c7505765280fb27ec2c8c4da6f87229a4078e3a4a27525226b6bf55864caa04b
2022-06-06 21:08:27 +00:00
drh c18fc6134e Do not allow a WHERE clause constraint to be used to drive an index for
the right operand of a RIGHT JOIN, since this can cause problem if the
constraint implies a not-NULL value for one of the columns for the left
operand of the same join.  See
[forum:/forumpost/206d99a16dd9212f|forum post 206d99a16dd9212f].

FossilOrigin-Name: 4a31b7942a15c9c4363477365784d6d4ac5b1bbe8ff8aeaf2dd3d6532bf8bc96
2022-06-06 15:27:42 +00:00
larrybr 8a4d2bc34f In CLI, drop .dbinfo command when build options prevent it from working.
FossilOrigin-Name: 4b50a55165f4603674a250df89cfc5ac1fef8aabaf433df8400df14d53bfbbe0
2022-06-06 15:22:11 +00:00
larrybr 0dbb3db431 Sync w/trunk, pickup fts3corrupt6.test change.
FossilOrigin-Name: 268072f636b25c24ec47e34f2a8356f466ec200b80487b1041e89e0ae909c8bd
2022-06-06 14:00:41 +00:00
stephan 8fca1c7044 fiddle: replaced the huge file selection widget with a smaller proxy button.
FossilOrigin-Name: f7c17449ea0685e322f50abe7a59b7afcde0f7e38e03645ec5b13753a6d0dcf3
2022-06-06 06:29:09 +00:00
dan fd80fa9b6d Fix a test case in fts3corrupt6.test. Was failing due to [f1dfbc4f].
FossilOrigin-Name: 04b2e47784238008ce9057e2761ded91d895dc16d3bc8a3a3508df98a4769602
2022-06-06 06:17:54 +00:00
stephan 626aa48c26 shell: in WASM mode, permit ATTACH because the filesystem is a virtual sandbox and ATTACH can be used to provide more import/export options. Minor doc updates in sqlite3-api.js.
FossilOrigin-Name: f28de5b726999b913b442fa51355d020ba1f1662d2f7978380623c16438eb238
2022-06-06 04:09:44 +00:00
larrybr f3d6e8fd6e In CLI, drop .dbinfo command when build options prevent it from working.
FossilOrigin-Name: 2512d2f68dfff4d74c881a4102b63ca528e690ad93ab2b4eb1f03ce1d9ac155c
2022-06-05 22:58:40 +00:00
larrybr b61c2424d7 Create new branch named "dbinfo-guard"
FossilOrigin-Name: 8d942ba72ea995d0e8d1f8694bb428e5f919fc75afd3e059a69547e27991d580
2022-06-05 22:40:49 +00:00
dan 93a4b411ef Fix to test case in fts3corrupt.test. No changes to source code.
FossilOrigin-Name: d18818afc6021a32989499c26ab38fa442e5a55e662e39bb06e5c0daa9c65e25
2022-06-03 14:08:40 +00:00
dan 181d75ef9e Fix a 1-byte overread in fts3 that could occur when processing corrupt records.
FossilOrigin-Name: f1dfbc4f7452154ca5190ac22e17fdabebb92833967b11f7dae21b8d3a5857bd
2022-06-03 13:52:53 +00:00
dan 410fac35d7 Fix a problem with flattening and window functions causing an "IS <column>" to be transformed to "IS TRUE" or "IS FALSE" when <column> is a view or sub-select expression that is the literal value "TRUE" or "FALSE".
FossilOrigin-Name: 2a952c7738d94e70024e06600fee8c3a49f317f2d02774468019bd7cf9488c8b
2022-06-02 16:26:21 +00:00
mistachkin bf154369e7 Avoid a direct use of abort() in debug builds to prevent a compilation issue for Windows CE.
FossilOrigin-Name: 8eb9a7dd07afc0aef0b7c67054d73e7e821138867d115407b71c985e90d44d59
2022-06-02 02:45:59 +00:00
drh 486191603f New test cases for row values and RIGHT JOIN.
FossilOrigin-Name: 5f0582b90fab9111e4a645c692549c35480e62635c596f8c7fa3466bd22f7235
2022-06-01 20:08:22 +00:00
drh f89f4efb28 Ensure that subqueries associated with row-values are invoked before being
used when processing a RIGHT JOIN.  Fix for the problem described by
[forum:/forumpost/087de2d9ec87305b|forum post 087de2d9ec87305b].

FossilOrigin-Name: 5a9465dcc0c23fc2c66cd4898bcdfd5086fe4c71ec19a95db7221fdf7c0bbbbd
2022-06-01 16:05:25 +00:00
stephan 4e5aeb54f2 fiddle: added another UI element to the list of those which are disabled during long-running activities. Added DB.close() binding to the Worker-based wasm binding.
FossilOrigin-Name: 5933163ed1a8f996e81023c7c5822655dc6411d30016f37fe8863f760530dc5b
2022-06-01 16:04:29 +00:00
drh a5d06a3d54 Ensure that all necessary row-value subqueries are invoked while running
the right-join post processing.

FossilOrigin-Name: e4e71b4cd4c026fc36f0da1703e6237e6ddd8ff2e08dc3c0011632b9e63098cd
2022-06-01 15:53:11 +00:00
stephan 23aa8ff4de Minor tweaks to, and consolidation of, the wasm-related build flags.
FossilOrigin-Name: f0ad6b1b324f9c0f4340f6cf9584884d1206b56fe1010db43bcbef324e713ea3
2022-06-01 14:52:23 +00:00
dan f74f4ed5b5 Fix a minor problem in the Tcl "incrblob" command. This does not affect the SQLite core.
FossilOrigin-Name: e96feccc21d9b858f076960e029b615809243d0cc3f95db75180feb01887451f
2022-06-01 14:32:05 +00:00
drh 0f4b534b60 Candidate fix for the problem with row-value WHERE clause constraints on
a RIGHT JOIN.

FossilOrigin-Name: fdd782a7bb217e2aceda97a588c0d7874ee19885abfcf0658472d6c3387da6ee
2022-06-01 13:32:47 +00:00
drh 6d013d890e Only include the code for sqlite_offset() if compiled with
-DSQLITE_ENABLE_OFFSET_SQL_FUNC.

FossilOrigin-Name: 382cd7e10b2df4216da8f25b55546bc74a963d9834af240f75ec8b8321ba106e
2022-06-01 13:32:05 +00:00
drh 1324b2830e Fix a typo in a comment in a test case. No changes to code.
FossilOrigin-Name: 570efa45dd4c6848dcbd550f78fcaa00b6d84dcffe0a2d12e65ea8ee4468c0e8
2022-06-01 13:01:57 +00:00
drh 0286cdbca6 Additional enhancements to the test cases.
FossilOrigin-Name: 55cfad74cace74e541b354228e3ad46e17028213a9f639edf2007c6a8f3ba8fc
2022-06-01 11:58:11 +00:00
drh 47b4969e2d Fix test cases in the previous check-in to make them postgres-compatible.
FossilOrigin-Name: f223ba72b6e02a7ccfd894b4b135f4609b1eb79f547ec279b1c52a6996cd5a73
2022-06-01 11:46:39 +00:00
drh 36c19f7799 Test case for [forum:/forumpost/087de2d9ec|forum post 087de2d9ec] showing
a problem when a row-value constraint is used with RIGHT JOIN.

FossilOrigin-Name: d1e3e0d26e302587a6cfcb7aa4fcdefe2b3891037732a0df0d0fe10a14454e00
2022-06-01 11:43:57 +00:00
stephan ea7a4e4fb3 The Worker-specific variants of the most significant DB-class JS bindings are implemented, most notably various uses of DB.exec().
FossilOrigin-Name: 371d6f7497016ca9bf82c8524b4d701ddf1e614b3fb4e69ff63935da0d51ed05
2022-06-01 11:20:07 +00:00
drh 645682a7c7 Move the sqlite_offset() function implementation to be an in-line function,
thereby avoiding special case code and freeing up a bit in the
FuncDef.flags field.

FossilOrigin-Name: 1c9812c458bd229c862efe5df1b64fae333da9871c8756b5ae4605a81bcda4b5
2022-06-01 11:05:59 +00:00
stephan 6ffa895884 Initial proof of concept code for a JavaScript binding which runs in the main window thread but acts on a db handle running in a Worker thread. Expanded the DB.exec() and DB() constructor to simplify certain use cases.
FossilOrigin-Name: d9efe3e92d1c95aee6f5ae37a8ba28d8cf4891d746744ce4aa2464f766821a0b
2022-06-01 08:09:06 +00:00