Re: BUG #18314: PARALLEL UNSAFE function does not prevent parallel index build - Mailing list pgsql-bugs

From jian he
Subject Re: BUG #18314: PARALLEL UNSAFE function does not prevent parallel index build
Date
Msg-id CACJufxEQGsCqsa2XZMQdHtZxwBD8tncLDJV32+6G9y4bOi0jVg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18314: PARALLEL UNSAFE function does not prevent parallel index build  (Tender Wang <tndrwang@gmail.com>)
Responses Re: BUG #18314: PARALLEL UNSAFE function does not prevent parallel index build  (Michael Paquier <michael@paquier.xyz>)
List pgsql-bugs
On Tue, Mar 5, 2024 at 7:49 PM Tender Wang <tndrwang@gmail.com> wrote:
>
>>
>> On top of that, your approach has two bugs:
>> RelationGetIndexExpressions and RelationGetIndexPredicate would return
>> the flattened information if available directly from the relcache, so
>> even if you pass get_raw_expr=true you may finish with flattened
>> expressions and/or predicates, facing the same issues.
>>
>> I think that the correct way to do that would be to get the
>> information from the syscache when calculating the number of parallel
>> workers to use for the parallel index builds, with SysCacheGetAttr(),
>> for example.  That would ensure that the expressions are not
>> flattened, letting the relcache be.
>
>
> I refactor the v2 version patch according to your advice.
> Any thoughts?

in RelationGetIndexClause to, I think you can use the following to
save a SearchSysCache1 cycle?
if (relation->rd_indextuple == NULL ||
heap_attisnull(relation->rd_indextuple, Anum_pg_index_indexprs, NULL))
return NIL;

or
if (relation->rd_indextuple == NULL ||
heap_attisnull(relation->rd_indextuple, Anum_pg_index_indpred, NULL))
return NIL;

main question would be why not two functions,
like RelationGetIndexRawExpr(Relation relation),
RelationGetIndexRawPred(Relation relation)



pgsql-bugs by date:

Previous
From: Miron Berlin
Date:
Subject: bug in function strtoint, on Windows OS won't report ERANGE
Next
From: Ronan Dunklau
Date:
Subject: Re: FSM Corruption (was: Could not read block at end of the relation)