pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lucas Jeffrey <luquijeffrey@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Lucas Jeffrey <luquijeffrey@gmail.com>
Subject: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
Date: Tue,  8 Sep 2026 21:00:31 -0300
Message-ID: <20260909000031.1538080-1-luquijeffrey@gmail.com> (raw)

Signed-off-by: Lucas Jeffrey <luquijeffrey@gmail.com>
---
 src/backend/commands/trigger.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

inline patch 1: src/backend/commands/trigger.c (+3/-1 lines) download inline-1.patchdiff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 1d10fb1c13c..fe447f6df68 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -899,6 +899,7 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString, char *args; int nargs = list_length(stmt->args); int len = 0; + char *d; Assert(nargs >= 0); if (nargs > PG_INT16_MAX) @@ -922,10 +923,10 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString, } args = (char *) palloc(len + 1); args[0] = '\0'; + d = args; foreach(le, stmt->args) { char *s = strVal(lfirst(le)); - char *d = args + strlen(args); while (*s) { @@ -934,6 +935,7 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString, *d++ = *s++; } strcpy(d, "\\000"); + d += 4; } values[Anum_pg_trigger_tgnargs - 1] = Int16GetDatum(nargs); values[Anum_pg_trigger_tgargs - 1] = DirectFunctionCall1(byteain, -- 2.43.0

view thread (3+ messages)  latest in thread

Message-ID: <20260909000031.1538080-1-luquijeffrey@gmail.com>
Permalink:  ../20260909000031.1538080-1-luquijeffrey@gmail.com/
Also on:    postgresql.org/message-id/20260909000031.1538080-1-luquijeffrey@gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: luquijeffrey@gmail.com
  Subject: Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
  In-Reply-To: <20260909000031.1538080-1-luquijeffrey@gmail.com>
  References: <20260909000031.1538080-1-luquijeffrey@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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