MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / dispatch_sql

Function dispatch_sql

nodedb/src/control/sql_dispatch/dispatch.rs:25–40  ·  view source on GitHub ↗

Attempt to dispatch `sql` as a NodeDB SQL extension. Returns `Some(result)` if the statement was handled (e.g. `PUBLISH TO`), or `None` if the SQL should be handled by the caller via `plan_sql`. The caller is responsible for handling `None`.

(
    state: &SharedState,
    identity: &AuthenticatedIdentity,
    sql: &str,
)

Source from the content-addressed store, hash-verified

23///
24/// The caller is responsible for handling `None`.
25pub async fn dispatch_sql(
26 state: &SharedState,
27 identity: &AuthenticatedIdentity,
28 sql: &str,
29) -> Option<crate::Result<DispatchOutcome>> {
30 let trimmed = sql.trim().trim_end_matches(';').trim();
31 let upper = trimmed.to_uppercase();
32
33 // ── PUBLISH TO <topic> <payload> ─────────────────────────────────────────
34 if upper.starts_with("PUBLISH TO ") {
35 return Some(handle_publish(state, identity, trimmed).await);
36 }
37
38 // Not a handled NodeDB extension — caller should use plan_sql.
39 None
40}
41
42/// Handle `PUBLISH TO <topic> <payload>` without pgwire coupling.
43async fn handle_publish(

Callers 1

execute_sqlMethod · 0.50

Calls 1

handle_publishFunction · 0.70

Tested by

no test coverage detected