Project

General

Profile

« Previous | Next » 

Revision 14160

schemas/util.sql: derived_cols_sync(): also create trigger, since this is necessary for a complete sync

View differences:

trunk/schemas/util.sql
1610 1610
    SET search_path TO util
1611 1611
    AS $_$
1612 1612
DECLARE
1613
	trigger_name_sql text = table_::text||%'__fill_derived';
1613
	trigger_func_name_sql text = table_::text||%'__fill_derived';
1614
	trigger_name text;
1614 1615
BEGIN
1615 1616
	PERFORM util.eval($$
1616
CREATE OR REPLACE FUNCTION $$||trigger_name_sql||$$()
1617
CREATE OR REPLACE FUNCTION $$||trigger_func_name_sql||$$()
1617 1618
  RETURNS trigger AS
1618 1619
$BODY1$
1619 1620
BEGIN
......
1632 1633
  LANGUAGE plpgsql VOLATILE
1633 1634
  COST 100;
1634 1635
$$);
1636
	
1637
	-- util.name() only works once func exists
1638
	trigger_name = util.name(trigger_func_name_sql::regproc);
1639
	
1640
	PERFORM util.create_if_not_exists($$
1641
CREATE TRIGGER $$||quote_ident(trigger_name)||$$
1642
  BEFORE INSERT OR UPDATE
1643
  ON $$||table_||$$
1644
  FOR EACH ROW
1645
  EXECUTE PROCEDURE $$||trigger_func_name_sql||$$();$$);
1635 1646
END;
1636 1647
$_$;
1637 1648

  

Also available in: Unified diff