Skip to main content

Module tree_query

Module tree_query 

Source
Expand description

Dynamically assembles the single-statement tree query a nested repo’s generated read fns execute at runtime: a tagged UNION ALL over one CTE per tree node, so a parent and all of its nested children (recursively) come back in one statement instead of one per level.

Structs§

TreeQuerySource
The root user query plus the bits needed to fold it into the tree query.
TreeSpec
Static description of one node (repo) in a nested tree, used to build the query.

Functions§

build_tree_query
decode_tag
decode_tagged_row
Decodes a row from a tree branch with no snapshot columns (the branch’s own node has no snapshot table, and no sibling forced padding). Identical to what every tree branch decoded before snapshotting existed.
decode_tagged_snapshot_row
Decodes a row from a snapshot-enabled node’s own branch: event and recorded_at may be NULL (the lone snapshot-only row when the tail is empty), and the five snapshot* columns are present.
partition_by_tag
snapshot_fingerprints
Walks the tree in the same DFS order build_tree_query assigns fingerprint bind-parameter indices in (root, then children depth-first), returning the fingerprint of every node that has a snapshot table.
tree_has_snapshot
true if this node or any descendant enables snapshot. Determines whether every branch in the tree’s UNION ALL needs the same (wider) column list — a tree with no snapshot node anywhere emits the same SQL as before this feature existed.