Skip to content

Conversation

@ShahanaFarooqui
Copy link
Collaborator

@ShahanaFarooqui ShahanaFarooqui commented Aug 12, 2025

Changelog-Added: Plugins: sql also supports functions json_object(key1, value1, ...) to construct JSON objects and json_group_array(value) to aggregate rows into 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.

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add to sql plugin docs: it lists the functions.

Also start Changelog line to start with Plugins: sql

@rustyrussell rustyrussell modified the milestones: v25.12, v25.09 Aug 13, 2025
@ShahanaFarooqui ShahanaFarooqui force-pushed the plugin-sql-add-json-func branch from 0f618ac to fcd7d0e Compare August 13, 2025 04:17
Changelog-Added: Plugins: `sql` also supports functions `json_object(key1, value1, ...)` to construct JSON objects and `json_group_array(value)` to aggregate rows into 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.
@ShahanaFarooqui ShahanaFarooqui force-pushed the plugin-sql-add-json-func branch from fcd7d0e to 1a57d6f Compare August 13, 2025 04:18
@rustyrussell rustyrussell enabled auto-merge (rebase) August 13, 2025 04:38
@rustyrussell rustyrussell merged commit 2e58ed6 into ElementsProject:master Aug 13, 2025
76 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants