Trigger function volatility

From: Tyler Mitchell <fission(at)ldx(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Trigger function volatility
Date: 2009-08-04 10:48:56
Message-ID: Pine.NEB.4.64.0908040323120.7569@fury.overtheedge.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have some data that I would like to store in lowercase, and so I've
created a function and a trigger:

create or replace function gl_lower() returns trigger as $$
begin
new.sender := lower(new.sender);
new.recipient := lower(new.recipient);
return new;
end;
$$ language plpgsql;
create trigger gl_lower
before insert or update on gl_exemptions
for each row execute procedure gl_lower();

I'm wondering, though, if I can declare it IMMUTABLE. The function itself
doesn't query the database or modify the database directly. Potentially
the data which is about to be inserted/updated gets modified, but my
understanding is that the new data isn't committed until all of the before
triggers are processed.

Can anyone think of any issues with IMMUTABLE in this case? Will there be
any noticeable benefit? My initial tests thus far have all passed.

Kindest regards,

--
Tyler

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Lonni J Friedman 2009-08-04 16:01:28 max_fsm_relations(1000) equals the number of relations checked
Previous Message Devrim GÜNDÜZ 2009-08-04 10:46:55 Re: Where can I find the PostgreSQL 8.2.5 binaries?