Thread

  1. Re: SQL-level pg_datum_image_equal

    jian he <jian.universality@gmail.com> — 2025-12-20T13:14:46Z

    On Thu, Dec 11, 2025 at 1:46 AM Matthias van de Meent
    <boekewurm+postgres@gmail.com> wrote:
    >
    > Hi,
    >
    
    >
    
    > So, attached is a simple and to-the-point patch that adds the function
    > mentioned in $subject, which will tell the user whether two values of
    > the same type have an exactly equal binary representation, using
    > datum_image_eq.
    >
    
    hi.
    
    maybe Table 9.76
    (https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-INFO-CATALOG)
    is the right place for this function.
    
    corner case confused me, I think this is related to null handling,
    maybe not related to this.
    create type t1 as (a int, b text);
    select pg_datum_image_equal('(,)'::t1, $$(,)$$::t1);
    select pg_datum_image_equal('(,)'::t1, NULL::t1);
    select '(,)'::t1 is null, NULL::t1 is null;
    
    enforce_generic_type_consistency already resolved generic type.
    see
    select pg_datum_image_equal('1','1');
    ERROR:  could not determine polymorphic type because input has type unknown
    
    so
    + if (!OidIsValid(typ))
    + {
    + ereport(ERROR,
    + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
    + errmsg("could not determine type")));
    + }
    this part should be elog(ERROR.....) ?
    
    
    --
    jian
    https://www.enterprisedb.com/