Re: range of composite types!

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jian He <hejian(dot)mark(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: range of composite types!
Date: 2022-04-27 05:29:28
Message-ID: CAKFQuwbwfvohRwSAn9WEUCBnRHeqPt8vWXubY4kVJ2XLoMQNHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tuesday, April 26, 2022, Jian He <hejian(dot)mark(at)gmail(dot)com> wrote:

>
> -- composite type range.
>> create type mytype as (t1 int, t2 date);
>> -- create type my_interval as (t1 int, t2 interval);
>> select (2,'2022-01-02')::mytype ;
>> create type mytyperange as range(subtype = mytype);
>>
>
> I am thinking construct a composite type range that would be equivalent
> as:
>
>> select a, b::datefrom generate_series(1,8) a,
>> generate_series('2022-01-01'::timestamp,
>> '2022-01-31'::timestamp, interval '1 day') b;
>>
>> Ranges have to be ordered. How do you propose to order the above?
Composite type comparisons have defined ordering semantics. Your results
demonstrate what those are (namely, subsequent fields are used only to
break ties). If you want different behavior you will have to code it
yourself - possibly including ignoring the generic composite type
infrastructure and make a formal base type of whatever it is you need.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2022-04-27 09:32:07 Re: "create function... depends on extension..." not supported. Why?
Previous Message Tom Lane 2022-04-27 05:26:00 Re: Fwd: range of composite types!

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-04-27 05:31:55 Re: Possible corruption by CreateRestartPoint at promotion
Previous Message Michael Paquier 2022-04-27 05:27:00 Re: Possible corruption by CreateRestartPoint at promotion