pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18755: Using Natts_pg_trigger rather than Natts_pg_event_trigger for event trigger
3+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2024-12-29 eb53ff5517  Fix overly large values/nulls arrays
* BUG #18755: Using Natts_pg_trigger rather than Natts_pg_event_trigger for event trigger
@ 2024-12-29 08:52  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2024-12-29 08:52 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: zhanghien@qq.com

The following bug has been logged on the website:

Bug reference:      18755
Logged by:          Xin Zhang
Email address:      zhanghien@qq.com
PostgreSQL version: 17.2
Operating system:   Any
Description:        

In function insert_event_trigger_tuple, the datum array is declared with
length Natts_pg_trigger:
```c
	Datum		values[Natts_pg_trigger];
	bool		nulls[Natts_pg_trigger];
```

Natts_pg_trigger should only be used in pg_trigger tuple and
Natts_pg_event_trigger is for pg_event_trigger?
I think this could be a typo. Maybe the author of function
insert_event_trigger_tuple copied the variables from CreateTriggerFiringOn
but forgot to change the array length to Natts_pg_event_trigger.

The current code works because Natts_pg_trigger is 19 and
Natts_pg_event_trigger is 7, the pg_event_trigger values array is allocated
with some extra items which is never accessed with index >= 7.



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

* Re: BUG #18755: Using Natts_pg_trigger rather than Natts_pg_event_trigger for event trigger
@ 2024-12-29 09:37  张鑫 <zhanghien@qq.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: 张鑫 @ 2024-12-29 09:37 UTC (permalink / raw)
  To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>

Hi&nbsp;everyone!


Here is the fix for BUG #18755. I fail to upload the patch with my mailbox and I just paste the text here because it's simple enough.


inline patch 1: src/backend/commands/event_trigger.c (+0/-0 lines) download 0001-Replace-Natts_pg_trigger-with-Natts_pg_event_trigger.patchFrom 94009c0ae26443d03bd81ec10a1b666a4c10def4 Mon Sep 17 00:00:00 2001 From: "Xin Zhang" <zhanghien@qq.com&gt; Date: Sun, 29 Dec 2024 17:08:53 +0800 Subject: [PATCH] Replace Natts_pg_trigger with Natts_pg_event_trigger for &nbsp;event trigger --- &nbsp;src/backend/commands/event_trigger.c | 4 ++-- &nbsp;1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index dcfc1dbaffd..1f5872554d4 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -276,8 +276,8 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
&nbsp; Relation tgrel; &nbsp; Oid trigoid; &nbsp; HeapTuple tuple; - Datum values[Natts_pg_trigger]; - bool nulls[Natts_pg_trigger]; + Datum values[Natts_pg_event_trigger]; + bool nulls[Natts_pg_event_trigger]; &nbsp; NameData evtnamedata, &nbsp; evteventdata; &nbsp; ObjectAddress myself, --&nbsp; 2.39.3 ^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: BUG #18755: Using Natts_pg_trigger rather than Natts_pg_event_trigger for event trigger
@ 2024-12-29 10:36  David Rowley <dgrowleyml@gmail.com>
  parent: 张鑫 <zhanghien@qq.com>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2024-12-29 10:36 UTC (permalink / raw)
  To: 张鑫 <zhanghien@qq.com>; +Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>

On Sun, 29 Dec 2024 at 22:37, 张鑫 <zhanghien@qq.com> wrote:
> Here is the fix for BUG #18755. I fail to upload the patch with my mailbox and I just paste the text here because it's simple enough.

I've not seen this bug report. Perhaps it's caught up in moderation?

> --- a/src/backend/commands/event_trigger.c
> +++ b/src/backend/commands/event_trigger.c
> @@ -276,8 +276,8 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
>   Relation tgrel;
>   Oid trigoid;
>   HeapTuple tuple;
> - Datum values[Natts_pg_trigger];
> - bool nulls[Natts_pg_trigger];
> + Datum values[Natts_pg_event_trigger];
> + bool nulls[Natts_pg_event_trigger];
>   NameData evtnamedata,
>   evteventdata;
>   ObjectAddress myself,

Yes, that's better. However, no particular harm done since pg_trigger
has more columns than pg_event_trigger.  For that reason, it's
probably fine to fix in master only. The number of columns in those
tables in the back branches isn't going to change.

I scanned around to see if there's been any similar copy/paste errors,
but couldn't see any.

I'll take care of pushing this. Thanks for the patch.

David





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


end of thread, other threads:[~2024-12-29 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-29 08:52 BUG #18755: Using Natts_pg_trigger rather than Natts_pg_event_trigger for event trigger PG Bug reporting form <noreply@postgresql.org>
2024-12-29 09:37 ` 张鑫 <zhanghien@qq.com>
2024-12-29 10:36   ` David Rowley <dgrowleyml@gmail.com>

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