Sha256: 4d7f3562703a02355502df75111eb37a330f7a27502468f498d17a16b42cc165

Contents?: true

Size: 769 Bytes

Versions: 8

Compression:

Stored size: 769 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.o_user_id = NEW.o_user_id;
     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

8 entries across 8 versions & 1 rubygems

Version Path
mcfly-0.0.17 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.16 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.15 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.14 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.13 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.12 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.11 lib/mcfly/update_append_only_trig.sql
mcfly-0.0.10 lib/mcfly/update_append_only_trig.sql