pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Split ExecUpdate and ExecDelete into reusable pieces
4+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2022-03-19 a1fc50672c  Fix an outdated and grammatically wrong comment
* pgsql: Split ExecUpdate and ExecDelete into reusable pieces
@ 2022-03-17 10:47 Alvaro Herrera <alvherre@alvh.no-ip.org>
  2022-03-19 03:59 ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Alvaro Herrera @ 2022-03-17 10:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Split ExecUpdate and ExecDelete into reusable pieces

Create subroutines ExecUpdatePrologue / ExecUpdateAct /
ExecUpdateEpilogue, and similar for ExecDelete.

Introduce a new struct to be used internally in nodeModifyTable.c,
dubbed ModifyTableContext, which contains all context information needed
to perform these operations, as well as ExecInsert and others.

This allows using a different schedule and a different way of evaluating
the results of these operations, which can be exploited by a later
commit introducing support for MERGE.  It also makes ExecUpdate and
ExecDelete proper shorter and (hopefully) simpler.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>
Discussion: https://postgr.es/m/202202271724.4z7xv3cf46kv@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/25e777cf8e547d7423d2e1e9da71f98b9414d59e

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 781 ++++++++++++++++++++-------------
src/tools/pgindent/typedefs.list       |   2 +
2 files changed, 484 insertions(+), 299 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces
  2022-03-17 10:47 pgsql: Split ExecUpdate and ExecDelete into reusable pieces Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2022-03-19 03:59 ` Amit Langote <amitlangote09@gmail.com>
  2022-03-19 04:09   ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Amit Langote @ 2022-03-19 03:59 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-committers@lists.postgresql.org

Hi Alvaro,

On Thu, Mar 17, 2022 at 7:47 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> Split ExecUpdate and ExecDelete into reusable pieces
>
> Create subroutines ExecUpdatePrologue / ExecUpdateAct /
> ExecUpdateEpilogue, and similar for ExecDelete.
>
> Introduce a new struct to be used internally in nodeModifyTable.c,
> dubbed ModifyTableContext, which contains all context information needed
> to perform these operations, as well as ExecInsert and others.
>
> This allows using a different schedule and a different way of evaluating
> the results of these operations, which can be exploited by a later
> commit introducing support for MERGE.  It also makes ExecUpdate and
> ExecDelete proper shorter and (hopefully) simpler.

I noticed that we failed to update a comment mentioning a now obsolete
parameter of ExecCrossPartitionUpdate().  Attached a patch to fix that
and an old typo in the same sentence.

-- 
Amit Langote
EDB: http://www.enterprisedb.com

Attachments:

fix-obsolete-comment.patch (application/octet-stream, 893B) download diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 6239abae90..dbdc8e5d52 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1517,9 +1517,10 @@ ldelete:; * for the caller. * * False is returned if the tuple we're trying to move is found to have been - * concurrently updated. In that case, the caller must to check if the - * updated tuple that's returned in *retry_slot still needs to be re-routed, - * and call this function again or perform a regular update accordingly. + * concurrently updated. In that case, the caller must check if the updated + * tuple that's returned in context->cpUpdateRetrySlot still needs to be + * re-routed, and call this function again or perform a regular update + * accordingly. */ static bool ExecCrossPartitionUpdate(ModifyTableContext *context,
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces
  2022-03-17 10:47 pgsql: Split ExecUpdate and ExecDelete into reusable pieces Alvaro Herrera <alvherre@alvh.no-ip.org>
  2022-03-19 03:59 ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Amit Langote <amitlangote09@gmail.com>
@ 2022-03-19 04:09   ` Amit Langote <amitlangote09@gmail.com>
  2022-03-19 18:42     ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Amit Langote @ 2022-03-19 04:09 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-committers@lists.postgresql.org

On Sat, Mar 19, 2022 at 12:59 PM Amit Langote <amitlangote09@gmail.com> wrote:
> On Thu, Mar 17, 2022 at 7:47 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> >
> > Split ExecUpdate and ExecDelete into reusable pieces
> >
> > Create subroutines ExecUpdatePrologue / ExecUpdateAct /
> > ExecUpdateEpilogue, and similar for ExecDelete.
> >
> > Introduce a new struct to be used internally in nodeModifyTable.c,
> > dubbed ModifyTableContext, which contains all context information needed
> > to perform these operations, as well as ExecInsert and others.
> >
> > This allows using a different schedule and a different way of evaluating
> > the results of these operations, which can be exploited by a later
> > commit introducing support for MERGE.  It also makes ExecUpdate and
> > ExecDelete proper shorter and (hopefully) simpler.
>
> I noticed that we failed to update a comment mentioning a now obsolete
> parameter of ExecCrossPartitionUpdate().  Attached a patch to fix that
> and an old typo in the same sentence.

Actually, I also noticed that the v16 patch you posted in the "Re: a
misbehavior of partition row movement (?)" thread contained this same
fix.  I like the wording in that patch, though I guess it's better to
commit the fix separately from the big patch there, which I guess may
have been your intention anyway.  So, here's a v2.

-- 
Amit Langote
EDB: http://www.enterprisedb.com

Attachments:

fix-obsolete-comment_v2.patch (application/octet-stream, 874B) download diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 6239abae90..3dd9100cb4 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1517,9 +1517,9 @@ ldelete:; * for the caller. * * False is returned if the tuple we're trying to move is found to have been - * concurrently updated. In that case, the caller must to check if the - * updated tuple that's returned in *retry_slot still needs to be re-routed, - * and call this function again or perform a regular update accordingly. + * concurrently updated. In that case, the caller must check if the updated + * tuple (in context->cpUpdateRetrySlot) still needs to be re-routed, and call + * this function again or perform a regular update accordingly. */ static bool ExecCrossPartitionUpdate(ModifyTableContext *context,
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces
  2022-03-17 10:47 pgsql: Split ExecUpdate and ExecDelete into reusable pieces Alvaro Herrera <alvherre@alvh.no-ip.org>
  2022-03-19 03:59 ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Amit Langote <amitlangote09@gmail.com>
  2022-03-19 04:09   ` Re: pgsql: Split ExecUpdate and ExecDelete into reusable pieces Amit Langote <amitlangote09@gmail.com>
@ 2022-03-19 18:42     ` Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Alvaro Herrera @ 2022-03-19 18:42 UTC (permalink / raw)
  To: Amit Langote <amitlangote09@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

On 2022-Mar-19, Amit Langote wrote:

> Actually, I also noticed that the v16 patch you posted in the "Re: a
> misbehavior of partition row movement (?)" thread contained this same
> fix.  I like the wording in that patch, though I guess it's better to
> commit the fix separately from the big patch there, which I guess may
> have been your intention anyway.  So, here's a v2.

Yeah, I was of two minds about pushing it separately -- and you
mentioning it now pushed me to do that.  So, it's done now.

-- 
Álvaro Herrera              Valdivia, Chile  —  https://www.EnterpriseDB.com/
"Hay que recordar que la existencia en el cosmos, y particularmente la
elaboración de civilizaciones dentro de él no son, por desgracia,
nada idílicas" (Ijon Tichy)





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2022-03-19 18:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 10:47 pgsql: Split ExecUpdate and ExecDelete into reusable pieces Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-03-19 03:59 ` Amit Langote <amitlangote09@gmail.com>
2022-03-19 04:09   ` Amit Langote <amitlangote09@gmail.com>
2022-03-19 18:42     ` Alvaro Herrera <alvherre@alvh.no-ip.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox