Commit Graph

19174 Commits

Author SHA1 Message Date
drh 9f88e6d861 Add the -dDIRECTORY command-line option to LEMON.
FossilOrigin-Name: 9cd20475ff3b2ca1a58e441194c921780d25bdb9b9c744a6b4541b888194efb8
2018-04-20 20:47:49 +00:00
dan 340e9e125b Enhance the "rbu" command line utility a bit.
FossilOrigin-Name: 61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976
2018-04-20 20:37:25 +00:00
drh 4b8bd84302 Fix a harmless compiler warning.
FossilOrigin-Name: d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940
2018-04-20 20:09:22 +00:00
drh 7c48360d7c Avoid the use of statement journals on DELETEs of a single row without
triggers or foreign keys.

FossilOrigin-Name: 20bf5800808ea02b2aa4bf01a380926784c0e7514a2c73ca303cac1f5c732ae0
2018-04-20 19:46:52 +00:00
drh ac9151d848 Avoid opening a statement journal on single-row UPDATEs without triggers or
FK constraints.

FossilOrigin-Name: 2772404b8c570caf3c31d2b0530cf347a24f6f60e220e726c086537b38ebfa85
2018-04-20 19:32:35 +00:00
drh 9cadb2308b Fix a VDBE comment on upsert. Provide an error message when upsert detects
index corruption.

FossilOrigin-Name: 279c48f6061f766f5437edd6964c0dd1e10399314eb17b6e5ee34df925a776ed
2018-04-20 18:01:31 +00:00
dan 224d92c8c0 Add tests for name resolution in ON CONFLICT clauses.
FossilOrigin-Name: cf253584ecf7aed04406b4bae78b536818fadfb3fb96c05f2c99954b841db85f
2018-04-20 17:50:49 +00:00
drh 4da91eed80 Avoid unnecessary cursor seeking when performing an UPSERT.
FossilOrigin-Name: 693a3dcbdd8fb2d516c0f46fdbb478838cde675afc1026740e942705aac3c07f
2018-04-20 17:02:16 +00:00
drh 023e89760f Improved VDBE comment on UPSERT code.
FossilOrigin-Name: 131ed95e1452a5b0d92341c48a5d3915b328ccfce2cf605f702428ae7ee3e21b
2018-04-20 16:49:51 +00:00
drh 5deb1813cd Minor simplification of the previous checkin.
FossilOrigin-Name: d1906689abdb685f78aa97bca4bf301204d12846016d27bc86dcc9ce2b024d24
2018-04-20 16:27:57 +00:00
drh fb2213e1ff Avoid unnecessary cursor seeks during upsert processing.
FossilOrigin-Name: 7c4b6d5475092a3e205f01a6972366e27a404568e8e7ba327f2feefac2ce2c7c
2018-04-20 15:56:24 +00:00
dan a46838cb13 Add test cases for UPSERT. And a fix for a "REPLACE INTO ... ON CONFLICT"
statement where the new row conflicts with both the IPK and the ON CONFLICT
indexes.

FossilOrigin-Name: d8eb9f8d9b61400c7e12f01ef5c233257b03532221f7c7a8386f7ac2db439626
2018-04-20 15:34:08 +00:00
drh 7fc3aba862 Enhance UPSERT so that the UPDATE uses the same set of cursors as the INSERT.
FossilOrigin-Name: c37f39d18d41ae5ba6c4561d87cbbf71f3b6896b86cc5cff9cdf046b02dc521a
2018-04-20 13:18:51 +00:00
drh 2ac4e5cca9 Minor simplification of the cursor allocation logic for update.
FossilOrigin-Name: fdf71be65835e7e8915d16dd64114de35c4754ef5b94a2af6cac88a94817fb75
2018-04-20 00:40:19 +00:00
drh 7963691314 Fix the handling of "PRAGMA count_changes=ON" with UPSERT. Also improved
the implementation of count_changes in other places, without changing the
behavior.

FossilOrigin-Name: c6f71115eb933c2aee295bc31e5139112463c28e15a3b3ea242fd9bac168aed9
2018-04-19 23:52:39 +00:00
drh 2633b28983 Minor simplification to the upsert logic.
FossilOrigin-Name: e657c1d60f5fca9464e9bcab24bc328855bec9986e0a029877f639355da4b201
2018-04-19 21:29:52 +00:00
dan a67d02f509 Modify a test case in zipfile2.test to take into account that with some
platform/file-system combinations it is possible to fopen() and fread() (but
not fwrite()) a directory.

FossilOrigin-Name: 893e6089c875e947ddadb23f031a81bc36da8b060d2212363098992ddb90378b
2018-04-19 20:06:10 +00:00
drh 482dc64505 Add the --upsert option to the wordcount test program.
FossilOrigin-Name: ee1e750baaf4c66b4e1f103d8b80362f57e711ac601e57f99ed6a33913f443d2
2018-04-19 16:52:37 +00:00
drh 55a3490cf2 Add the ext/misc/tmeplatevtab.c template for virtual tables. This is a
work-in-progress as it still needs improvements to the comments in order to
be useful as a template.

FossilOrigin-Name: 22358fb5495c727a4dde129128fe409a7b929a5ffa143b1e2879f84d7680ec3c
2018-04-19 16:14:59 +00:00
drh bb6b1ca73d Fix a problem in the new upsert implemention, discovered by OSSFuzz.
FossilOrigin-Name: b6d5ea59fe83716f464e408b7eef0310c6d30b3493e3f966362db2e30b36e821
2018-04-19 13:52:39 +00:00
drh 5e3a6ebf34 Fix the table name aliasing on INSERT so that it occurs before the column list
rather than afterwards, just as it does for PostgreSQL.  Add table name
aliasing to UPDATE and DELETE.

FossilOrigin-Name: 861a2e2a4895f96a5d8e1730e744983b2ac4311d0c2cf201c0e59f409030d5d7
2018-04-19 11:45:16 +00:00
dan dedff6be8a Add the "sorter-reference" optimization, allowing SQLite to be configured so
that some required values may be loaded from the database after external
sorting occurs for SELECT statements with ORDER BY clauses that are not
satisfied by database indexes.

FossilOrigin-Name: ef74090a40ceaef2fd93a7613ec99a191ce986811c852e96f4a19719f18af4f0
2018-04-18 19:56:14 +00:00
dan 52b3e340cc Minor changes to test script upsert4.test.
FossilOrigin-Name: 0cb83c84d10b89ef7a5504862566a609307c63e7571dd711d8b9f995d29e5a8c
2018-04-18 19:45:14 +00:00
drh 5a2e65ed63 Avoid a NULL-pointer deref following OOM.
FossilOrigin-Name: 413015c029d850d4ce7e66be1f59b57f291254240a958856378a62f5ac4a5092
2018-04-18 19:08:44 +00:00
drh 4e8b9925bf Fix a test case inside distinct.test.
FossilOrigin-Name: 61cb8a391a0c709340ac60ffd0c58f950567892a8404c2bec7b9b1f64b3cc5cf
2018-04-18 18:19:25 +00:00
drh 277434e9a7 Improved matching of COLLATE clauses within the ON CONFLICT conflict-target.
FossilOrigin-Name: 8f4376e52b6124986937a3837ad83a18863c3144ef3b438a0d5e9231bf6c8980
2018-04-18 18:18:12 +00:00
dan 370c32628f Add extra test cases for UPSERT.
FossilOrigin-Name: 7ea08d0750dd9e07d2ffea336127034800db14aa23e60adec384d338871bf53a
2018-04-18 17:56:37 +00:00
drh e79f629985 Fix a problem in the sqlite3ExprCompare() function that caused two
dissimilar expressions to match if they have the same "COLLATE name" at
the outer layer.

FossilOrigin-Name: fb16348a5bd52752098c9aeacc3281c4e1e8eb5a868d131ea6c3271dc4226b40
2018-04-18 17:52:28 +00:00
drh 6651e10ee7 Add support for PostgreSQL UPSERT syntax and functionality.
FossilOrigin-Name: fba24aec235dd6f124c1ece66cdac485c9d96e0578c4fbacd8f49d7b767a5b4a
2018-04-18 16:03:36 +00:00
drh 5412eb5106 Fix the build for SQLITE_OMIT_UPSERT
FossilOrigin-Name: 32956519173ee49ec9dd9aa7952278eb4effe567493c6cb304e16f887df6bafa
2018-04-18 15:33:21 +00:00
drh a90d84fe21 Add the --sorterref N option to the CLI.
FossilOrigin-Name: 902a40897f74ac8a3bc72ef84c2161ab308b5601381cc9eea18147bfefa978ce
2018-04-18 15:21:13 +00:00
drh bbade8d1f6 Omit some code not used without SQLITE_ENABLE_SORTER_REFERENCES. Improvements
to comments used for documentation.

FossilOrigin-Name: f3596ab9eb1168dc75202e6f79e12c67d518b3a0659a0a629c707f43990fa7cf
2018-04-18 14:48:08 +00:00
drh 7590d09324 Remove an unused local variable.
FossilOrigin-Name: 9afeb0c88b211e3ad90697778ec8ebb80f216fe7078c3a2f51651c35d3828746
2018-04-18 14:04:19 +00:00
drh 3bc431550a Enhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false".
FossilOrigin-Name: 594ebc69557095c9262db39129dd50a3dbf038556a3d2a3ea69b82ed4c61e2b9
2018-04-18 11:35:35 +00:00
drh e7df892ad8 Add checks to the CLI that issue a warning if SQLite gets initialized prior
to the last sqlite3_config() call.

FossilOrigin-Name: 40b117347763ef67f6621d3665ca7f287eebfd7435e3178055a8c624eb06b2c5
2018-04-18 10:44:58 +00:00
dan 16a474273e Fix a problem in the shell preventing it from working with
SQLITE_OMIT_AUTOINIT builds.

FossilOrigin-Name: 89209000a205c685bb6bd941376ef16e507919d192d606c1be110ccf2921d9bd
2018-04-18 09:16:11 +00:00
drh 9916048b89 Add new testcase() macros and fix a bug that was revealed when trying to
cover all the new test cases.

FossilOrigin-Name: 266a99f7c068aadbd08157d1d495a428109ad7a32d872f8026e8db0f89c40f91
2018-04-18 01:34:39 +00:00
drh 54514c9813 Remove unreachable branches. 100% MC/DC in TH3 now.
FossilOrigin-Name: 558865d5c3c297155e1be5ea73effb46a995ea146bd745b23330c94782c6c45b
2018-04-17 21:59:34 +00:00
drh 7ef8a3e666 Added a comment on the assert() added to the previous check-in.
FossilOrigin-Name: 542547c1ce770a1427d3023d8c8fdcb2db7b1e017bc111e3484641f97e42381a
2018-04-17 20:09:27 +00:00
drh 7f5f306b84 Fixes to the logic for constraint check reordering during upsert.
Improved comments on constraint check bytecode.  Add an assert that
prevents the same label from being resolved more than once.

FossilOrigin-Name: 1ddbb0ff5586ef5ca987e4309979f24f95eea883ed68937094a2db2d61e75657
2018-04-17 20:06:24 +00:00
drh 2928546d04 During PRAGMA vdbe_addoptrace=ON, show calls to sqlite3VdbeResolveLabel()
in the debugging output.

FossilOrigin-Name: 9ff07a06cef6e04777d2d5b81f96e8626e835382e62320ecf17b3ff73573e23e
2018-04-17 19:29:58 +00:00
drh 6e341b9347 TK_REGISTER expressions nodes are probably not constant. Make sure
sqlite3ExprIsConstant() knows this.

FossilOrigin-Name: f3d91cad929cfbee8f621425f55b5f12e79567362cf8769a786adb3e1bbef214
2018-04-17 18:50:40 +00:00
drh dedbc50811 Simplification to the upsert logic.
FossilOrigin-Name: f36d07a5b24cc48e3daa8b18dd34c50d9025c6c0ba019926610538b54f7b66ec
2018-04-17 18:18:05 +00:00
dan 2cc00423a0 Add some more simple test cases for UPSERT. And a minor fix.
FossilOrigin-Name: 27cd3b2fb2ad0cf2b36741bd1057cb7973954d40456e9db158261a38b049d2b5
2018-04-17 18:16:10 +00:00
drh 5015c9b50e New test cases for upsert.
FossilOrigin-Name: 907b5a37c539ea67c285c87399b494c7fe15014389a2ea3d49e90640b58946ae
2018-04-17 16:16:40 +00:00
dan 2e3a5a810a Add SQLITE_CONFIG_SORTERREF_SIZE configuration option.
FossilOrigin-Name: b25a7bb769b8397a00736bd922bd24b1200b2f82d36d42ecb4c3eb17efb4b84d
2018-04-16 21:12:42 +00:00
drh f1a0223077 Merge the Lemon enhancement from trunk, resulting in smaller parser tables.
FossilOrigin-Name: 641f41722c68f1d51251b10d4d3d7c473d08ee999f6db20023ef6dcd4dc5f6e8
2018-04-16 14:36:34 +00:00
drh ed0c15b52e Lemon enhancements: (1) Do not allocate space for the 'error' non-terminal
if it is not used. (2) Fix an off-by-one problem so that 'unsigned char' can
be used for symbol numbers if the number of symbols is 256.

FossilOrigin-Name: 3b7801acff91905d0e78e06121ebcf2664f6de5f605699dc8726ec9bcb558eb8
2018-04-16 14:31:34 +00:00
drh 0a6259f539 Remove the MySQL upsert syntax. As an optional alias to the insert table
name in order to finish out PostgreSQL upsert syntax emulation.

FossilOrigin-Name: 810d9f63be46c1452718b05e51c519fb64e9fabf2f1813b5e07b1041dbb71880
2018-04-16 13:26:53 +00:00
drh eac9fabbc9 Add support for the "excluded.*" names in the UPDATE clause of an upsert.
FossilOrigin-Name: 0203f34faae07fbea0bff2d23b81fb37df8854cded4cdadac5a034132a096b6d
2018-04-16 13:00:50 +00:00