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 1qyI1F-007P7u-Ia for pgsql-docs@arkaria.postgresql.org; Wed, 01 Nov 2023 20:40:53 +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 1qyI1D-008otJ-JJ for pgsql-docs@arkaria.postgresql.org; Wed, 01 Nov 2023 20:40:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qyI1D-008otB-Bs for pgsql-docs@lists.postgresql.org; Wed, 01 Nov 2023 20:40:51 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qyI18-003Uzm-45 for pgsql-docs@lists.postgresql.org; Wed, 01 Nov 2023 20:40:50 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4083f61322fso1579875e9.1 for ; Wed, 01 Nov 2023 13:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1698871244; x=1699476044; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=kVB2oW/bApNda+tbscwQD6y72NFJbe1lKtlPjuzrWCQ=; b=jLbWt3HTdVdgSIkZK2DebZgz97IK503R1wI3tqDpZf043ny6AJzWWw57vwK+qLNuVG 3KsBfuVe002+9539DcHmwCbiQI5c8YfL4Frc68UiTnVNAgLvpPEuUUla5WyAlXRjOvgz CpROHM3nR3IZ2wArjlxyQPLRiF0Cm6NxIR/yduax3knGOAFXkKXJtfeSlfjTwzWnHiVd MeUV9NJRpWSNbzecRdrVgOYpjIfcZGOSH8e8A/KdWZ6RG4t0SYQZKn05yzmdfC/cliHA Q3MR7ZQ4izdfTyajz+hBZDUFVBwSrQeDOFNS2AGHjYpSA6x1qUeu5wZLrpcR7R8tziHu 6Jcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698871244; x=1699476044; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kVB2oW/bApNda+tbscwQD6y72NFJbe1lKtlPjuzrWCQ=; b=sj4mhetog0933UmanDlkv4uZtO4x4QanqsbQ2P5mGNVzcKxwHYl+OxYP1glLiCCnVL KTw4eXkCBsH334+I0Aw8waSkZx3ZIcS1P0bYvmunAmkaryqG3S2u09q48edgY1PqF04H 3YZx4LNiIf1HYTQ1bOA4l3sZzxMhRYMw5BZshXyZdlJo8sPWQPSFFpUh3Y3PCXLqo6No zlSh6E5NavzW/Yxi8glWoNAZ8PLaYa8Hq/SxY0SYb9zOtslPLCgJxNgrLXqkWKLyza0O MsV2xAhHeUm0pWVrXZehU7ACHg/H1Q3IrryKL/4xVLasXHAs7B0Wke+RgtQ3940vIUj+ cQQA== X-Gm-Message-State: AOJu0YypYLbllbmRyWyzovEFv9oVa6c9vauu8h1mbP/PRzPfmrE1k1pg bsSbMYyGP8H8F4dBowsKSUFvIw== X-Google-Smtp-Source: AGHT+IHwrksretXC5xP6zzXsBzeWsxr8/sjrC8x58vJRCARKnypIzUSQltlk/QgJM4rznKl1o1c1Ww== X-Received: by 2002:a05:600c:3595:b0:409:8e0:69f4 with SMTP id p21-20020a05600c359500b0040908e069f4mr14374756wmq.21.1698871244221; Wed, 01 Nov 2023 13:40:44 -0700 (PDT) Received: from localhost.localdomain ([2001:871:260:b539:1410:61d3:4510:7322]) by smtp.gmail.com with ESMTPSA id n4-20020a05600c3b8400b003fe61c33df5sm777150wms.3.2023.11.01.13.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 13:40:44 -0700 (PDT) Message-ID: Subject: Re: Documentation of return values of range functions lower and upper From: Laurenz Albe To: Bruce Momjian Cc: Fujii Masao , jani.rahkola@iki.fi, pgsql-docs@lists.postgresql.org Date: Wed, 01 Nov 2023 21:40:43 +0100 In-Reply-To: References: <160508672127.25505.8356390205508789564@wrigleys.postgresql.org> <53ec9f116bea9252d7fa9341e024530553656c42.camel@cybertec.at> <16601466752e40543051369fac722c0a200bb4e6.camel@cybertec.at> <27d690d8-0987-5f2b-a2da-fc2ec7c19e3c@oss.nttdata.com> <02f3fa3a592fa6c1f8ec1a9f539ae376f744eb42.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2023-11-01 at 16:28 -0400, Bruce Momjian wrote: > On Wed, Nov 18, 2020 at 05:28:44PM +0100, Laurenz Albe wrote: > > On Wed, 2020-11-18 at 22:49 +0900, Fujii Masao wrote: > > > On 2020/11/12 17:14, Laurenz Albe wrote: > > > > On Wed, 2020-11-11 at 18:19 +0100, Laurenz Albe wrote: > > > > > > Table 9.54 in page > > > > > > https://www.postgresql.org/docs/current/functions-range.html st= ates that the > > > > > > functions lower and upper return NULL if the requested bound is= infinite. If > > > > > > the element type of the range contains the special values infin= ity and > > > > > > -infinity, this is not correct, as those values are returned if= explicitly > > > > > > used as either bound. > > > > > +1 > > > > > Perhaps it would be better to say > > > > > NULL if the range is empty or has no lower/upper bound > > >=20 > > > I agree this description looks a bit confusing. But according to the = section > > > "Infinite (Unbounded) Ranges" (*1), we already call "lower/upper boun= d > > > omitted" just infinite. So I don't think the current description is i= ncorrect. > > >=20 > > > (*1) > > > https://www.postgresql.org/docs/devel/rangetypes.html#RANGETYPES-INFI= NITE > >=20 > > That is correct, but I'd argue that it would be better to clarify the p= aragraph too, > > in particular: > >=20 > > The functions lower_inf and upper_inf test for infinite lower and upp= er bounds of a range, respectively. > >=20 > > should better read > >=20 > > The functions lower_inf and upper_inf test for omitted lower and uppe= r bounds of a range, respectively. > >=20 > > The rest of the paragraph is pretty unambiguous. > >=20 > >=20 > > Independent of this, I think that my patch for "upper" and "lower" woul= d make the > > documentation clearer. >=20 > Yes, I agree this documentation needs help. >=20 > For upper/lower(), it is clear that the documentation is better saying > "unspecified" rather than infinite. The fact that upper/lower_inf() > returns false for +/-Infinity is quite odd, but should at least be > documented. >=20 > Patch attached. It is odd that +Infinity (vs. Infinity) wasn't > supported for datetime input until PG 16, but I think we have to say > +/-infinity vs (blank)/-Infinity. >=20 > Patch attached. I am unhappy with "unspecified". A NULL value as upper or lower bound has = a very specific meaning, namely that the range is unbounded in that direction. Th= is is a bit confusing, since NULL is typically used for unknown or undefined valu= es. I think it would be better to say "returns NULL if the range is empty or un= bounded" and "is the range unbounded on the upper end?". Yours, Laurenz Albe