paupino / psqlpack

A logical database management system for PostgreSQL enabling incremental database deployment.
Apache License 2.0
8 stars 2 forks source link

Add support for index predicates #143

Open paupino opened 4 years ago

paupino commented 4 years ago

This relies on unpacking the pg_node_tree field on pg_index.indpred. This looks like a readable serialization format, however is not JSON etc. I suspect that it maps directly to it's C representation.

paupino commented 4 years ago

e.g. {NULLTEST :arg {VAR :varno 1 :varattno 3 :vartype 25 :vartypmod -1 :varcollid 100 :varlevelsup 0 :varnoold 1 :varoattno 3 :location 64} :nulltesttype 1 :argisrow false :location 74}

paupino commented 4 years ago

From what I know about this predicate (WHERE last_name IS NOT NULL in this case), the above structure seems to correlate to the following bison/C code:

| a_expr IS NULL_P                          %prec IS
{
    NullTest *n = makeNode(NullTest);
    n->arg = (Expr *) $1;
    n->nulltesttype = IS_NULL;
    n->location = @2;
    $$ = (Node *)n;
}