Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 470A664FCE9 for ; Wed, 12 Nov 2008 00:06:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 56694-04 for ; Wed, 12 Nov 2008 00:06:10 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.191]) by mail.postgresql.org (Postfix) with ESMTP id 22B3A64FCD8 for ; Wed, 12 Nov 2008 00:06:09 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id e30so234463fke.3 for ; Tue, 11 Nov 2008 20:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=LNNlFTYPhBBQmQ4rsXFs9utq9rSvzl8awyul/gNkuno=; b=lFNenggknc9dtS7bmwk8K22p79N+aL6KOE4MLJaFE4OKacudzxu4C0z42dbAfVN9gz uwSljXkPZD3Y4F82wsnjx2TKlumW3TvsoCAQe7/jb3mkeu6z/Nk5iCOfaGeKjJnWNJBz xC35KH7yGnYagB6w1MfVZU8/heJ9CEWlpYsco= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Iwg7C42WPBmZFzFyi6ePCYAFZc+GrDtGSAtjpoYVo6Nl53L0X1XKTYgdBny7EzfogE G5/Q6L/sRL9ZlePlVO1xjnRk+wiaTsWLBaCXYkQxEdO6jqXpr7FjHTG/pPD94KqGSyed nx7RUxS4T+1xmQbT22p2B3hGR5amF3r9EAZEQ= Received: by 10.187.195.7 with SMTP id x7mr3090411fap.45.1226462769056; Tue, 11 Nov 2008 20:06:09 -0800 (PST) Received: by 10.187.165.7 with HTTP; Tue, 11 Nov 2008 20:06:08 -0800 (PST) Message-ID: <603c8f070811112006q906b3a6o59a66228b7fc997@mail.gmail.com> Date: Tue, 11 Nov 2008 23:06:08 -0500 From: "Robert Haas" To: "Bernd Helmle" Subject: Re: WIP: Automatic view update rules Cc: pgsql-hackers@postgresql.org In-Reply-To: <94CF655A8D0DC7D5B4B81D8B@imhotep.credativ.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2849137C693B65CC8E86411C@imhotep.credativ.de> <94CF655A8D0DC7D5B4B81D8B@imhotep.credativ.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/838 X-Sequence-Number: 127550 I haven't done a full review of this patch, but here are some thoughts based on a quick read-through: - "make check" fails 16 of 118 tests for me with this patch applied. - There are some unnecessary hunks in this diff. For example, some of the gram.y changes appear to move curly braces around, adjust spacing, and replace true and false with TRUE and FALSE (I'm not 100% sure that the last of these isn't substantive... but I hope it's not). The changes to rewriteDefine.c contain some commented-out declarations that need to be cleaned up, and at least one place where a blank line has been added. - The doc changes for ev_kind describe 'e' as meaning "rule was created by user", which confused me because why would you pick "e" for that? Then I realized that "e" was probably intended to mean "explicit"; it would probably be good to work that word into the documentation of that value somehow. - Should this be an optional behavior? What if I don't WANT my view to be updateable? - I am wondering if the old_tup_is_implicit variable started off its life as a boolean and morphed into a char. It seems misnamed, now, at any rate. - The capitalization of deleteImplicitRulesOnEvent is inconsistent with the functions that immediately precede it in rewriteRemove.h. I think the "d" should be capitalized. checkTree() also uses this style of capitalization, which I haven't seen elsewhere in the source tree. - This: rhaas=# create table baz (a integer, b integer); CREATE TABLE rhaas=# create or replace view bar as select * from baz; NOTICE: CREATE VIEW will create implicit INSERT/UPDATE/DELETE rules CREATE VIEW Generates this update rule: ON UPDATE TO bar DO INSTEAD UPDATE ONLY foo SET a = new.a, b = new.b WHERE CASE WHEN old.a IS NOT NULL THEN old.a = foo.a ELSE foo.a IS NULL END AND CASE WHEN old.b IS NOT NULL THEN old.b = foo.b ELSE foo.b IS NULL END RETURNING new.a, new.b It seems like this could be simplified using IS NOT DISTINCT FROM. ...Robert