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

Method simple_query_raw

nodedb-client/src/remote/client/core.rs:120–159  ·  view source on GitHub ↗

Execute a parameterless statement via the simple-query protocol (single `Query` message — no `Parse`/`Bind`/`Describe` round-trip). Required for DDL statements that don't fit the extended-query row-description shape that `Client::query` expects. `simple_query` doesn't support bound parameters, so callers with non-empty params must continue to use `query_raw`. All values come back as strings from

(
        &self,
        sql: &str,
    )

Source from the content-addressed store, hash-verified

118 /// we wrap them as `Value::String` and let downstream consumers
119 /// coerce as needed.
120 pub(super) async fn simple_query_raw(
121 &self,
122 sql: &str,
123 ) -> NodeDbResult<(Vec<String>, Vec<Vec<Value>>)> {
124 use tokio_postgres::SimpleQueryMessage;
125
126 let client = self.client.lock().await;
127 let messages = client.simple_query(sql).await.map_err(|e| {
128 NodeDbError::storage(format!(
129 "pgwire simple_query failed: {}",
130 pg_error_detail(&e)
131 ))
132 })?;
133
134 let mut columns: Vec<String> = Vec::new();
135 let mut rows: Vec<Vec<Value>> = Vec::new();
136
137 for msg in messages {
138 match msg {
139 SimpleQueryMessage::RowDescription(fields) => {
140 columns = fields.iter().map(|f| f.name().to_string()).collect();
141 }
142 SimpleQueryMessage::Row(row) => {
143 let mut vals = Vec::with_capacity(row.len());
144 for i in 0..row.len() {
145 match row.get(i) {
146 Some(s) => vals.push(Value::String(s.to_string())),
147 None => vals.push(Value::Null),
148 }
149 }
150 rows.push(vals);
151 }
152 SimpleQueryMessage::CommandComplete(_) => {
153 // DDL / DML completion — no rows.
154 }
155 _ => {}
156 }
157 }
158 Ok((columns, rows))
159 }
160}
161
162#[cfg(test)]

Callers 8

graph_traverse_implMethod · 0.80
graph_stats_implMethod · 0.80
graph_pagerank_implMethod · 0.80
execute_sql_implMethod · 0.80
text_search_implMethod · 0.80

Calls 8

lockMethod · 0.80
collectMethod · 0.80
to_stringMethod · 0.80
iterMethod · 0.45
nameMethod · 0.45
lenMethod · 0.45
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected