以下函数 update_sessioninfo() 应该只更新更改的列。New.* 列在运行后被更新为一些不正确的值:
update freeradius.radacct set acctsessiontime=25 where radacctid=3;
功能
CREATE OR REPLACE FUNCTION update_sessioninfo() RETURNS trigger AS $radacct_update$
BEGIN
-- update the updated records
update freeradius.day_guiding_usage set acctstoptime=New.acctstoptime,acctsessiontime=New.acctsessiontime,connectinfo_start=New.connectinfo_start,connectinfo_stop=New.connectinfo_stop,acctinputoctets=New.acctinputoctets,acctoutputoctets=New.acctoutputoctets,acctterminatecause=New.acctterminatecause where acctsessionid=Old.acctsessionid;
RETURN NULL;
END;
$radacct_update$ LANGUAGE plpgsql;
触发器在下面
CREATE TRIGGER radacct_update AFTER UPDATE ON freeradius.radacct
FOR EACH ROW
WHEN (OLD.* IS DISTINCT FROM NEW.*)
EXECUTE procedure update_sessioninfo();