diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-03-06 17:24:06 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-03-06 17:24:06 +0900 |
commit | 50b5913a87c9c2d67330d82429f6dda61441d40c (patch) | |
tree | f84a64aa5d9519703e5c86715e361b8c543dbb8d /src/include/utils/lsyscache.h | |
parent | 164fe7a6e1f34a56d91c0130daddbbe6a8e8392f (diff) |
Fix parallel-safety check of expressions and predicate for index builds
As coded, the planner logic that calculates the number of parallel
workers to use for a parallel index build uses expressions and
predicates from the relcache, which are flattened for the planner by
eval_const_expressions().
As reported in the bug, an immutable parallel-unsafe function flattened
in the relcache would become a Const, which would be considered as
parallel-safe, even if the predicate or the expressions including the
function are not safe in parallel workers. Depending on the expressions
or predicate used, this could cause the parallel build to fail.
Tests are included that check parallel index builds with parallel-unsafe
predicate and expressions. Two routines are added to lsyscache.h to be
able to retrieve expressions and predicate of an index from its pg_index
data.
Reported-by: Alexander Lakhin
Author: Tender Wang
Reviewed-by: Jian He, Michael Paquier
Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evHUFA@mail.gmail.com
Backpatch-through: 12
Diffstat (limited to 'src/include/utils/lsyscache.h')
-rw-r--r-- | src/include/utils/lsyscache.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index b8dd27d4a96..96605ea586a 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -195,6 +195,8 @@ extern Oid get_range_collation(Oid rangeOid); extern Oid get_range_multirange(Oid rangeOid); extern Oid get_multirange_range(Oid multirangeOid); extern Oid get_index_column_opclass(Oid index_oid, int attno); +extern List *get_index_expressions(Oid index_oid); +extern List *get_index_predicate(Oid index_oid); extern bool get_index_isreplident(Oid index_oid); extern bool get_index_isvalid(Oid index_oid); extern bool get_index_isclustered(Oid index_oid); |