aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2023-11-08 17:11:13 +0000
committerdrh <>2023-11-08 17:11:13 +0000
commita4cf38ca9b9f2217b163888b3d4811e316e538c4 (patch)
tree5dc2c2d6db757b2a613394268ef12e8b47049640 /src/json.c
parent7b5123c7963c0b956e298e9e355ee45fdbd4de02 (diff)
parentb494366370f5f9698e574150c5a4309d7c3dc78b (diff)
downloadsqlite-a4cf38ca9b9f2217b163888b3d4811e316e538c4.tar.gz
sqlite-a4cf38ca9b9f2217b163888b3d4811e316e538c4.zip
Merge recent trunk enhancements into the jsonb branch, and especially the
finer-grain characterization of JSON function properties. FossilOrigin-Name: 72393b003f9f8675e4a124dddd09607b5b34ddefe56716b283c68c0982fb3d96
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/json.c b/src/json.c
index e998af523..04349899c 100644
--- a/src/json.c
+++ b/src/json.c
@@ -5859,37 +5859,43 @@ static sqlite3_module jsonTreeModule = {
void sqlite3RegisterJsonFunctions(void){
#ifndef SQLITE_OMIT_JSON
static FuncDef aJsonFunc[] = {
- JFUNCTION(json, 1, 0, jsonRemoveFunc),
- JFUNCTION(jsonb, 1, JSON_BLOB, jsonbFunc),
- JFUNCTION(json_array, -1, 0, jsonArrayFunc),
- JFUNCTION(jsonb_array, -1, JSON_BLOB, jsonArrayFunc),
- JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc),
- JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc),
- JFUNCTION(json_error_position,1, 0, jsonErrorFunc),
- JFUNCTION(json_extract, -1, 0, jsonExtractFunc),
- JFUNCTION(jsonb_extract, -1, JSON_BLOB, jsonExtractFunc),
- JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc),
- JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc),
- JFUNCTION(json_insert, -1, 0, jsonSetFunc),
- JFUNCTION(jsonb_insert, -1, JSON_BLOB, jsonSetFunc),
- JFUNCTION(json_object, -1, 0, jsonObjectFunc),
- JFUNCTION(jsonb_object, -1, JSON_BLOB, jsonObjectFunc),
- JFUNCTION(json_patch, 2, 0, jsonPatchFunc),
- JFUNCTION(jsonb_patch, 2, JSON_BLOB, jsonPatchFunc),
- JFUNCTION(json_quote, 1, 0, jsonQuoteFunc),
- JFUNCTION(json_remove, -1, 0, jsonRemoveFunc),
- JFUNCTION(jsonb_remove, -1, JSON_BLOB, jsonRemoveFunc),
- JFUNCTION(json_replace, -1, 0, jsonReplaceFunc),
- JFUNCTION(jsonb_replace, -1, JSON_BLOB, jsonReplaceFunc),
- JFUNCTION(json_set, -1, JSON_ISSET, jsonSetFunc),
- JFUNCTION(jsonb_set, -1, JSON_ISSET|JSON_BLOB, jsonSetFunc),
- JFUNCTION(json_type, 1, 0, jsonTypeFunc),
- JFUNCTION(json_type, 2, 0, jsonTypeFunc),
- JFUNCTION(json_valid, 1, 0, jsonValidFunc),
+ /* Might return JSON text (subtype J) */
+ /* | */
+ /* Uses cache ------, | ,---- Returns JSONB */
+ /* | | | */
+ /* Number of arguments ---, | | | ,--- Flags */
+ /* | | | | | */
+ JFUNCTION(json, 1, 1, 1, 0, 0, jsonRemoveFunc),
+ JFUNCTION(jsonb, 1, 1, 0, 1, 0, jsonbFunc),
+ JFUNCTION(json_array, -1, 0, 1, 0, 0, jsonArrayFunc),
+ JFUNCTION(jsonb_array, -1, 0, 0, 1, 0, jsonArrayFunc),
+ JFUNCTION(json_array_length, 1, 1, 0, 0, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_array_length, 2, 1, 0, 0, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_error_position,1, 1, 0, 0, 0, jsonErrorFunc),
+ JFUNCTION(json_extract, -1, 1, 1, 0, 0, jsonExtractFunc),
+ JFUNCTION(jsonb_extract, -1, 1, 0, 1, 0, jsonExtractFunc),
+ JFUNCTION(->, 2, 1, 1, 0, JSON_JSON, jsonExtractFunc),
+ JFUNCTION(->>, 2, 1, 0, 0, JSON_SQL, jsonExtractFunc),
+ JFUNCTION(json_insert, -1, 1, 1, 0, 0, jsonSetFunc),
+ JFUNCTION(jsonb_insert, -1, 1, 0, 1, 0, jsonSetFunc),
+ JFUNCTION(json_object, -1, 0, 1, 0, 0, jsonObjectFunc),
+ JFUNCTION(jsonb_object, -1, 0, 0, 1, 0, jsonObjectFunc),
+ JFUNCTION(json_patch, 2, 1, 1, 0, 0, jsonPatchFunc),
+ JFUNCTION(jsonb_patch, 2, 1, 0, 1, 0, jsonPatchFunc),
+ JFUNCTION(json_quote, 1, 0, 1, 0, 0, jsonQuoteFunc),
+ JFUNCTION(json_remove, -1, 1, 1, 0, 0, jsonRemoveFunc),
+ JFUNCTION(jsonb_remove, -1, 1, 0, 1, 0, jsonRemoveFunc),
+ JFUNCTION(json_replace, -1, 1, 1, 0, 0, jsonReplaceFunc),
+ JFUNCTION(jsonb_replace, -1, 1, 0, 1, 0, jsonReplaceFunc),
+ JFUNCTION(json_set, -1, 1, 1, 0, JSON_ISSET, jsonSetFunc),
+ JFUNCTION(jsonb_set, -1, 1, 0, 1, JSON_ISSET, jsonSetFunc),
+ JFUNCTION(json_type, 1, 1, 0, 0, 0, jsonTypeFunc),
+ JFUNCTION(json_type, 2, 1, 0, 0, 0, jsonTypeFunc),
+ JFUNCTION(json_valid, 1, 1, 0, 0, 0, jsonValidFunc),
#if SQLITE_DEBUG
- JFUNCTION(json_parse, 1, 0, jsonParseFunc),
- JFUNCTION(json_test1, 1, 0, jsonTest1Func),
- JFUNCTION(jsonb_test2, 1, 0, jsonbTest2),
+ JFUNCTION(json_parse, 1, 1, 0, 0, 0, jsonParseFunc),
+ JFUNCTION(json_test1, 1, 1, 0, 0, 0, jsonTest1Func),
+ JFUNCTION(jsonb_test2, 1, 1, 0, 1, 0, jsonbTest2),
#endif
WAGGREGATE(json_group_array, 1, 0, 0,
jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,