Commit Graph

50 Commits

Author SHA1 Message Date
drh
7394a6ef57 Simplification of the new JSON insert/set test cases.
FossilOrigin-Name: 04c0d5644372446c924a2e31a26edf51ddc563a1990d170b0ed4739e3e8b239b
2023-11-30 16:17:09 +00:00
drh
ad27c437ff New test cases for insert/set/replace with paths that indicate substructure
that does not yet exist.

FossilOrigin-Name: 146c717c51940b2139befc45ac74e7a1c36ef3c32fd3cfe35b334488eebe6298
2023-11-30 12:04:14 +00:00
drh
1cab41e290 Attempt to get json_extract() working with pure JSONB only, and without
the use of JsonNode.  Mostly working, but there are some differences from
legacy in corner cases.

FossilOrigin-Name: 8c324af1eca27e86adc45622af4f3b06a67a3f968596ac58aa7434b1f6f05f3c
2023-11-28 20:25:23 +00:00
drh
821a4c9f8c Give the json_valid() function an optional second argument that determines
what is meant by "valid".

FossilOrigin-Name: a4e19ad43dac81e7655ec03ff69bb99d1d02b0c227034c90fb41415fd4793fe3
2023-11-27 15:57:11 +00:00
drh
b4e5bc6cdb All tests passing.
FossilOrigin-Name: b5a5660ca22437640c9bf32c44d92c76a7293dafcbaf4fa6a4c171128d64871d
2023-11-27 12:30:55 +00:00
drh
f5e487d168 Merge recent trunk enhancements into the jsonb branch.
FossilOrigin-Name: f47a8d0a207a8442a7f621b070ce9dd1d6013ce26bcf68165d20bb379bd478a0
2023-10-19 20:46:22 +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
ac4aea5102 Fix the use of an uninitialized value that occurs when doing a json_insert()
of a string value that contains embedded U+0000 characters.

FossilOrigin-Name: d3c0cbb90966316be9cd25e3edb501da42731e8a83c13227b90ce17d3975a2c3
2023-10-11 17:24:31 +00:00
drh
7d1c9da62d Fix the use of an uninitialized value that occurs when doing a json_insert()
of a string value that contains embedded U+0000 characters.

FossilOrigin-Name: fc5ee9e51ad4556af526a6cefca5ae5a3b1b7affc4edf09832491d6b4f4ba366
2023-10-11 17:21:16 +00:00
drh
0dead8d3d1 Merge the latest trunk fixes and enhancements into the jsonb branch, and
especially the JSON cache spill UAF fix.

FossilOrigin-Name: 9422c24f4a8b290dcae61e50ec81be5b314b22c61a2bca1e194e47da1316b6e6
2023-10-09 12:57:03 +00:00
drh
faef28e6bd Fix a potential UAF caused by JSON parser cache spill.
[forum:/forumpost/b25edc1d46|Forum post b25edc1d46].

FossilOrigin-Name: a163fecca90cab9d1b7bf8ebac78d498775eed7b6d81e7920e3401633c3a4b60
2023-10-09 12:46:53 +00:00
drh
dee29e8c7a New test cases for JSONB.
FossilOrigin-Name: d624c31e5c49e1ce63b4b72caa42a61c5167866f47d842fbcfe4e826fd079d7c
2023-10-02 14:51:28 +00:00
drh
c97407fdba Allow json_replace() to accept JSONB arguments as the new value.
FossilOrigin-Name: 95eb7b37fab29931924311f541d52173ef77a448efc8771b1a1783ccd786d23d
2023-10-02 13:35:06 +00:00
drh
8eeafb7544 Improvements to error handling for BLOB inputs on JSON.
FossilOrigin-Name: 14f20ecbfab44934e86f1ac7a3f745b989aa8190c6df119ff5aa8100fa248d93
2023-10-02 13:20:43 +00:00
drh
5624b0b4cd Gather forward references into a single place for the JSON code. Allow
JSONB arguments to json_array() and json_object() and similar.

FossilOrigin-Name: c352201b8c299c330d9abbff6dbcbcbcf00ada53183d3cd91020ec772e066357
2023-10-02 12:40:04 +00:00
dan
58c44132d1 Have all test names in json101.test start with "json101".
FossilOrigin-Name: af56d7b6b9c50f2541a51fcb7d94b89aafba4f343a9103b21a15aad3f283c63e
2023-08-17 15:14:43 +00:00
drh
b8a0fc52a2 Fix bug in the test case for the previous check-in.
FossilOrigin-Name: c5daae88612607aa7a8b13b021cf586fc66e8bcd1fa9d948a860c881b7247761
2023-08-11 11:24:44 +00:00
drh
91c0092917 Up until version 3.42.0, there was a bug in json_valid() such that it would
return False (0) for a NULL input.  That bug is fixed in 3.42.0.  This
check-in adds a compile-time option -DSQLITE_LEGACY_JSON_VALID that restores
the old buggy behavior for applications that depend on it.

FossilOrigin-Name: 15c2eadbff8e732cca45d6c3771d1fcea5aab2127e87f2a611b41ccfef4d1a0d
2023-08-11 11:12:46 +00:00
dan
ed96436f23 Reduce the maximum depth of nesting in json objects to 1000.
FossilOrigin-Name: c7697a0d45bfab20ec09f17ad65e375ddb43af6762278481c13a65c9a784978e
2023-05-05 15:52:44 +00:00
drh
8c79ea8447 Improved handling of NULL arguments to json_valid() and
json_error_position(). [forum:/forumpost/06c6334412|Forum post 06c6334412].

FossilOrigin-Name: ab78e6946ba8125a83ff155561adf9c8df4d1c09a645fce08c8245ddb08bfa3b
2023-05-02 11:12:01 +00:00
drh
7be1473ccb Omit the json_valid() function. Change the name of json_error() to
json_error_position().  Use "NOT json_error_position(X)" as a substitute
for "json_valid5(X)".

FossilOrigin-Name: 34c4e900a9cc51630eeaf01deef74bf5b18d66e0ab1dc61a2023ac8f837a5197
2023-04-30 19:34:41 +00:00
drh
f62518f65d Work toward implementing JSON5 whitespace. Untested and incomplete.
FossilOrigin-Name: d262c059455ebe0650a45a6c1c04d1baf9609c635df352732dd192426e1bdc39
2023-04-26 15:19:19 +00:00
drh
be5bada4d0 Allow trailing commas in objects and arrays of JSON.
FossilOrigin-Name: 4031b231c223db598b45dbd192b027a99a9b82a981d43c75f723a3fb06720b82
2023-04-24 23:14:34 +00:00
drh
667b5cc985 Fix json rendering so that it shows positive and negative infinity as
9.0e+999 and -9.0e+999 respectively.

FossilOrigin-Name: efce4690a52592c4f5fc7d023eebe771b0e615bb03c0fe203493f853b28e8f85
2023-03-17 20:31:24 +00:00
drh
4d28830861 Any function call can abort. Take this into account when deciding if a DML
statement needs a statement journal.  See
[forum:/forumpost/9b9e4716c0d7bbd1|forum thread 9b9e4716c0d7bbd1] for more
information.

FossilOrigin-Name: 5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe
2022-08-30 00:11:51 +00:00
drh
b07fb4f1c2 Fix the JSON Path parser so that it will accept zero-length object labels.
[forum/forumpost/c082aeab43|Forum thread c082aeab43].

FossilOrigin-Name: 84fe95d2a5b4d232d657e3b8110027a698a9bcd597f205cc535cfa97bc299f21
2022-04-04 14:24:14 +00:00
drh
ddd166a350 Remove a faulty NEVER(). Fix for dbsqlfuzz 4678cf825d27f87c9b8343720121e12cf944b71a
FossilOrigin-Name: d4e402458dd4cadb623a30158eb9ff5f24f011240b3b1bc5b1d6ae3c5b855892
2022-01-30 11:42:56 +00:00
drh
48eb03bd0e Proper surrogate pair decoding added to JSON functions. See the mailing list
bug report and [https://bugs.python.org/issue38749].  More test cases
needed here, but it seems to work so far.

FossilOrigin-Name: 51027f08c0478f1bf9d7545d9e268c772c0a5cd5dda4b03d78f16c7d94f2f50d
2019-11-10 11:09:06 +00:00
drh
4a5cff73a7 Fix a parser bug in the use of parentheses around table-valued functions.
FossilOrigin-Name: 58a51123d1a6381cc67d3c64ba3468ec5a92c299ad6fd86de0b843d0ffafb846
2018-12-03 01:47:41 +00:00
drh
dd7460f0fd Correct output for the fullkey column of json_each() when the total JSON
input is a simple value, not an array or object.

FossilOrigin-Name: b45b18850c59f22a163ee482f529f578a8798f96d0e26b5a061d336d480a1540
2018-05-16 12:19:11 +00:00
drh
33f763d154 Fix the query planner so that it takes into account dependencies in the
arguments to table-valued functions in subexpressions in the WHERE clause.
Fix for ticket [80177f0c226ff54f6dd].

FossilOrigin-Name: 7daa687340e475972d6849f84fe1419a1f5700934f53fd80656849adc73d6d04
2018-01-26 22:41:59 +00:00
drh
6e61c5f895 Additional test case demonstrating the ability to access structure elements
using quoted names in the JSON1 extension.

FossilOrigin-Name: 8d3cc928a8f0c7b2616c5c75af9d3a50bd4f0fe8e4ccab545ab8648cbfbb4b7f
2017-10-27 12:27:25 +00:00
drh
8671538cad Fix a regression caused by the fix for ticket [6c9b5514077fed34551f98e64c09a1] -
control characters allowed in JSON.

FossilOrigin-Name: 8e7b611863247a3bf46a96ec4b47d24c0ae0d60c9cee968a1cfd1da157e7c9bb
2017-04-13 00:12:32 +00:00
drh
ff6d50e973 Limit the depth of recursion for valid JSON in the JSON1 extension in order
to avoid using excess stack space in the recursive descent parser.
Fix for ticket [981329adeef51011052667a9].

FossilOrigin-Name: 1f68c184596912d742b50b1ca38252a9e783aacf121619a27b17a7ae9f6df041
2017-04-11 18:55:05 +00:00
drh
ad875e7416 Fix the JSON1 extension so that the JSON validator correctly rejects malformed
backslash escapes within string literals.

FossilOrigin-Name: 7a63539169a384960e30a63e0c8e9b0f07fa431e
2016-11-07 13:37:28 +00:00
drh
2ad96f5880 Add the json_quote() function to the JSON1 extension.
FossilOrigin-Name: 2c3714aebf5e40e3728877a235b3c1f93defa33e
2016-06-17 13:01:51 +00:00
drh
3b7f9a68d5 Escape control characters in JSON.
Fix for ticket [ad2559db380abf8].

FossilOrigin-Name: 4f1b5229a3bbc9d40b7433a5eb3139d59d31dcb1
2016-02-04 10:28:57 +00:00
drh
b9e8f59b63 Form-feed is not valid whitespace for json.
Fix for ticket [57eec374ae1d0a1d]

FossilOrigin-Name: 28957d635961c525f735a52b8ffe3e69ccf31382
2015-10-16 15:16:06 +00:00
drh
c306e08ad5 Json1 tests are working. Builds without FTS5 enabled. Still some problems
building with FTS5.

FossilOrigin-Name: 2928f8e87d2e5d121e6e7e5993cbb773bb2b0603
2015-10-08 23:37:00 +00:00
drh
b7601461e0 Fix a JSON1 test case so that it works on builds that omit virtual tables.
FossilOrigin-Name: a4444c0f662058bdd5267e616c31cef828bc1fc5
2015-09-24 11:06:26 +00:00
drh
f27cd1f3aa Do not allow a comma at the end of a JSON array or object.
FossilOrigin-Name: 7c7a3f3e9bc2f7a7334d8d6eae183d83f22097be
2015-09-23 01:10:29 +00:00
drh
8cb0c83cce Fix json_set() so that it can overwrite a value that was previously overwritten
during the same call.

FossilOrigin-Name: 0f16041647993975c316203c7e11f06e27640136
2015-09-22 00:21:03 +00:00
drh
dc38495715 Fix a memory leak in json1.c that could occur after misuse of json_object().
FossilOrigin-Name: 394b81b11f261a9b179a034bc2a2d2dff0765e3b
2015-09-19 18:54:39 +00:00
drh
f5ddb9c214 Take out the goofy '$$' path syntax. Instead, use subtypes to communicate when
a string is JSON.  Add the json() function that validates and minifies the
JSON and sets the appropriate subtype.

FossilOrigin-Name: 8a80d6459e246ec1b38325e1cbd1e862157138b3
2015-09-11 00:06:41 +00:00
drh
20b3b6109b New test cases for the json1 extension.
FossilOrigin-Name: daff4832af963f98bcc1d2c2f84bd815d384f850
2015-08-29 18:30:30 +00:00
drh
d1f0068d19 Do not consider an empty string to be valid JSON. Add some additional
JSON test cases.

FossilOrigin-Name: fd19ff029f128f478f69910352a6f8b84262ce1d
2015-08-29 16:02:37 +00:00
drh
f2df7e71d6 Back out the json_check() routine. Instead, throw an error if the input to
a json function (other than json_valid()) is not valid JSON.

FossilOrigin-Name: dc9ce7b18cbe23d065317757234ef9fb8792da7a
2015-08-28 20:07:40 +00:00
drh
f6ec8d4f4c Add the json_check() function, which returns its argument if the argument
is well-formed JSON or which throws an error otherwise.

FossilOrigin-Name: 64abb65d4df11e5b3bcc4afc8e7c18e907c6080a
2015-08-28 03:48:04 +00:00
drh
ecb5fedb3f Enhance the json_insert(), json_replace(), and json_set() functions with the
ability to add JSON instead of text if the argument is text and if the PATH
begins with '$$' instead of just '$'.

FossilOrigin-Name: 44f103d8862abc2d5613bac04dc2ea8e625b1f40
2015-08-28 03:33:50 +00:00
drh
6fd5c1e0e8 Fixes for compiler warnings and errors in the makefiles. Rename the
one test script to json101.test.

FossilOrigin-Name: 9ff6ccde5f26f18073587c320290570854ffc833
2015-08-21 20:37:12 +00:00