Re: Problem with CAST-ing - am I missing something?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Problem with CAST-ing - am I missing something?
Date: 2023-10-26 00:26:40
Message-ID: 3E465C5A-D794-41B2-B481-DDACC10B41DD@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Oct 25, 2023, at 17:21, Pól Ua Laoínecháin <linehanp(at)tcd(dot)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;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-10-26 00:59:41 Re: Problem with CAST-ing - am I missing something?
Previous Message Pól Ua Laoínecháin 2023-10-26 00:22:48 Re: Problem with CAST-ing - am I missing something?