summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2012-01-08 22:56:19 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2013-06-13 01:01:55 +0200
commit52497ab789ce706d6c726d347dfc8af7bedfee89 (patch)
treefb481aff41036b3915634c5b548e15e82d5e8dea /database
parent9828725d7c40d26739700e54007a3c22287b2b78 (diff)
downloadeurephia-52497ab789ce706d6c726d347dfc8af7bedfee89.tar.gz
eurephia-52497ab789ce706d6c726d347dfc8af7bedfee89.tar.xz
eurephia-52497ab789ce706d6c726d347dfc8af7bedfee89.zip
edb-pgsql: Add an updatable view for the lastlog table
This allows the eurephia-auth user to only update the columns in the lastlog which it is supposed to update. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'database')
-rw-r--r--database/postgresql/sql-schema.sql15
1 files changed, 15 insertions, 0 deletions
diff --git a/database/postgresql/sql-schema.sql b/database/postgresql/sql-schema.sql
index dc75a82..6634344 100644
--- a/database/postgresql/sql-schema.sql
+++ b/database/postgresql/sql-schema.sql
@@ -95,6 +95,21 @@ CREATE TABLE lastlog (
);
CREATE UNIQUE INDEX lastlog_sessionkey ON lastlog(sessionkey);
+-- View lastlog_update: A view with columns which is allowed to be updated
+CREATE VIEW lastlog_update AS
+ SELECT sessionkey, sessionstatus, macaddr, logout, session_deleted, session_duration,
+ bytes_sent, bytes_received
+ FROM lastlog;
+CREATE RULE lastlog_allow_update
+ AS ON UPDATE TO lastlog_update
+ DO INSTEAD UPDATE lastlog
+ SET sessionstatus = NEW.sessionstatus, macaddr = NEW.macaddr,
+ logout = NEW.logout, session_deleted = NEW.session_deleted,
+ session_duration = NEW.session_duration,
+ bytes_sent = NEW.bytes_sent, bytes_received = NEW.bytes_received
+ WHERE sessionkey = OLD.sessionkey
+ AND sessionstatus = OLD.sessionstatus;
+
-- Table macaddr_history: This keeps an overview over which MAC addresses a session
-- have used, in case the client changes the MAC address.
CREATE TABLE macaddr_history (