X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A73A3476392; Fri, 25 Apr 2003 13:44:26 -0400 (EDT) Received: from snoopy.oit.edu (snoopy.OIT.EDU [140.211.135.12]) by postgresql.org (Postfix) with ESMTP id 34A8B475F3D; Fri, 25 Apr 2003 13:44:17 -0400 (EDT) Received: from cvc.net (purvine-141-62.oit.edu [140.211.141.62]) by snoopy.oit.edu (8.12.9/8.12.9/OIT-4.0) with ESMTP id h3PHi4pX031770; Fri, 25 Apr 2003 10:44:14 -0700 Message-ID: <3EA974B7.4090309@cvc.net> Date: Fri, 25 Apr 2003 10:47:35 -0700 From: Dennis Gearon Reply-To: gearond@cvc.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, ru MIME-Version: 1.0 To: josh@agliodbs.com Cc: Robert Treat , elein@varlena.com, elein , "pgsql-general@postgresql.org" , pgsql-sql@postgresql.org Subject: Re: [SQL] rewriting values with before trigger References: <1051201544.4753.522.camel@camel> <200304250033.h3P0XuDl088102@pimout1-ext.prodigy.net> <200304250003.24506.xzilla@users.sourceforge.net> <200304251020.48678.josh@agliodbs.com> In-Reply-To: <200304251020.48678.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/1337 X-Sequence-Number: 41402 It's a lot of work to write the functions, but it is the best way to keep the db intact. Josh Berkus wrote: > Robert, > > >>You misunderstood. I don't think it's a bug in postgresql, it's a bug in > > the > >>application that is hitting against my database. When it doesn't have a > > value > >>for the timestamp field, it either needs to drop it from the insert statment >>or convert it to null; not send a '' > > > Incidentally, this sort of problem is why most of my apps are based on "push" > data functions. i.e., instead of the client calling: > INSERT INTO foo VALUES ( id, bar1, bar2, bar3 ); > it calls > SELECT df_modify_foo ( id, bar1, bar2, bar3 ); > > Data-push functions allow me to do a whole array of validation and custom > error message return that would be impractical with triggers. It also > allows me to build security checks in to the back-end, via: > > SELECT df_modify_foo ( user_id, session_key, id, bar1, bar2, bar3 ) > > ... allowing me to check all of the following things: > Does the user have a valid session? > Does the user have rights to foo? > Does the user have a lock on foo? > Is this a new foo record, or a modified one? > etc. >