Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 2624A2E00E5 for ; Tue, 29 Jan 2008 00:16:12 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 90742-01 for ; Tue, 29 Jan 2008 00:15:51 -0400 (AST) Received: from outX.internet-mail-service.net (outX.internet-mail-service.net [216.240.47.247]) by postgresql.org (Postfix) with ESMTP id 9A6C12E0281 for ; Tue, 29 Jan 2008 00:16:03 -0400 (AST) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Mon, 28 Jan 2008 20:16:01 -0800 X-Client-Authorized: MaGic Cook1e Received: from [192.168.1.109] (adsl-71-135-191-42.dsl.pltn13.pacbell.net [71.135.191.42]) by idiom.com (Postfix) with ESMTP id DB6A2127031 for ; Mon, 28 Jan 2008 20:16:00 -0800 (PST) Message-ID: <479EA8A3.5070401@obviously.com> Date: Mon, 28 Jan 2008 20:16:35 -0800 From: Bryce Nesbitt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20070803 SUSE/1.1.7-0.1 SeaMonkey/1.1.7 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Proposed archival read only trigger on rows - prevent history modification Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/217 X-Sequence-Number: 30070 I've got a largish database which once a month churns out some invoices. Once those invoices are created, there is zero business logic reason to ever modify the underlying data. A few hundred thousand database rows go into the building of each month's invoices. New data is added all the time, and used at the end of each month. I'm considering building a protective mechanism, and am seeking feedback on the idea. The approach would be to add a new column named "ro" to each table at invoice level and below. Then have a trigger on 'ro'==true deny the write, and probably raise a huge stink. As invoice are mailed each month, all the supporting data would be set to "ro" true. The idea is to protect years and years of archival data from an inadvertent write (such from an underspecified where clause, or a software bug). Ideally the mechanism would never be triggered. To corrupt data would require two acts -- changing the "ro" column, then issuing an update. I'm seeking feedback on the need, the approach, performance issues, and any instances of core database support for such a concept. I do see an Oracle feature that seems somewhat on target. I am using postgres, in a mostly database independent manner. Bryce Nesbitt http://www.citycarshare.org/