pg_trigger.tgargs needs detoast

From: Kenji Kawamura <kawamura(at)intellilink(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_trigger.tgargs needs detoast
Date: 2007-01-19 00:31:10
Message-ID: 45B0114E.3090700@intellilink.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

This patch fixes a bug of case of extraction of pg_trigger.tgargs.
There was a problem when we used a long argument in defining trigger,
possibly resulting in a server crash.

Example:

We defined a CREATE TRIGGER such as follows and registered trigger.
In this case, the argument value which we received in the trigger
procedure was not right.

CREATE TRIGGER trigger_test BEFORE INSERT OR UPDATE ON sample FOR EACH
ROW EXECUTE PROCEDURE sample_trig('XXX...(more than 1823 characters)');

The trigger procedure which receives the argument:

Datum sample_trig(PG_FUNCTION_ARGS)
{
TriggerData* trigdata = (TriggerData*)fcinfo->context;
char** args = trigdata->tg_trigger->tgargs;
int nargs = trigdata->tg_trigger->tgnargs;

int i;
for (i = 0; i < nargs; i++) {
elog(LOG, "%s", args[i]);
}
...
}

Result:

Before: LOG: (the character that is not right, for example '%')
After : LOG: XXX...(more than 1823 characters)

Regards,

---
Kenji Kawamura
NTT Open Source Center, Japan

Attachment Content-Type Size
detoast_pg_trigger_tgargs.patch text/plain 1.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Gavin Sherry 2007-01-19 03:46:05 Planning aggregates which require sorted or distinct input
Previous Message Alvaro Herrera 2007-01-19 00:18:57 Re: Windows buildfarm failures