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

Function plan_sql

nodedb-sql/src/lib.rs:74–90  ·  view source on GitHub ↗

Plan one or more SQL statements against the given catalog. Handles NodeDB-specific syntax (UPSERT, `{ }` object literals) via pre-processing before handing to sqlparser.

(sql: &str, catalog: &dyn SqlCatalog)

Source from the content-addressed store, hash-verified

72/// Handles NodeDB-specific syntax (UPSERT, `{ }` object literals) via
73/// pre-processing before handing to sqlparser.
74pub fn plan_sql(sql: &str, catalog: &dyn SqlCatalog) -> Result<Vec<SqlPlan>> {
75 // Array DDL/DML uses non-standard syntax that sqlparser-rs cannot
76 // accept. Intercept it before the standard preprocess pipeline.
77 if let Some(stmt) = try_parse_array_statement(sql)? {
78 return plan_array_statement(stmt, catalog);
79 }
80 let preprocessed = preprocess::preprocess(sql)?;
81 let effective_sql = preprocessed.as_ref().map_or(sql, |p| p.sql.as_str());
82 let is_upsert = preprocessed.as_ref().is_some_and(|p| p.is_upsert);
83 let temporal = preprocessed
84 .as_ref()
85 .map(|p| p.temporal)
86 .unwrap_or_default();
87
88 let statements = parse_sql(effective_sql)?;
89 plan_statements(&statements, is_upsert, temporal, catalog)
90}
91
92/// Plan SQL with bound parameters (prepared statement execution).
93///

Callers

nothing calls this directly

Calls 7

plan_array_statementFunction · 0.85
preprocessFunction · 0.85
plan_statementsFunction · 0.85
parse_sqlFunction · 0.50
as_refMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected