Trigger on 'create table' ? - Mailing list pgsql-hackers

From Bruce David
Subject Trigger on 'create table' ?
Date
Msg-id 00f501c27c4f$10b5b680$6552010a@direcpc.com
Whole thread Raw
Responses Re: Trigger on 'create table' ?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
All,

I'm trying to implement row level security using PostgreSQL.  I envision
having column on each and every table in the database that will contain a
discriminating value that determines if a given user is able to see that row
or not.  Users do not directly access the database; they get at it only
through client applications.

Is there a way to initially configure PostgreSQL such that each and every
time a 'create table foo....' command is executed that, something else would
happen instead?

For example,

CREATE TABLE weather (   city        varchar(80),   lo        int,   hi        int,   prcp    real,   date    date
);

would result in the following being executed automatically:

CREATE TABLE t_weather (   city        varchar(80),   lo        int,   hi        int,   prcp    real,   date    date,
hidden_column   int
 
);

CREATE VIEW weather AS   SELECT city, lo, hi, prcp, date   FROM t_weather;


How the view gets populated is another discussion entirely.

But is there a way to set things up initially such that each 'create table'
command will exhibit the behavior described above?

Thanks.

--

Bruce






pgsql-hackers by date:

Previous
From: "P.J. \"Josh\" Rovero"
Date:
Subject: 7.3b3 build --with-perl fails on RH 8.0
Next
From: "Timothy Chan"
Date:
Subject: How to store chinese using the Postgresql?