Moved schema files to sql/$(db)
authoraland <aland>
Fri, 20 Jul 2007 11:15:21 +0000 (11:15 +0000)
committeraland <aland>
Fri, 20 Jul 2007 11:15:21 +0000 (11:15 +0000)
raddb/sql/mssql/schema.sql [moved from doc/examples/mssql.sql with 100% similarity]
raddb/sql/mysql/schema.sql [moved from doc/examples/mysql.sql with 100% similarity]
raddb/sql/oracle/schema.sql [moved from doc/examples/oracle.sql with 100% similarity]
raddb/sql/postgresql/schema.sql [moved from doc/examples/postgresql.sql with 100% similarity]
raddb/sql/postgresql/update_radacct_group_trigger.sql [new file with mode: 0644]

diff --git a/raddb/sql/postgresql/update_radacct_group_trigger.sql b/raddb/sql/postgresql/update_radacct_group_trigger.sql
new file mode 100644 (file)
index 0000000..ca01d60
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ *
+ * OPTIONAL Postgresql trigger for FreeRADIUS
+ *
+ * This trigger updates fills in the groupname field (which doesnt come in Accounting packets)
+ * by querying the radusergroup table.
+ * This makes it easier to do group summary reports, however note that it does add some extra
+ * database load to 50% of your SQL accounting queries. If you dont care about group summary
+ * reports then you dont need to install this.
+ *
+ */
+
+
+CREATE OR REPLACE FUNCTION upd_radgroups() RETURNS trigger AS'
+
+DECLARE
+        v_groupname varchar;
+
+BEGIN
+        SELECT INTO v_groupname groupname FROM radusergroup WHERE calledstationid = NEW.calledstationid AND username = NEW.username;
+        IF FOUND THEN
+                UPDATE radacct SET groupname = v_groupname WHERE radacctid = NEW.radacctid;
+        END IF;
+
+        RETURN NEW;
+END
+
+'LANGUAGE plpgsql;
+
+
+DROP TRIGGER upd_radgroups ON radacct;
+
+CREATE TRIGGER upd_radgroups AFTER INSERT ON radacct
+    FOR EACH ROW EXECUTE PROCEDURE upd_radgroups();
+
+