Re: SQL-level pg_datum_image_equal

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: solai v <solai(dot)cdac(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <dgrowleyml(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: SQL-level pg_datum_image_equal
Date: 2026-08-12 16:36:53
Message-ID: CAEze2Wii2ME7hq30Cur9zLAtJ4=0FXQ9bF73v-aHF4VGMk7iGQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 10 Aug 2026 at 14:39, solai v <solai(dot)cdac(at)gmail(dot)com> wrote:
>
> Hi all,
>
>
> On Mon, Aug 10, 2026 at 12:32 PM Matthias van de Meent
> <boekewurm+postgres(at)gmail(dot)com> wrote:
> >
> > Here's version 3 of the patch, which is no more than a rebase.
> >
> > Kind regards,
> >
> > Matthias van de Meent
> > Databricks (https://www.databricks.com)
> >
> > p.s. The upthread issues with datum_image_*() have been resolved in 0d866282b8.
>
>
> I reviewed and tested the v3 patch. I like the idea of exposing the
> existing datum_image_eq() functionality through a SQL-level function,
> pg_datum_image_equal(anyelement, anyelement). I think this can be
> useful, especially for synchronization/update scenarios where we need
> to check whether two values have the same datum representation and
> potentially avoid unnecessary work. So, +1 from my side for
> introducing this function.

Thanks!

> But I do have a couple of suggestions that may make the patch even stronger:
> 1. Add behavioral regression tests

I've added some compare operations in the regression tests. I did not
add the MATERIALIZED test, because that was more a bug in the
underlying code than an issue this patch specifically.

> 2. Slightly expand the documentation - It may be useful to explicitly
> mention that pg_datum_image_equal() is different from the normal SQL
> equality operator. For example, 1.0::numeric and 1.00::numeric compare
> equal using =, but their datum images are different and the new
> function returns false.

I think the example in the functions table already made this clear. I
think adding further explanation on this function's workings would be
excessive.

> It may also be worth documenting the NULL
> behavior, since two NULL arguments return true.

I've added a NULL-example in the attached patch.

Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)

Attachment Content-Type Size
v4-0001-Add-SQL-level-datum-equality-tests.patch application/octet-stream 8.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-08-12 17:05:36 Re: Introduce psystem() to replace system()
Previous Message Mariyan Clement S 2026-08-12 16:28:14 Proposal: Richer Structured Export Support for COPY TO