Trigger function does not modify the NEW value

From: "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Trigger function does not modify the NEW value
Date: 2019-06-29 02:53:50
Message-ID: 04592c40-829d-a31e-790a-96afbc108c0a@lucee.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a trigger that is created like so:

    create trigger tr_on_table_modified after insert or delete or update
        on some_table for each row execute procedure on_table_modified();

    CREATE OR REPLACE FUNCTION on_table_modified() RETURNS trigger
LANGUAGE plpgsql $$
        /* some code that does not modify any values but calls PERFORM
on another function */

        raise notice 'lowercasing %', new.email;
        new.email = lower(new.email);
        raise notice '    to %', new.email;

        return new;
    $$

I can see in the output the notices with the expected values, but the
value in the updated record is not lower-cased.

update some_table
set    email = 'IGAL(at)Lucee(dot)org'
where  id = 1;

> 00000: lowercasing IGAL(at)Lucee(dot)org
> 00000:     to igal(at)lucee(dot)org

select email
from   some_table
where  id = 1;

> email         |
> --------------|
> IGAL(at)Lucee(dot)org|

Any ideas?

Thanks,

Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2019-06-29 03:07:25 Re: Trigger function does not modify the NEW value
Previous Message Michael Paquier 2019-06-29 02:27:09 Re: Re: Re: Enabling checksums on a streaming replica