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

Function evaluate

nodedb/src/control/server/pgwire/pg_catalog/dispatch.rs:53–89  ·  view source on GitHub ↗
(
    state: &SharedState,
    identity: &AuthenticatedIdentity,
    sql: &str,
    table: &'static str,
    params: &[nodedb_sql::ParamValue],
)

Source from the content-addressed store, hash-verified

51}
52
53async fn evaluate(
54 state: &SharedState,
55 identity: &AuthenticatedIdentity,
56 sql: &str,
57 table: &'static str,
58 params: &[nodedb_sql::ParamValue],
59) -> PgWireResult<Vec<Response>> {
60 let materialized: VTable = match table {
61 "pg_database" => tables::pg_database()?,
62 "pg_namespace" => tables::pg_namespace()?,
63 "pg_type" => tables::pg_type()?,
64 "pg_class" => tables::pg_class(state, identity)?,
65 "pg_attribute" => tables::pg_attribute(state, identity)?,
66 "pg_index" => tables::pg_index(state, identity)?,
67 "pg_authid" => tables::pg_authid(state, identity)?,
68 "_system.audit_log" => audit_log(state, identity)?,
69 "_system.dropped_collections" => dropped_collections(state, identity).await?,
70 "_system.l2_cleanup_queue" => l2_cleanup_queue(state, identity)?,
71 _ => unreachable!("extract_pg_catalog_table returned an unknown name"),
72 };
73
74 let select = vquery::select::parse_select_with_params(sql, params).map_err(|e| {
75 PgWireError::UserError(Box::new(ErrorInfo::new(
76 "ERROR".to_owned(),
77 "0A000".to_owned(), // feature_not_supported
78 format!("virtual table query: {e}"),
79 )))
80 })?;
81 let result = vquery::execute(&select, materialized).map_err(|e| {
82 PgWireError::UserError(Box::new(ErrorInfo::new(
83 "ERROR".to_owned(),
84 "0A000".to_owned(),
85 format!("virtual table query: {e}"),
86 )))
87 })?;
88 vquery::encode::encode(result)
89}
90
91/// Schema reported for `table` at Parse/Describe time when the projected
92/// column set cannot be computed from the SQL. Returns the *full* table

Callers 1

Calls 13

pg_databaseFunction · 0.85
pg_namespaceFunction · 0.85
pg_typeFunction · 0.85
pg_classFunction · 0.85
pg_attributeFunction · 0.85
pg_indexFunction · 0.85
pg_authidFunction · 0.85
audit_logFunction · 0.85
dropped_collectionsFunction · 0.85
l2_cleanup_queueFunction · 0.85
parse_select_with_paramsFunction · 0.85
executeFunction · 0.50

Tested by

no test coverage detected