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 1qvoj1-007cXX-Pw for pgsql-general@arkaria.postgresql.org; Thu, 26 Oct 2023 00:59:52 +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 1qvoiz-00AjGl-W9 for pgsql-general@arkaria.postgresql.org; Thu, 26 Oct 2023 00:59:50 +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 1qvoiz-00AjGZ-1M for pgsql-general@lists.postgresql.org; Thu, 26 Oct 2023 00:59:49 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvoiu-002pTv-MQ for pgsql-general@lists.postgresql.org; Thu, 26 Oct 2023 00:59:48 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 812AE5C01DC; Wed, 25 Oct 2023 20:59:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 25 Oct 2023 20:59:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1698281983; x=1698368383; bh=LpEQuNALb/ksfGC/zMT/+R+6o1BHt9IAvqB kerASZG4=; b=gJ7Qh6ObBPJrxZDp/SgKC+GllFcdHJojyF5rD/ZblsDkwMcH5PU YHuaSEwus+cCtWoAyB6IJpmgF5ihzwOeViahqyCxoz0OFe3KWBEf/ogUwrTQ0ne2 S+wilZtumCENEMdk4+gFbXmfayyoRNTqQ6MVbB6GgEb2k7e+aT+uRoNAIh/dzCUj 0Ed8354NQq1QNQUMKxeBLZ3tdvM6HNvO+r3K2uyASxnr7JrFw5v/4J0DTjqEy1fq VQtYRfbrHq8KWOjmQbvl86Lh5ylRNpe4DFreqrLGlCA0OUbnH8pnkvpPYMnnQ40R HzxMcacH4TY8SrZJRkwV1mL7d3ifLfVRIIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1698281983; x=1698368383; bh=LpEQuNALb/ksfGC/zMT/+R+6o1BHt9IAvqB kerASZG4=; b=cYdSkOYu2+LCGeFKUGKgx6/XMoPdB0hrbr67XvBqKwijAj+q/YB 9R09JxiFE64AWC6ScLJjDb7TiY/27iF0cVQBJ8OFfWrlg4cHZA2D0aoYyiYTxpPx c8BsactKyq7cAx46T9lbjlg9lxepfCSyOSMVsrL7dzVTEbuV8kpum2V0NEVhvMSs LvjHABz80NoRFE4arC9yo5L1nWYaJhM2ZNVfAmFQCf4HxGc6DtZLeo7/PBaevn8e 1kUFla92FU0MPrTVn4CQlRlCsS0+8U8pccGTEdhT9m/e9iT8tYL70olCkiwno3rl 7fsxkfY8jd6DzuV505M6+6+3Hp6/DyMtsbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpefgudefkefhveefleevieeuveehvdduudekuddvvdel hfeuueeijedtuedvvedvueenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhi rghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Oct 2023 20:59:42 -0400 (EDT) Message-ID: <9bc42afd-8be3-47f3-aa7d-20bf12ca39de@aklaver.com> Date: Wed, 25 Oct 2023 17:59:41 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Problem with CAST-ing - am I missing something? To: Christophe Pettus , =?UTF-8?B?UMOzbCBVYSBMYW/DrW5lY2g=?= =?UTF-8?Q?=C3=A1in?= Cc: PostgreSQL General References: <3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com> 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 10/25/23 17:26, Christophe Pettus wrote: > > >> On Oct 25, 2023, at 17:21, Pól Ua Laoínecháin wrote: >> >> SELECT (ts, te)::TSTZRANGE FROM test; > > That syntax doesn't mean what you probably think it does. (ts, te) defines a record type with two fields. PostgreSQL constructs that, and then attempts to apply the cast. There's no conversion path from that to TSTZRANGE, so the system complains. It's imaginable, I guess, that such a path could be added, but the right way to do it is what you do here: > >> SELECT TSTZRANGE(ts, te) FROM test; > Or do something like: select '[2023-10-25 14:33:00, 2023-10-25 15:56:00)'::TSTZRANGE; tstzrange ------------------------------------------------------- ["10/25/2023 14:33:00 PDT","10/25/2023 15:56:00 PDT") per: https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-IO > > -- Adrian Klaver adrian.klaver@aklaver.com