Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1isrOb-00070a-Se for pgsql-general@arkaria.postgresql.org; Sat, 18 Jan 2020 16:56:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1isrOa-0002NI-MJ for pgsql-general@arkaria.postgresql.org; Sat, 18 Jan 2020 16:56:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1isrOY-00026c-Q9 for pgsql-general@lists.postgresql.org; Sat, 18 Jan 2020 16:56:24 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1isrOV-0004Vo-2H for pgsql-general@lists.postgresql.org; Sat, 18 Jan 2020 16:56:21 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 18B0121B01; Sat, 18 Jan 2020 11:56:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 18 Jan 2020 11:56:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=X 36koUiQhEz3UA9Vtm/Inm/GgQ7tvk6x6psaK4KUvUY=; b=qYTrFW9OBKbYPhyQD veAEeyVi6O/B3/oXGEilKgnWLWTrFuQm77PyOvfNd/kIRJmlK9ryAQGg/sId57NB cBvUWdvnD1dm9d+VHSNDr3Np13D0tSiKm4ihE9fwX8RBpE244Pr2VG8UOWWVwQLc rs07pLredVz7nWU38WdUB8Rv2pGDDVOmiQcgumqs0Gn2yKQ9f2v+08S9quTBD+ws 3NOU1gp9VVnHyivgNBRUikzld+G3a2h+/l5tnCtLtKCUk8xww1JyJjQCzQ356Uc+ 7+6fgzSeCh8hSya8/3GTmWkEp9ROk8f0UzyJtBmZsvuy85EBxhMLY1MrUMjRpVAc /NTiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=X36koUiQhEz3UA9Vtm/Inm/GgQ7tvk6x6psaK4KUv UY=; b=N6McLl45u8E+BXTMfY+m9vb1d+fKkgaf7uYxc3LNhaAkwa4XZd1ILRWhe QZ5SIF1WZs9qV/Scfp/hbYix71H/cicdyFD+y2Gw6TfHb4lKH8my2Uam1OW1v6H6 c3FfGsz+X+/Fr4lCZApE01NtLSvCWB1mnAoDJS8k1S7WqrdRyR3aGQzsYV9u7Idu Jt8eVneTyCiplsPxLmBhJkfDtHKGEL+4pzqO/dh1PCFJ9spjlSIrV9yE81qtvYKC 9htzDbA+aP3fT1z+e/tvLmfoMjFabcyoZIhCOG09HavfNBjBUjTGfjTHI3lsUQXE Hmo0yEZtZcKC8k6e7Nl87DFrdzD0Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthejre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucfkphepjedurddvuddvrdduvdelrddule efnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhl rghvvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 6FB0A30608E5; Sat, 18 Jan 2020 11:56:07 -0500 (EST) Subject: Re: A question about rules To: stan , pgsql-general@lists.postgresql.org References: <20200118165325.GB21472@panix.com> From: Adrian Klaver Message-ID: Date: Sat, 18 Jan 2020 08:56:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200118165325.GB21472@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/18/20 8:53 AM, stan wrote: > So, I just discovered the rules system. As I understand it, it can be used > to rewrite queries before they are passed to the query processor. > > I was wondering if I could use this to resolve a long standing frustration > of mine. I often need to declare a column as NON NULL, and create a > trigger/function to auto populate it with something more complex than a > simple sequence. This need arises fairly often for me, and I would like to > come up with a good way to implement this. Stay away from rules, they will only drive you to distraction. Stick with triggers they are a lot easier to understand and implement. > > Sorry for such a newbie question. > -- Adrian Klaver adrian.klaver@aklaver.com