X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 551FC3A3D2D for ; Mon, 3 Jan 2005 17:02:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33634-02 for ; Mon, 3 Jan 2005 17:02:01 +0000 (GMT) Received: from laptop.kieser.net (kieser2.demon.co.uk [80.176.229.121]) by svr1.postgresql.org (Postfix) with ESMTP id 9160B3A3D0A for ; Mon, 3 Jan 2005 17:02:00 +0000 (GMT) Received: from [127.0.0.1] (laptop.kieser2.demon.co.uk [127.0.0.1]) by laptop.kieser.net (Postfix) with ESMTP id 5069118330 for ; Mon, 3 Jan 2005 17:02:21 +0000 (GMT) Message-ID: <41D97A9C.6050401@kieser.net> Date: Mon, 03 Jan 2005 17:02:20 +0000 From: Bradley Kieser User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en, en-us MIME-Version: 1.0 To: PgSQL ADMIN Subject: Rules on a view overwrite default values. Any way to reinstate them? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.424 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/8 X-Sequence-Number: 15867 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. Is there any way to tell PG to implement the triggers on the underlying table? It will make it extremely difficult to implement this schema if I have to try to put in null field handling... and it really should be PG doing this not me! No doubt if this is a bug, it will be fixed in 8.x! Thanks, Brad