pg_trigger.tgargs needs detoast
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