Commit Graph

23587 Commits

Author SHA1 Message Date
drh
9d44f18b3c Add a new built-in subtype() function.
FossilOrigin-Name: a25f4ce255c034fc694c33728aedb98289ebccda9c48920829ef780b92b8faee
2022-01-09 16:54:02 +00:00
drh
daefcd9e00 Merge the JSON function enhancements from the json-enhancements branch into
json-in-core.

FossilOrigin-Name: e116501c2f0e594eb7a3dd804daa943cc508f32ded3078aed21b695ec83bcd4c
2022-01-08 15:37:13 +00:00
drh
dc60c68cc0 Improved commenting of changes in the json1.c extension.
FossilOrigin-Name: 4d81425e1bf2cff6fa961d0a7936b5f62d3f8ffe9bffea89c1e8b8ddf8fad6f4
2022-01-08 15:05:53 +00:00
drh
4f3557e4c9 Notes on the JSON enhancement proposals.
FossilOrigin-Name: 18160985ea6b2bbf27de25e0f4f3a1ebcdb079a36af039fc06e37a834e49e772
2022-01-07 18:09:56 +00:00
drh
a3f51d7b3e Reverse the meaningn of -> and ->>. ->> raises an error on invalid JSON
but -> does not.  This allows ->> to behave the same as PG and MySQL.

FossilOrigin-Name: 85f8170555ee0d4d28cb7e120a7062e9f64c331a936fdfa29fc0e67224eea7c6
2022-01-07 17:26:40 +00:00
drh
9956c18a81 Change the -> operator to use json_extract(). The ->> operator continues
to use json_nextract().

FossilOrigin-Name: b4c8a62381755b9f1447e10ab95df7209eebda91f9a4583ef1c093a13f6b4725
2022-01-07 17:14:35 +00:00
drh
338b1fde62 New json_nextract() function that works like json_extract() except that it
returns NULL instead of raising an error if the first argument is not
well-formed JSON.  Or if the first argument is not well-formed JSON and
the second argument is '$', then return the first argument quoted.  The
"->" and "->>" operators are converted to use json_nextract().

FossilOrigin-Name: dc00f5286d26524b149de071490320afaa203fec5777b3eb813f07963614861a
2022-01-07 17:08:48 +00:00
drh
a4e4e18494 Add the json_ntype() SQL function. Works like the 1-argument json_type()
except that it returns NULL if the argument is not well-formed JSON, rather
than raising an error.

FossilOrigin-Name: ed9956f5ddca68141eded81d5362847db603257329801622c4eb3b0732112f14
2022-01-07 16:03:00 +00:00
drh
12b9fa979c Accept abbreviated JSON Paths on the right-hand side of the -> and ->> operators.
FossilOrigin-Name: d15410900dccbb7159683c29f640fa321b1e019718827334f5fefe89da623008
2022-01-07 15:47:12 +00:00
drh
d5326c333f Add new binary operators "->" and "->>" to the parser that evaluate to
2-argument SQL functions by the same name.  Add new "->" and "->>" functions
to the JSON extension that are aliases for json_extract().

FossilOrigin-Name: c4e4e3a3fc5da0381ccb7930706e57d7831d87f9c63bafe49ae64117701e1cfe
2022-01-07 14:58:47 +00:00
mistachkin
3c64888253 Add the '-guard:cf' compiler option for Windows 10, per [forum:/forumpost/8d3b4ad694|forum post 8d3b4ad694].
FossilOrigin-Name: 2d6a16caa7d28ad5c766036b2eb6c2020683fcc9389b3c7df2013739929dd36f
2022-01-06 17:13:56 +00:00
drh
9dbf96bd70 An attempt to integrate the JSON functions directly into the SQLite core,
rather than holding them as an extension.

FossilOrigin-Name: 583b47d865fb8d2c9ae4d3a4e70356a8a758978efb0a282f6b19775bf41fb748
2022-01-06 01:40:09 +00:00
drh
10f7365748 Remove two NEVER() macros that can sometimes be true if the database is
corrupt.  dbsqlfuzz 0414d2c18290fc80fd5fb540def7d3e46c1ae9c6.

FossilOrigin-Name: b6a82f3c3b9d89fdf628c7f117b6a4a64383a36c84fe84d47c80e845c9bd8a4f
2022-01-05 21:01:26 +00:00
dan
c6977c1c0d Fix an assert() failure that could follow an OOM when coding a RETURNING trigger. dbsqlfuzz case 5d3e2438f15dc32b473d9f29413157857efa1212.
FossilOrigin-Name: 7ae596dd4a73a09585c5dc9f4faf75d126d0733fc2fb32c1de64126a1088d967
2022-01-05 15:54:02 +00:00
drh
ebc4434e99 Improved handling of OOM errors in sqlite3ExpandReturning().
dbsqlfuzz 1040b720f0bbc3bdcfe7336acffbf71517e3ef82.

FossilOrigin-Name: 33c6b8e94bda12df13b4d2dd782b3120c3628596b86ef531d20b3100bf159b50
2022-01-05 11:49:58 +00:00
larrybr
d0a9a46215 Test .mode quote blob output
FossilOrigin-Name: ef4dcd1080241a62a50eff28ef12c49da0116032f10843aaf048ae7ad3cdfd0e
2022-01-03 19:33:44 +00:00
drh
b248668bc9 Small performance and size optimization to allocateCursor().
FossilOrigin-Name: 23f042669aff535afa6ee9de367656848d01e90a1c9dab9359fa938a615b4195
2022-01-03 01:43:28 +00:00
drh
80d99e19b6 Remove unnecessary assignment operations in the btree search algorithm,
for a small size reduction and performance increase.

FossilOrigin-Name: 01bd266eb682feed901a0995c2232b62d8444d19dbb227095dfbfe8edeaa5d88
2022-01-02 21:53:54 +00:00
drh
5d1bf4f560 In the CLI, fix ".mode quote" output for UTF16 BLOBs.
[forum:/forumpost/b4bfe62fe6|Forum post b4bfe62fe6].

FossilOrigin-Name: 728e9dcc6d211acd787837c41cb62275284b5e02f55bd28bf5a44e233bcb057a
2022-01-02 20:54:33 +00:00
drh
bda4d20080 Do not open a rollback journal file when the journal_mode is OFF, even if
such a file exists on disk. See
[forum/forumpost/ec2a102440|forum post ec2a102440] for a description.  I so
far have been unable to find any harm to come of the problem, other than the
assertion fault when in DEBUG mode.

FossilOrigin-Name: fdf9ed665b2fb07d26f3852bfd2170f2fb56851edd2851d47672116a8ea58463
2022-01-02 19:32:43 +00:00
drh
d0fa3484c6 Improve formatting of an assert(). No functional changes.
FossilOrigin-Name: 4bb78ce8b50af3c6f04ffdf4de4438e61370a73ccfa971479af5d58a0a7e5fbb
2022-01-02 19:10:49 +00:00
drh
29bbc2b51f Performance optimization in btreeParseCellPtr() by unrolling the loop that
decodes the rowid.

FossilOrigin-Name: fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
2022-01-02 16:48:00 +00:00
drh
7e17a3abbe Small performance optimization and size reduction in sqlite3BtreeDelete().
FossilOrigin-Name: da0af4dd9ba4180a16543fac1549fd4ccecdc66dcf6d275f77de21fd80708882
2022-01-02 14:55:43 +00:00
drh
44a5c0257f Clear the cache of triggers used to implement CASCADE foreign key constraints
whenever the schema changes.  Fix for the problem identified by
[forum:/forumpost/2831335356|forum post 2831335356].

FossilOrigin-Name: 5232c9777fe4fb13e1ecfe5b5d644e2c45d0514f95884dbed49a03fb9b67304c
2022-01-02 12:01:03 +00:00
drh
2dfe9664a9 Earlier detection of corruption in sqlite3BtreeDelete(). Fix for
the assertion fault reported by
[forum:/forumpost/9d78389221|forum post 9d78389221].

FossilOrigin-Name: 13e9ff9e84a114374b49986484dbee05953a496f3017dd5089fba6f495a17c40
2022-01-02 11:25:51 +00:00
drh
24a82eadb3 Do not raise an SQLITE_SCHEMA error if in sqlite3Init(). Fix for PoC #2 in
[forum:/forumpost/b03d86f951|forum post b03d86f951].  See TH3 for test
cases.

FossilOrigin-Name: e199a851e316bd471bfc54204b8c250d3ae93b829261214158a2c74acad4093e
2022-01-01 22:55:31 +00:00
dan
4ce289d088 Fix an assert() in pager.c to avoid the possibility of side-effects.
FossilOrigin-Name: 1d1fe03c752267f03f015ada975876f65e2a7b967e19f057b5c73f95d7df8a9c
2022-01-01 20:02:58 +00:00
drh
a6ca90c38c Attempt to fix a harmless compiler warning in FTS5.
FossilOrigin-Name: 8e619c21e2326be1538b60908e7cd211558ec840835c6eb69e768eb190e1fd0b
2022-01-01 19:55:29 +00:00
dan
0f42f71da2 Fix an obscure problem with releasing savepoints stored in an in-memory journal that could cause subsequent savepoint rollback to fail.
FossilOrigin-Name: 73c2b50211d3ae26aeb89976ec7b9fcd7de9f152b283ec7d0809ad18bddc603e
2022-01-01 19:29:50 +00:00
drh
3ea82384ea Remove an obsolete assert() statement that no longer does anything useful
and which is not always true.  Fix for PoC #1 of
[forum:/forumpost/b03d86f951|forum post b03d86f951].

FossilOrigin-Name: c76a4c0b3cb625017ba09c8bccfcf1b5826df6873f1d3705d3345716079d5ec9
2022-01-01 17:21:55 +00:00
drh
3907560848 Fix a faulty assert() statement - adding a CORRUPT_DB term - based on a test
case derived from [562805cf488a455c].  Also add a test case to that prior
issue.

FossilOrigin-Name: 0dd6b5fccd554ebe4c0b081601863acd7b6ea81b51e14b508b23244f2a570e7e
2022-01-01 12:26:01 +00:00
drh
017e363787 Mark the REGEXP operator in the built-in extension as deterministic.
FossilOrigin-Name: e654b57a9fc32021453eed48d1c1bba65c833fb1aac3946567968c877e4cbd10
2021-12-31 22:53:15 +00:00
drh
54bc63815a Simplify the sqlite3RunParser() routine by omitting the third parameter.
Results in a binary that is about 100 bytes smaller and 1.4M cycles faster.

FossilOrigin-Name: 6fb2a1bb0280d6e31291e3fd06bbcbbb28ef5fb27d3898e2327a50ac738ae1f3
2021-12-31 19:20:42 +00:00
mistachkin
c158c07a22 Fix harmless compiler warnings in the shell.
FossilOrigin-Name: f3ea36d79b6aa95470bf13e8d4ed5250a6b19bc16032b29e4dcdfc49b47a1edf
2021-12-31 19:08:20 +00:00
mistachkin
2b5fbb2836 Fix harmless compiler warnings seen with MSVC.
FossilOrigin-Name: a9bfb621091b6d92d1caeb69134d3809d9e0b43fe764608c5995db277ac785be
2021-12-31 18:26:50 +00:00
drh
16118265ca Performance optimization and size reduction in sqlite3RunParser().
FossilOrigin-Name: 41ee2bac5731d8434322e92abba580f7c759a137e576dd286fe01ab23fc440ea
2021-12-31 17:54:48 +00:00
drh
b296ab6f6a Move the pTriggerPrg and pCleanup elements of the Parse object up into the
section of that object that is persisted across calls to sqlite3NestedParse().
This fixes a memory leak
[forum:/info/24bd1fef7e9323ef|reported in forum post 24bd1fef7e9323ef].

FossilOrigin-Name: 562805cf488a455cdc57adcb110fef9b5416d813d5eaeabacd28bccb76d7f39d
2021-12-31 16:37:46 +00:00
drh
9aff824090 Remove unnecessary conditionals around the ORDER BY resolver calls in
multiSelectOrderBy().

FossilOrigin-Name: f2887e018be71bc406526935c7e99e42f12fc5d1d1c65a89dc2b9bfbca01d43d
2021-12-30 17:46:15 +00:00
drh
e1961c55c3 When constructing the sqlite3_index_info object for the xBestIndex method
of a virtual table, omit constant trims from the ORDER BY clause, as they
will always be in the correct order.

FossilOrigin-Name: 524c2b87d74c8cad6fb377aed7275788d61beafe61e675480de732519987102c
2021-12-30 17:36:54 +00:00
drh
66306d86ab When a table has an INTEGER PRIMARY KEY ON CONFLICT REPLACE and some other
uniqueness constraint, and it participates in an upsert on that other
constraint, ensure that code that checks for conflicts on the INTEGER PRIMARY
KEY is well-formed.  Fix for the problem reported by
[forum:/forumpost/06b16b8b29f8c8c3|forum post 06b16b8b29f8c8c3].

FossilOrigin-Name: 2f09b51b1ff37bf98f958564cc1224968caa7e33147e6666b5c1ba20b2a7813b
2021-12-30 02:38:43 +00:00
drh
38cebe07bb When implementing a multi-way compound SELECT using merge, try to balance
the merge tree.

FossilOrigin-Name: bb8522fe0dc54282ec13672eba9b44ee08f9cb55c1663f1699a61bf96ec1fd04
2021-12-30 00:37:11 +00:00
drh
092ba22cca Minor changes to shell1.test test results to account for the new feature
of the shell that points to the specific part of the input line where the
error occurs.

FossilOrigin-Name: d4870c08893ea9984b1fa1c3a7d04893ad5ed4a2130e9287d169a306cc8ef0a4
2021-12-29 13:32:36 +00:00
drh
41584df573 Ensure that the affinity of columns is honored in the RETURNING clause.
See [forum:/forumpost/e0c7574ab2|forum post e0c7574ab2] for the bug report.

FossilOrigin-Name: 4711fb69547f4f17653ab116030c32fdcc2c836410349d1d025866ffc15704da
2021-12-29 04:31:54 +00:00
drh
9ebe43c120 Add the sqlite3_error_offset() interface. Use it to enhance error reporting
in the CLI.

FossilOrigin-Name: 416602a85101c2cd1705eb5306a8933e54cb05ae1562400395ec2769173dec01
2021-12-29 04:13:37 +00:00
drh
44c44cd7c5 Make .read's help tell of piped input
FossilOrigin-Name: 155c3e9c7ccd6fd644cc64b027cf460112c491e5f9202dd76cefe2000936ad80
2021-12-29 04:10:49 +00:00
drh
412a59f56e Change an assert() in FTS3 into assert_fts3_nc(), since it is a harmless
condition that can occur when processing a corrupt database file.

FossilOrigin-Name: e773d6219bded9a5dfa9930882682dadaa7f1c6be344dbde904c9477a89f2d2c
2021-12-29 04:10:03 +00:00
drh
9169d0cb0f Fix the build-breaker bug in test1.c introduced by check-in [7fa20ca4c09ab024].
FossilOrigin-Name: 5f804da1820c98e7ff5c377e57e30b5154844b92ce622ed2ff888fe2c887e1ca
2021-12-29 04:08:11 +00:00
larrybr
a2ba25b508 Make .read's help tell of piped input
FossilOrigin-Name: e4ddcd8aa582c1130c34e9f05cd3e5f96ebf03c97a36c09ca442e3612fee4a20
2021-12-28 05:08:38 +00:00
drh
d66d5c2d35 Change an assert() in FTS3 into assert_fts3_nc(), since it is a harmless
condition that can occur when processing a corrupt database file.

FossilOrigin-Name: c03205aee9015fd886b8db02c8190899cee699255ca370f939e547deaf5ba9e8
2021-12-25 23:59:54 +00:00
drh
a98c868a10 Add the sqlite3_error_offset() interface. Use it to enhance error reporting
in the CLI.

FossilOrigin-Name: 7fa20ca4c09ab0249de0363691541fa836120ec277e72feb0e1516b9bfbdd97a
2021-12-25 00:26:51 +00:00