Sha256: 6dd80e1572dbcd2956163e6f86e6343ad98701ff8c40efffeb36a90b8336c3d0

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 Bytes

Contents

CREATE OR REPLACE FUNCTION "%{table}_update" ()
  RETURNS TRIGGER
AS $$
DECLARE

BEGIN
  IF OLD.obsoleted_dt <> 'infinity' THEN
     RAISE EXCEPTION 'can not update obsoleted append-only row';
  END IF;

  -- If obsoleted_dt is being set, assume that the row is being
  -- obsoleted.  We return the OLD row so that other field updates are
  -- ignored.  This is used by DELETE.
  IF NEW.obsoleted_dt <> 'infinity' THEN
     OLD.obsoleted_dt = NEW.obsoleted_dt;
     return OLD;
  END IF;

  RAISE EXCEPTION 'can not update append-only row';
END;
$$ LANGUAGE plpgsql;

DROP TRIGGER IF EXISTS %{table}_update ON %{table};
CREATE TRIGGER "%{table}_update" BEFORE UPDATE ON "%{table}" FOR EACH ROW
EXECUTE PROCEDURE "%{table}_update"();

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mcfly-0.0.4 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.3 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.2 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.1 lib/mcfly/update_append_only_trig.sql