Re: SQL:2011 Application Time Update & Delete

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: SQL:2011 Application Time Update & Delete
Date: 2026-01-19 18:33:02
Message-ID: CA+renyWKOj5=rMmQmJcbybu-Vdomxdp=eJ93kp76AgmQKYdfiQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 19, 2026 at 5:37 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> I tuned the naming again in the new patch. I changed "constr" to
> "construct" because "constr" read too much like "constraint" to me. I
> also did a bit of "mtlrng". I think it's a bit more consistent and less
> ambiguous now.

I agree that seems like an improvement.

> > It's tempting to use two oidvectors, one for range constructors and
> > another for multirange, with the 0-arg constructor in position 0,
> > 1-arg in position 1, etc. We could use InvalidOid to say there is no
> > such constructor. So we would have rngconstr of `{0,0,123,456}` and
> > mltrngconstr of `{123,456,789}`. But is it better to avoid varlena
> > columns if we can?
>
> I don't think oidvectors would be appropriate here. These are for when
> you have a group of values that you need together, like for function
> arguments. But here we want to access them separately. And it would
> create a lot of notational and a bit of storage overhead.

Okay.

> > Is there a reason you're adding them in the middle of the struct? It
> > doesn't help with packing.
>
> Well, initially I had done that so that the edits to pg_range.dat are
> easier. But I think this order makes some sense, because it has the
> mandatory data first and then the optional data later. But it doesn't
> matter much either way.

Okay. And ABI compatibility is only between minor versions, so no concern there.

> > This needs some kind of pg_upgrade support I assume? It will have to
> > work for user-defined rangetypes too.
>
> No, I don't think there needs to be pg_upgrade support. Existing range
> types are dumped as CREATE TYPE ... RANGE commands, and when those get
> restored it will create the new catalog entries.

Okay, that's great!

Do we want a regress test in rangetypes.sql to confirm that these are
set correctly (especially for user-defined types)? I checked manually
after `make installcheck`, and they look fine, but should it be in our
test suite?

Here is another thought I had: As we've talked about in the
application-time threads, I would like temporal features to be
extensible enough to support user-defined types. We almost achieve
that, but we need something like a "type support function". For primary
key and unique constraints, we need a way to reject invalid values like
empty ranges. For foreign keys we need an intersect operator (which is
not currently in pg_amop, since it is neither for search nor ordering,
and isn't involved in indexes anyway). And for UPDATE/DELETE FOR
PORTION OF we need a foo_minus_multi to compute the "temporal
leftovers".

We could also ask for a constructor function, to build the targeted
portion from the FROM/TO bounds. This is not strictly necessary, since
we also have the FOR PORTION OF valid_at (...) syntax (which is used by
multiranges). But it's something that would be nice to offer. In that
case range types would not need these extra columns in pg_range.

But recording the constructor oids in pg_range still has inherent
value, and doing it now doesn't *prevent* us from later adding a
facility to get a constructor function for FOR PORTION OF bounds. So I
don't think there is any downside to recording them here.

Yours,

--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-01-19 18:56:49 Re: 001_password.pl fails with --without-readline
Previous Message Robert Haas 2026-01-19 18:02:27 Re: Enhancing Memory Context Statistics Reporting