Skip to content

Commit 19ea0d3

Browse files
plugin: Allow json_object and json_group_array functions in sql plugin
Changelog-Added: Added support for json_object(key1, value1, ...) to construct JSON objects and json_group_array(value) to aggregate rows into a JSON array. Security Considerations - No new SQL injection risks: Functions only process explicitly provided column values (no arbitrary string parsing). - Explicit column requirements: Wildcards (*) are not supported, all fields must be named (e.g., json_object('peer_id', id)). - Permission-bound data access: Functions adhere to the same table/row permissions as the underlying query. Performance Impact - Optimized native execution: Leverages SQLite’s built-in JSON1 extension (when available) for efficiency. - Moderate CPU overhead: Complex nesting may impact performance on large datasets but still faster than application-layer JSON conversion.
1 parent ebbe5a2 commit 19ea0d3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plugins/sql.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ static int sqlite_authorize(void *dbq_, int code,
352352
return SQLITE_OK;
353353
if (streq(b, "unixepoch"))
354354
return SQLITE_OK;
355+
if (streq(b, "json_object"))
356+
return SQLITE_OK;
357+
if (streq(b, "json_group_array"))
358+
return SQLITE_OK;
355359
}
356360

357361
/* See https://www.sqlite.org/c3ref/c_alter_table.html to decode these! */

0 commit comments

Comments
 (0)