pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Bradley Kieser <brad@kieser.net>
Cc: PgSQL ADMIN <pgsql-admin@postgresql.org>
Subject: Re: Rules on a view overwrite default values. Any way to
Date: Mon, 3 Jan 2005 09:30:59 -0800 (PST)
Message-ID: <20050103092722.M55197@megazone.bigpanda.com> (raw)
In-Reply-To: <41D97A9C.6050401@kieser.net>
References: <41D97A9C.6050401@kieser.net>

On Mon, 3 Jan 2005, Bradley Kieser wrote:

> Hi,
>
> I use views extensively to implement security on tables. This requires
> each table to have a view. All updates, inserts and deletes take place
> through the view. The view has rules for each of these operations
> defining security for that table. Under other conditions, the view also
> removes complex views of the underlying data from the application layer
> by supplying a view where the rules for update, insert and delete
> implement business logic.
>
> The problem is that rules on a view mean that the default values for NOT
> NULL columns (used extensively) no longer trigger!
>
> E.g.
>
> Table A had column "updated_time" which is not null default now().
> Inserting into the view on table A where "updated_time" has not been
> supplied will not fill in "now()". It will attempt to put in a null
> value and hence the insert will fail in the insert rule on that view.

I believe the easiest way is to attach a default to the view column
using ALTER TABLE viewname ALTER COLUMN viewcolumn SET DEFAULT
defaultexpr.



view thread (7+ messages)  latest in thread

Message-ID: <20050103092722.M55197@megazone.bigpanda.com>
Permalink:  ../20050103092722.M55197@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20050103092722.M55197@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, brad@kieser.net
  Subject: Re: Rules on a view overwrite default values. Any way to
  In-Reply-To: <20050103092722.M55197@megazone.bigpanda.com>
  References: <41D97A9C.6050401@kieser.net> <20050103092722.M55197@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox