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 1iws8T-0001BX-4S for pgsql-general@arkaria.postgresql.org; Wed, 29 Jan 2020 18:32:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iws8R-0004NN-Mh for pgsql-general@arkaria.postgresql.org; Wed, 29 Jan 2020 18:32:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iws8R-0004MI-Cf for pgsql-general@lists.postgresql.org; Wed, 29 Jan 2020 18:32:19 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iws8K-0003Tf-HH for pgsql-general@lists.postgresql.org; Wed, 29 Jan 2020 18:32:18 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id BC14F21AEF; Wed, 29 Jan 2020 13:32:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 29 Jan 2020 13:32:10 -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=P FhBvI1eWL+DXsSsw1ZfPM7I4C6CJBPjdT4r2BFpkF0=; b=cXVLM/Z39NaO31tVV BSzGqWq/aBvShQ7plZz7UR+5s9Oo26RGzjNCvRGLTKwl70mzJY6cydeXM2gFiEjm egKFLqD+w+6P57o9gezHXGXKH0PQDQh7tkZt9s1ogbIZBKkDdUNxSC4z151jayp3 5GbL4EgHwIniU0s0AvQjqK6apzBLY5SSHrfTm8nFF15BPKup9uyDdFGYd6Jb9iiq cOsEkju/Ul2SnUqPB7Z+CgWEXfrD89wPoSXITppLrQ33scuO+0AZKmlzMLALk6qu P6j6CPE2MMxvaryze3cH5Gar3zo7lzzcq5lPRXyeCOoIWgTY16ZXJRDuWWCHcq1Y 59XLQ== 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=PFhBvI1eWL+DXsSsw1ZfPM7I4C6CJBPjdT4r2BFpk F0=; b=sW7mVhd8Sv5BrpTxWicITkWroaxlOYHkNb8gotvvrQrwAra71ROI0B7pr +iu7eEOjAEr7+nGpVbcB7pkSRpa3doz0Hoy7vbWnf5dpfjN5cjTHLgXKD55499oY W/0zWUDTuYxBMahFhH1CuaEu2F44QlqoWOqRFFJ7LdR24ibgXNrEUmrChGARu7MX 8YaFbr130mb2lWHMZ16A9x9K53R01QgK2PpJgaJkJKbV92kjfb8FsjBwoTFpQ4E4 O67IRmlsd/9TQjR7I+zP2Lzih3ZlsL61whw1anyz9uXy+LoqCQLuHeV9pVCRFmof Gw13OUWyvXSPwD2ZfesefvJA2pcaQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrfeeigdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjeegrdelfedruddthedrudekieenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrg hvvghrrdgtohhm X-ME-Proxy: Received: from ranger.suse (74-93-105-186-washington.hfc.comcastbusiness.net [74.93.105.186]) by mail.messagingengine.com (Postfix) with ESMTPA id C0E40306099F; Wed, 29 Jan 2020 13:32:09 -0500 (EST) Subject: Re: Exclude constraint on ranges : commutative containment : allow only complete containment To: Achilleas Mantzios , pgsql-general@lists.postgresql.org References: <3b555944-1563-6614-a5d5-e0cc001aecdb@matrix.gatewaynet.com> From: Adrian Klaver Message-ID: Date: Wed, 29 Jan 2020 10:32:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <3b555944-1563-6614-a5d5-e0cc001aecdb@matrix.gatewaynet.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/29/20 8:12 AM, Achilleas Mantzios wrote: > Hello Dear Postgresql ppl, > I have a table with date ranges and need to express the following > constraint : allow overlaps only if there is complete containment, e.g. > allow values in rows like : > [2020-01-01,2020-01-31) > [2020-01-02,2020-01-10) > [2020-01-10,2020-01-20) > > but disallow rows like > > [2020-01-02,2020-01-10) > [2020-01-08,2020-01-11) I'm missing something. Can you provide a more complete example? > > I think that writing a new commutative range operator e.g. |<@@> which > would return true if the left operand is either contained by or contains > the right operand and false otherwise would solve this, I am just > wondering if there is a more elegant and economical way to express this. > (besides writing a trigger which is always an option).| > > -- > Achilleas Mantzios > IT DEV Lead > IT DEPT > Dynacom Tankers Mgmt > -- Adrian Klaver adrian.klaver@aklaver.com