pgtap
pgtap copied to clipboard
Feature: index_is_partial(), index_partial_clause_is()
trafficstars
It would be useful to be able see if an index is partial and what the clause is.
For index_is_partial, we can get that with:
SELECT x.indpred IS NOT NULL
FROM pg_catalog.pg_index x
JOIN pg_catalog.pg_class ct ON ct.oid = x.indrelid
JOIN pg_catalog.pg_class ci ON ci.oid = x.indexrelid
JOIN pg_catalog.pg_namespace n ON n.oid = ct.relnamespace
WHERE ct.relname = $table
AND ci.relname = $index
AND n.nspname = $schema;
For index_partial_clause_is, we can get the string for the partial clause as:
SELECT pg_get_expr(x.indpred, x.indrelid)
FROM pg_catalog.pg_index x
JOIN pg_catalog.pg_class ct ON ct.oid = x.indrelid
JOIN pg_catalog.pg_class ci ON ci.oid = x.indexrelid
JOIN pg_catalog.pg_namespace n ON n.oid = ct.relnamespace
WHERE ct.relname = $table
AND ci.relname = $index
AND n.nspname = $schema;
Hi @halostatue I started to work on your request, please see the attached pull request. If everything go fine, it should be in the 1.3.4 version
Heya @rodo, is that in #334? Is it ready to review?
Heya @rodo, is that in #334? Is it ready to review?
Bah, no, it's #342, sorry.