Re: PL/pgSQL: allow parallel query for assignment statements

From: Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: PL/pgSQL: allow parallel query for assignment statements
Date: 2026-11-07 14:10:45
Message-ID: b51009fe-8ca0-418d-a14b-46cd82e1cb1d@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

This patch looks good to me.

I have applied it on latest 20-devel master branch and I have run make
installcheck-world successfully.

I have set status to Ready For Committed.

Regards,

PF.

Le 26/10/2026 à 09:58, Jeevan Chalke a écrit :
> Hi,
>
> Commit 61c2e1a95f ("Improve access to parallel query from procedural
> languages") made exec_eval_expr() prepare expressions with
> CURSOR_OPT_PARALLEL_OK, so that queries in IF, RETURN, RAISE, etc. can use
> parallel plans.  It missed exec_assign_expr(), which creates the plan
> itself,
> with cursorOptions 0, before calling exec_eval_expr(). As the plan already
> exists by then, the PARALLEL_OK prepare in exec_eval_expr() never runs.
>
> As a result, a query used in an assignment never gets a parallel plan:
> x := sum(a) from tab;
> while the same query used in, say, an IF condition can.  The same
> applies to
> DECLARE default expressions, which also go through exec_assign_expr().
>
> The pre-planning in exec_assign_expr() is redundant, since
> exec_eval_expr()
> creates the plan if needed, so the attached patch just removes it.
>
> The patch also adds regression tests to select_parallel.sql, one for an
> assignment statement and one for a DECLARE default.  Each provokes an
> error
> in a worker with debug_parallel_query = 1 and checks for the "parallel
> worker" context line.  Both tests fail without the fix.
>
> Thoughts?
>
> Thanks
>
> --
> *Jeevan Chalke*
> /Senior Principal Engineer, Engineering Manager//
> Product Development/
> enterprisedb.com <https://www.enterprisedb.com>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2026-11-07 14:31:07 Re: Call CalculateShmemSize() only once
Previous Message Jeevan Chalke 2026-11-07 13:53:00 Re: postgres_fdw: virtual generated columns vs. IMPORT FOREIGN SCHEMA