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

The Boolean algebra of the subsets of a PostgreSQL enum type. More...

#include "postgres.h"
#include "fmgr.h"
#include "catalog/pg_enum.h"
#include "catalog/pg_type.h"
#include "utils/array.h"
#include "utils/catcache.h"
#include "utils/syscache.h"
#include "utils/lsyscache.h"
#include "access/htup_details.h"
#include <algorithm>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "Semiring.h"
Include dependency graph for Subset.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  semiring::EnumLabels
 The labels of an enum type, in enumsortorder: their OIDs, and the rank of each OID. More...
class  semiring::Subset
 Subsets of the labels of an enum type, as a 64-bit mask. More...

Namespaces

namespace  semiring

Detailed Description

The Boolean algebra of the subsets of a PostgreSQL enum type.

An annotation is a set of labels of a user enum (at most 63 of them), stored as a bitmask: bit \(i\) stands for the label of rank \(i\) in pg_enum.enumsortorder. The operations are those of the powerset Boolean algebra:

  • zero() → the empty set
  • one() → every label (and, for consent, the unrestricted element)
  • plus() → union
  • times() → intersection
  • monus() → set difference
  • delta() → identity

Evaluating a circuit here is evaluating it in every one of the worlds the labels stand for at once: the annotation of a result is the set of labels whose world contains it. Three front-ends read the labels differently, selected by Mode:

  • SUBSET: a mapping value is a set of labels (an enum array), or a single label standing for itself;
  • CLEARANCE: the labels are clearance levels in increasing order, and a single label stands for itself and every level above it (the levels at which a tuple of that clearance may be seen); an array is any set (compartments);
  • CONSENT: the labels are purposes, a mapping value is the set of purposes a tuple is consented for, and every tuple also belongs to the unrestricted world, an extra element (bit 63) standing for the whole database.

Being a Boolean algebra, the semiring is absorptive, idempotent for both operations, exclusive, and its product distributes over its monus: every property the evaluators look for holds, so negation (EXCEPT, NOT EXISTS) gets its exact reading, which a single level (MinMax) cannot represent.

Definition in file Subset.h.