ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
join_alias_ctx Struct Reference

Rewrite a single SELECT query to carry provenance. More...

Public Attributes

List * rtable
 range table owning the joinaliasvars
Bitmapset * flattened
 rtindexes of the RTE_JOIN entries being dissolved
int sublevels_up
 current query nesting depth
bool wholerow
 a whole-row Var references a dissolved join

Detailed Description

Rewrite a single SELECT query to carry provenance.

This is the recursive entry point for the provenance rewriter. It is called from provsql_planner for top-level queries and re-entered from get_provenance_attributes for subqueries in FROM.

High-level steps:

  1. Strip any provsql column propagated into this query's target list.
  2. Detect and rewrite structural forms requiring pre-processing: non-ALL set operations (wrap in outer GROUP BY), AGG DISTINCT (push into a subquery), DISTINCT (convert to GROUP BY).
  3. Collect provenance attributes via get_provenance_attributes.
  4. Build a column-numbering map for where-provenance (build_column_map).
  5. Handle aggregates, migrate WHERE-on-aggregate to HAVING, and set ops.
  6. Build and splice the combined provenance expression.
Parameters
constantsExtension OID cache.
qQuery to rewrite (modified in place).
removedOut-param: boolean array indicating which original target list entries were provenance columns and were removed. May be NULL if the caller does not need this info.
wrap_rootIf true, mark this query's provenance expression as a safe-query root that must be wrapped in provsql.assume_boolean before splicing.
top_levelTrue for the outermost query the user evaluates; gates the inversion-free analysis (run only at the top).
in_boolean_rewriteTrue once a safe-query (boolean) rewrite has fired above; propagated through every recursion (including into subqueries, where wrap_root is otherwise lost) so the joint-width recogniser defers to the safe rewrite everywhere in its subtree.
inv_ctxInversion-free marker context supplied by a parent that flattened this query as a subquery, or NULL; when set, this query applies the supplied per-input markers instead of running its own analysis or read-once rewrite.
Returns
The (possibly restructured) rewritten query, or NULL if the query has no FROM clause and can be skipped.

Context for the join-alias walker/mutator of normalize_inner_joins.

Definition at line 13700 of file provsql.c.

Member Data Documentation

◆ flattened

Bitmapset* join_alias_ctx::flattened

rtindexes of the RTE_JOIN entries being dissolved

Definition at line 13702 of file provsql.c.

◆ rtable

List* join_alias_ctx::rtable

range table owning the joinaliasvars

Definition at line 13701 of file provsql.c.

◆ sublevels_up

int join_alias_ctx::sublevels_up

current query nesting depth

Definition at line 13703 of file provsql.c.

◆ wholerow

bool join_alias_ctx::wholerow

a whole-row Var references a dissolved join

Definition at line 13704 of file provsql.c.


The documentation for this struct was generated from the following file:
  • /home/pierre/git/software/provsql/src/provsql.c