From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Christophe Pettus <xof@thebuild.com>
To: Pól Ua Laoínecháin <linehanp@tcd.ie>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Problem with CAST-ing - am I missing something?
Date: Wed, 25 Oct 2023 17:59:41 -0700
Message-ID: <9bc42afd-8be3-47f3-aa7d-20bf12ca39de@aklaver.com> (raw)
In-Reply-To: <3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com>
References: <CAF4RT5QB7EY2SzeXBUdF9nB_ZPdMD0bab7zRZo4LqLVk=XWQEQ@mail.gmail.com>
<3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com>
On 10/25/23 17:26, Christophe Pettus wrote:
>
>
>> On Oct 25, 2023, at 17:21, Pól Ua Laoínecháin <linehanp@tcd.ie> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, xof@thebuild.com, linehanp@tcd.ie
Subject: Re: Problem with CAST-ing - am I missing something?
In-Reply-To: <9bc42afd-8be3-47f3-aa7d-20bf12ca39de@aklaver.com>
References: <CAF4RT5QB7EY2SzeXBUdF9nB_ZPdMD0bab7zRZo4LqLVk=XWQEQ@mail.gmail.com> <3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com> <9bc42afd-8be3-47f3-aa7d-20bf12ca39de@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox