pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
3+ messages / 3 participants
[nested] [flat]

* [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
@ 2026-09-09 00:00 Lucas Jeffrey <luquijeffrey@gmail.com>
  2026-09-09 00:40 ` Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments Michael Paquier <michael@paquier.xyz>
  2026-09-09 07:50 ` Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 2 replies; 3+ messages in thread

From: Lucas Jeffrey @ 2026-09-09 00:00 UTC (permalink / raw)
  To: pgsql-hackers@lists.postgresql.org; +Cc: Lucas Jeffrey <luquijeffrey@gmail.com>

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
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
  2026-09-09 00:00 [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments Lucas Jeffrey <luquijeffrey@gmail.com>
@ 2026-09-09 00:40 ` Michael Paquier <michael@paquier.xyz>
  1 sibling, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-09-09 00:40 UTC (permalink / raw)
  To: Lucas Jeffrey <luquijeffrey@gmail.com>; +Cc: pgsql-hackers@lists.postgresql.org

On Tue, Sep 08, 2026 at 09:00:31PM -0300, Lucas Jeffrey wrote:
>  		foreach(le, stmt->args)
>  		{
>  			char	   *s = strVal(lfirst(le));
> -			char	   *d = args + strlen(args);

While a right suggestion, trigger creation is no critical path.  So
why caring?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

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

* Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
  2026-09-09 00:00 [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments Lucas Jeffrey <luquijeffrey@gmail.com>
@ 2026-09-09 07:50 ` Daniel Gustafsson <daniel@yesql.se>
  1 sibling, 0 replies; 3+ messages in thread

From: Daniel Gustafsson @ 2026-09-09 07:50 UTC (permalink / raw)
  To: Lucas Jeffrey <luquijeffrey@gmail.com>; +Cc: pgsql-hackers@lists.postgresql.org

> On 9 Sep 2026, at 02:00, Lucas Jeffrey <luquijeffrey@gmail.com> wrote:
> 
> Signed-off-by: Lucas Jeffrey <luquijeffrey@gmail.com>

Optimization patches require a great deal more justification than just the
diff: a discussion on why it's safe and a non-synthetical benchmark which shows
the benefit.

--
Daniel Gustafsson







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


end of thread, other threads:[~2026-09-09 07:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 00:00 [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments Lucas Jeffrey <luquijeffrey@gmail.com>
2026-09-09 00:40 ` Michael Paquier <michael@paquier.xyz>
2026-09-09 07:50 ` Daniel Gustafsson <daniel@yesql.se>

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