(
state: &SharedState,
identity: &AuthenticatedIdentity,
sql: &str,
table: &'static str,
params: &[nodedb_sql::ParamValue],
)
| 51 | } |
| 52 | |
| 53 | async 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 |
no test coverage detected