pub struct PostgresIntrospector { /* private fields */ }Expand description
The PostgreSQL backend, behind the same feature that gates it in fraiseql-db.
PostgresAdapter belongs here, not in the unconditional list above. The
blanket pub use fraiseql_db as db; carried each item’s own #[cfg] for
free; enumerating the names drops that, so every line above is an assertion
that the item is ungated in fraiseql-db — and nothing but a feature-OFF
build checks it. make lint-feature-matrix is that build.
PostgreSQL introspector for fact table metadata.
Implementations§
Source§impl PostgresIntrospector
impl PostgresIntrospector
Sourcepub const fn new(pool: Pool<Manager>) -> PostgresIntrospector
pub const fn new(pool: Pool<Manager>) -> PostgresIntrospector
Create new PostgreSQL introspector from connection pool.
Source§impl PostgresIntrospector
impl PostgresIntrospector
Sourcepub async fn get_index_definitions(
&self,
relation: &str,
) -> Result<Vec<IndexInfo>, FraiseQLError>
pub async fn get_index_definitions( &self, relation: &str, ) -> Result<Vec<IndexInfo>, FraiseQLError>
Every index on relation, keys in declared order (#1307).
Keys come from pg_get_indexdef(indexrelid, n, true) rather than from
pg_attribute, because an expression key has no attnum: the JSONB
identity a page is tie-broken on (data->>'id') is indexed as an
expression, and reading indkey alone would report that index as having
fewer keys than it has.
Returns an empty vector for a view — a view carries no indexes, so a
caller holding a sql_source must resolve it with
resolve_base_relations first.
§Errors
Returns FraiseQLError::Database if the catalog query fails.
Sourcepub async fn resolve_base_relations(
&self,
view: &str,
) -> Result<Vec<String>, FraiseQLError>
pub async fn resolve_base_relations( &self, view: &str, ) -> Result<Vec<String>, FraiseQLError>
The tables and materialized views a view reads from (#1307).
A query binds to v_invoice, and v_invoice has no indexes — the indexes
that decide whether a page needs a sort live on tb_invoice. Resolved
through pg_rewrite/pg_depend rather than by assuming a v_/tb_
naming convention, which is a project convention and not a guarantee about
any particular database.
Returns every base relation the view depends on. More than one means the view is a join, and a caller cannot attribute an ordering to a single table without reading the view body.
§Errors
Returns FraiseQLError::Database if the catalog query fails.
Sourcepub async fn get_view_columns(
&self,
view_name: &str,
) -> Result<Vec<String>, FraiseQLError>
pub async fn get_view_columns( &self, view_name: &str, ) -> Result<Vec<String>, FraiseQLError>
Trait Implementations§
Source§impl DatabaseIntrospector for PostgresIntrospector
impl DatabaseIntrospector for PostgresIntrospector
Source§async fn list_fact_tables(&self) -> Result<Vec<String>, FraiseQLError>
async fn list_fact_tables(&self) -> Result<Vec<String>, FraiseQLError>
Source§async fn get_columns(
&self,
table_name: &str,
) -> Result<Vec<(String, String, bool)>, FraiseQLError>
async fn get_columns( &self, table_name: &str, ) -> Result<Vec<(String, String, bool)>, FraiseQLError>
Source§async fn get_indexed_columns(
&self,
table_name: &str,
) -> Result<Vec<String>, FraiseQLError>
async fn get_indexed_columns( &self, table_name: &str, ) -> Result<Vec<String>, FraiseQLError>
Source§fn database_type(&self) -> DatabaseType
fn database_type(&self) -> DatabaseType
Source§async fn list_relations(&self) -> Result<Vec<RelationInfo>, FraiseQLError>
async fn list_relations(&self) -> Result<Vec<RelationInfo>, FraiseQLError>
Source§async fn get_sample_jsonb(
&self,
table_name: &str,
column_name: &str,
) -> Result<Option<Value>, FraiseQLError>
async fn get_sample_jsonb( &self, table_name: &str, column_name: &str, ) -> Result<Option<Value>, FraiseQLError>
Source§async fn get_sample_json_rows(
&self,
table_name: &str,
column_name: &str,
limit: usize,
) -> Result<Vec<Value>, FraiseQLError>
async fn get_sample_json_rows( &self, table_name: &str, column_name: &str, limit: usize, ) -> Result<Vec<Value>, FraiseQLError>
Source§async fn function_exists(
&self,
schema: Option<&str>,
name: &str,
) -> Result<Option<bool>, FraiseQLError>
async fn function_exists( &self, schema: Option<&str>, name: &str, ) -> Result<Option<bool>, FraiseQLError>
name exists — in schema
when given, else resolved against the connection search_path. Read moreSource§async fn qualified_relation_exists(
&self,
schema: &str,
name: &str,
) -> Result<Option<bool>, FraiseQLError>
async fn qualified_relation_exists( &self, schema: &str, name: &str, ) -> Result<Option<bool>, FraiseQLError>
sql_source (quote_postgres_identifier + to_regclass), so a mixed-case
relation in an off-search_path schema is not falsely reported missing. Read moreSource§async fn get_view_definition(
&self,
relation: &str,
) -> Result<Option<String>, FraiseQLError>
async fn get_view_definition( &self, relation: &str, ) -> Result<Option<String>, FraiseQLError>
relation, when it is a view (#1303). Read more