fn bind_system_catalog_query(
sql: &str,
resolve: impl Fn(&str, &str) -> Option<String>,
) -> Result<String, McpRequestError>Expand description
Rewrites each object name in the query to its system catalog ID, as
[<id> AS <name>], and rejects the query if one is not a system object,
if a schema name is not a system schema, or if a SELECT reads no relation.
This covers the names SHOW and EXPLAIN take, not only the relations a
query reads. Function, type and cluster names stay as written.
Names match by exact spelling, in the system schemas (SYSTEM_SCHEMAS
without mz_unsafe). An unqualified name binds through
SYSTEM_CATALOG_SEARCH_PATH, except one matching a CTE, which stays
unbound.
sql must hold exactly one statement, which validate_readonly_query
checks. resolve(schema, item) returns the ID of the system object item
in schema.