Delete trigger and data integrity - Mailing list pgsql-general

From Yvonne Zannoun
Subject Delete trigger and data integrity
Date
Msg-id CAO0x8gtdCvA50fkXZO+t8-ptcOiBgpn_38yOK-1yZPFeC15DbQ@mail.gmail.com
Whole thread Raw
Responses Re: Delete trigger and data integrity  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Re: Delete trigger and data integrity  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general

Hello everyone,

 

I have this question regarding delete triggers and how it affects data integrity.

So here goes: I have this trigger which deletes everything before I insert new rows.

 

    CREATE OR REPLACE FUNCTION delete_records()

RETURNS TRIGGER AS $$

BEGIN

delete from "TABLE";

    RETURN NEW;

END;

$$

LANGUAGE plpgsql;

 

CREATE TRIGGER delete_on_insert

    BEFORE INSERT ON "TABLE"

    FOR EACH ROW EXECUTE PROCEDURE delete_records();

 

My question is what happens while this function is executed? Is there any chance the table can return empty data between the delete and insert commands? Or does a trigger like this block this possibility somehow?


Thank you


Kind regards,
Yvonne Zannoun



Geospatial Technology Company of the Year

pgsql-general by date:

Previous
From: Andrej Vanek
Date:
Subject: hidden junk files in ...data/base/oid/
Next
From: Albe Laurenz
Date:
Subject: Re: libpq: indefinite block on poll during network problems