small patch pathc postgresql trigger function

Jasen Betts jasen at treshna.com
Thu Jul 22 04:11:58 CEST 2010


>From jasen at treshna.com Thu Jul 22 13:02:19 2010
Date: Thu, 22 Jul 2010 13:02:19 +1200
From: Jasen Betts <jasen at treshna.com>
To: freeradius-devel at lists.freeradius.org
Subject: small patch pathc postgresql trigger function
Message-ID: <20100722010219.GA7516 at treshna.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.18 (2008-05-17)
Status: RO
X-Status: A

here's a small patch, not sure where to submit it.

This version should prove faster as it halves the number of writes,
however it still does a lookup.

this code replaces similar code in 
etc/raddb/sql/postgresql/update_radacct_group_trigger.sql 

----

CREATE OR REPLACE FUNCTION upd_radgroups() RETURNS trigger AS'
BEGIN
	IF NEW.groupname IS NULL THEN 
		NEW.groupname = groupname
			FROM radusergroup 
			WHERE calledstationid = NEW.calledstationid
				AND username = NEW.username;
	END IF;
	RETURN NEW;
END
'LANGUAGE plpgsql;

DROP TRIGGER upd_radgroups ON radacct;

CREATE TRIGGER upd_radgroups BEFORE INSERT ON radacct
    FOR EACH ROW EXECUTE PROCEDURE upd_radgroups();

----

    
-- 
Jasen Betts
treshna Enterprises Ltd



More information about the Freeradius-Devel mailing list