Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rMulR-007dVz-3i for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2024 18:54:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rMulP-0074CJ-MO for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2024 18:54:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rMulP-0074CB-9S for pgsql-hackers@lists.postgresql.org; Mon, 08 Jan 2024 18:54:19 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rMulM-000WP3-GI for pgsql-hackers@lists.postgresql.org; Mon, 08 Jan 2024 18:54:18 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d3e6c86868so18828995ad.1 for ; Mon, 08 Jan 2024 10:54:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20230601.gappssmtp.com; s=20230601; t=1704740054; x=1705344854; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CeUFFwikszbsc4TmWnSPDBzfxG50jdO7JNbvT03O2IY=; b=iaZGBJafxR12bDb6I4uV+YhJAARHDo8Q++K69crurYLuW4eF0o7is/9Rme5PMkYdKO Da7xC1r9zK9so93I7p8BijIZTlCVdFNhfTpWP4km7J5ZWFmr8/3eD8Vfq/QgKuPWc0/X tF1hqV+zGGJal9m/+5S5Puz6Qe62eRPoE5cQbAe+/CxCS8SIRP6BUIknhtI4UvpDGckl iAhGKF+kxHbTbwxXDE7wuYG81/hdf23eZCLprgm+GUosMUD0qv6qCNKLoPVtMSSq6NqC GblXE9I4PO/d4AEioHoSHpAgBr4Zlj8kHz6jI6/UaYzlYBdhK2pT2MBccnvUvJQMNEP3 ZTuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704740054; x=1705344854; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CeUFFwikszbsc4TmWnSPDBzfxG50jdO7JNbvT03O2IY=; b=S3k4gCBS8zd5MM57sTinkt6oWVPY/MNgtPzjcCZK7OQ9FJp3W08YT0xCZ5vRPMUwI0 lx0KLllIDLCDiSfe69/BjOjlN+kgl0z0rTYhWDFXjcaXTatOrpUIVUEJhmrqEQpFT1S6 CtkYH8Ibe2T2qVUe4+lHENsUTFC0NzvzJxklYX5t9g0hCGNnALLr3FUd61xepESi/Cg0 hydfiqSxpbyFGOCGUqORzwTCtLcJWeUakLRlQK5ZrMep70DowVn1TtsF6OqKYPGnBcfs aa8ETKkE+4Wxm+LN0V0fC/Yk/HXSR8Xn6SiElWdu1+t4jNuX3K7Ny18ZTruCH1nuTYAX 2G3w== X-Gm-Message-State: AOJu0YzNg6WXSw4ZfkrJYN2MlySbzv1uyJGJ+p7Y//XuJTXH7fuWdeff 0MEd4aD/kvWoAUkO2GGhvtLXWnFbIld7Ng== X-Google-Smtp-Source: AGHT+IGEWbgXHVt6DTh6AR1kCsFER1bvrybSaYUgtwGlrFuwNuNPGW9JI7rfHBgF6Oary+4kb+LaeA== X-Received: by 2002:a17:90a:d315:b0:28c:bd2c:b3b7 with SMTP id p21-20020a17090ad31500b0028cbd2cb3b7mr2217578pju.54.1704740054309; Mon, 08 Jan 2024 10:54:14 -0800 (PST) Received: from [192.168.2.139] ([50.53.98.191]) by smtp.googlemail.com with ESMTPSA id gf4-20020a17090ac7c400b0028cd463b4a7sm6712655pjb.46.2024.01.08.10.54.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jan 2024 10:54:13 -0800 (PST) Message-ID: Date: Mon, 8 Jan 2024 10:54:13 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time Content-Language: en-US To: jian he Cc: Peter Eisentraut , PostgreSQL Hackers References: <2d9740ad-3bb7-473c-8441-344351caa8ee@illuminatedcomputing.com> <596fefdd-6202-4228-b7c6-f240b1cbe06e@eisentraut.org> <35400587-6865-4a2c-9ea4-4761669478ea@eisentraut.org> <71b45adb-b496-4e58-b134-0a091014e63f@illuminatedcomputing.com> <159ba553-43c7-4557-bf05-74447cc6013b@illuminatedcomputing.com> From: Paul Jungwirth In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/8/24 06:54, jian he wrote: > On Fri, Jan 5, 2024 at 1:06 PM jian he wrote: > > range_intersect returns the intersection of two ranges. > I think here we are doing the opposite. > names the main SQL function "range_not_intersect" and the internal > function as "range_not_intersect_internal" should be fine. > so people don't need to understand the meaning of "portion". Thank you for helping me figure out a name here! I realize that can be a bike-sheddy kind of discussion, so let me share some of my principles. Range and multirange are highly mathematically "pure", and that's something I value in them. It makes them more general-purpose, less encumbered by edge cases, easier to combine, and easier to reason about. Preserving that close connection to math is a big goal. What I've called `without_portion` is (like) a closed form of minus (hence `@-` for the operator). Minus isn't closed under everything (e.g. ranges), so `without_portion` adds arrays---much as to close subtraction we add negative numbers and to close division we add rationals). We get the same effect from multiranges, but that only buys us range support. It would be awesome to support arbitrary types: ranges, multiranges, mdranges, boxes, polygons, inets, etc., so I think an array is the way to go here. And then each array element is a "leftover". What do we call a closed form of minus that returns arrays? Using "not" suggests a function that returns true/false, but `@-` returns an array of things. So instead of "not" let's consider "complement". I think that's what you're expressing re intersection. But `@-` is not the same as the complement of intersection. For one thing, `@-` is not commutative. `old_range @- target_portion` is not the same as `target_portion @- old_range`. But `complement(old_range * target_portion)` *is* the same as `complement(target_portion * old_range)`. Or from another angle: it's true that `old_range @- target_portion = old_range @- (old_range * target_portion)`, but the intersection isn't "doing" anything here. It's true that intersection and minus both "reduce" what you put in, but minus is more accurate. So I think we want a name that captures that idea of "minus". Both "not" and "intersection" are misleading IMO. Of course "minus" is already taken (and you wouldn't expect it to return arrays anyway), which is why I'm thinking about names like "without" or "except". Or maybe "multi-minus". I still think "without portion" is the closest to capturing everything above (and avoids ambiguity with other SQL operations). And the "portion" ties the operator to `FOR PORTION OF`, which is its purpose. But I wouldn't be surprised if there were something better. Yours, -- Paul ~{:-) pj@illuminatedcomputing.com