Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWMw2-0004cC-CA for pgsql-general@arkaria.postgresql.org; Wed, 06 May 2020 16:30:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jWMw1-0004Kb-95 for pgsql-general@arkaria.postgresql.org; Wed, 06 May 2020 16:30:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWMw1-0004JB-1C for pgsql-general@lists.postgresql.org; Wed, 06 May 2020 16:30:13 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWMvy-000647-CK for pgsql-general@postgresql.org; Wed, 06 May 2020 16:30:12 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DC8385C00E8; Wed, 6 May 2020 12:30:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 06 May 2020 12:30:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=k vWfDysA9rNeuiwYlivRITisRDLOUROq6xnCPfBNEKQ=; b=rtab0NpwV7scnjX+t 9cqKuoxZuR+KpwqivE4uPfp1pR65OgdV7qD7v3dOBt8ElKkvVdfehrGz1TkEJg+W //4aunIpco49+qYkhpOxjIVdxAhVHKmh7z8wzFj3BoR7cYtiLbW1QqxhOuf6MjYf cmbvyJKsxnorpeq66gV4SXpoZL1VJrnaZh4ev9UQbU6hxFj9mFyqT5zI4ezgmUi/ Yg773KWRosckfDTpmGxcvgOWBLxvk6I42Z9pf/pcDRB/QjbZeqkfV+0QG2+Euqpv Zi9lnZfM7DC+bkU5Uu/z+m9+Tkf6lssAYSFC+c54chzqA4zQxUqgheINEbyQ/0YW qQ0ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; bh=kvWfDysA9rNeuiwYlivRITisRDLOUROq6xnCPfBNE KQ=; b=oz+2v078zcujPtpSPngBXYpdwgrDqoBA/FXsc5XuPL4i5c3R69l2ypw8H oSSfE15HfF/N5Tb3qKLX1KN5N5+L+ccTKxJglraFCcedgKOZKpPNQf24sF7wtQlO FqS7zzlLeHK4RpUQ3LUNroSpLRXBOCnm609lnSRk0AEgXCMSpxq4wtaUL2oPqA97 atbgmtmjlnhdJz36FjbDRXJkAoVvCvBNv04dl+6Us9T4yHgC4DA+d7nK9H/8+iyi +eMxabwvfnVgu3sR4A/3JRAl0gDT6ttwyLaBaJrjcrM5iOFCX/KhukFNwnE4Wppx qKTDmiTok9UuKfFBhq3rLX6Vwokrw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrjeekgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepveetjedtieekteefhffhhfetledvkeffvedugeejueek hffgvdeileeitdekvefhnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenuc fkphepjeehrddujedvrdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 35E1E328006C; Wed, 6 May 2020 12:30:08 -0400 (EDT) Subject: Re: White space affecting parsing of range values To: Thom Brown Cc: PGSQL Mailing List References: <597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com> From: Adrian Klaver Message-ID: Date: Wed, 6 May 2020 09:30:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: 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 5/6/20 9:19 AM, Thom Brown wrote: > On Wed, 6 May 2020 at 17:13, Adrian Klaver wrote: >> >> On 5/6/20 9:00 AM, Thom Brown wrote: >>> Hi, >>> >>> I noticed I'm getting an error when adding white space to a numeric >>> range. I can run this: >>> >>> postgres=# SELECT 5::numeric <@ '(,10]'::numrange; >>> ?column? >>> ---------- >>> t >>> (1 row) >>> >>> But I can't run this: >>> >>> postgres=# SELECT 5::numeric <@ '( ,10]'::numrange; >>> ERROR: invalid input syntax for type numeric: " " >>> LINE 1: SELECT 5::numeric <@ '( ,10]'::numrange; >>> ^ >>> If one had constructed a series of ranges, and wanted to line them up >>> vertically for easy comprehension, this wouldn't be possible. >>> >>> This doesn't seem to be a problem with regular numeric values: >>> >>> postgres=# SELECT ' 3 '::numeric; >>> numeric >>> --------- >>> 3 >>> (1 row) >>> >>> >>> Shouldn't white space be ignored in range values? >>> >> >> https://www.postgresql.org/docs/12/rangetypes.html >> >> "Whitespace is allowed before and after the range value, but any >> whitespace between the parentheses or brackets is taken as part of the >> lower or upper bound value. (Depending on the element type, it might or >> might not be significant.) >> " > > I guess I should read the docs more carefully. Shouldn't this be > insignificant for a numeric value? No: select ' '::numeric; ERROR: invalid input syntax for type numeric: " " LINE 1: select ' '::numeric; > >> SELECT 5::numeric <@ '(00,10]'::numrange; >> ?column? >> ---------- >> t > > Your example isn't equivalent to mine. That sets a lower bound. SELECT 5::numeric <@ numrange(NULL ,10, '(]'); ?column? ---------- t From previous link: "-- Using NULL for either bound causes the range to be unbounded on that side. SELECT numrange(NULL, 2.2);" > > Thom > -- Adrian Klaver adrian.klaver@aklaver.com