Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uaCDX-000lXJ-Cj for pgsql-general@arkaria.postgresql.org; Fri, 11 Jul 2025 11:47:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uaCDU-004LEP-4Z for pgsql-general@arkaria.postgresql.org; Fri, 11 Jul 2025 11:47:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uaCDT-004LEG-KY for pgsql-general@lists.postgresql.org; Fri, 11 Jul 2025 11:47:00 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uaCDR-00713I-36 for pgsql-general@postgresql.org; Fri, 11 Jul 2025 11:46:59 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-40b859461easo1027777b6e.1 for ; Fri, 11 Jul 2025 04:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752234416; x=1752839216; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=voi9EfR9+22Aj6HOHjGFNlCF0MHZTH7MxroR+PTiji8=; b=RACaeyE0PaPjzIubfsWhw+OunIn5BqdZMyy4xOaIKRtArZ6Jxhjxt7TsmuP79MlHaF XNa9JhbWu7+oQBVU48aMMXRqArnRrdcMBOMjkmiSuxvKcOkCuvAJC7owiEKChMfaNXTQ A9CYeO6YU5V547Gs4h5SHl8MnjuvmmCJbDR7Dxn0DH/Jx8BzZItQXaADb9t86PmQK7Uj qIRS5A9rZUSwGGJ/GGBZ1mrSPqwarKPqATxLwvgszrcAzeVBMgYqK3VXxM6H2kZSWLNR LB93Iapr0BP1JM3YcNn/Zff7gue8E4dLaVlwqqiux/zlf/xHITL5sWDZZk4750RGCTwh kglA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752234416; x=1752839216; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=voi9EfR9+22Aj6HOHjGFNlCF0MHZTH7MxroR+PTiji8=; b=vdxT2PnZ0Gi50j/kJaAD0VTWkurNrNgX2GgWV1/2gMRdMFyQkn3fP7j2YT1QDavCU1 Drfiw4xuUw9d4d1rawDWMDAkHuvLClJD4516ezwyVM3xZzUAWUO0H2uwmLJZwcjUeZQ+ Nv55WZoX7gXlXDiK6StGpVFoc34zcrRdrBXk2Bw2GmiGQdk/GlZzYioCwYHfiM6CUDs2 cDXZBHn9TTTec7ycw8yc2WbLc/hgKOxIQAqW3C4PZDcnlWSpMomVjCwRgRniJ9fDR9g9 dpPK2/qUohrC3fdn+CBFJE5CKs4pOkKUTe86HfLNpEnxx1AnSCP7vCi4GKo4fT+X7Cnj KcnA== X-Gm-Message-State: AOJu0YxrQ6EBtTHfN/WLVz7b+k89og7QbnuhFkn3hcYb6afHaLhAg3zq 2JWN3nuzU931QXzv4t2UKLnQ6hKKgBW8YmakDsg7abYoPXhCCTbEuIsUEFCkIk3t8hilgoqeRj9 B+teKVvZ1siYsg7sYX+ohgrD1xnWG6YM5iw== X-Gm-Gg: ASbGncsHr7paqz6WJRixTP51PUCPAsMrFvZsb8wwr4gMohWkiDmiBpTE3EDgnZh80Et /+Jwepk2LhRsjMedyH1Tl7/O9jxD2ITjy+SIm4+iL2VnuCAI/yPiKbXYkQ2chXBO8Ne8gwtSeMR 4vTMlj74L+ZM5iwKcMuhnbYLxLiV627ggY38zn0F+2n+rnEcp2hu9nLRn5vg6h7H9pY4UbDHoSz sbTf06C0D21PlrYGFsC5zAx5crf+CiOOKVcrkjH X-Google-Smtp-Source: AGHT+IFhMjBsM3JdE7uR28GvpBcu4vIRN9ny99NxinfMQl6YPjFP2/uRQibGwOuCOop4KEQ0baYDYAzL2o65cengWMI= X-Received: by 2002:a05:6808:1a05:b0:3fe:af08:65b5 with SMTP id 5614622812f47-4156813bc1emr1212232b6e.37.1752234415943; Fri, 11 Jul 2025 04:46:55 -0700 (PDT) MIME-Version: 1.0 References: <7f90e1f3-7e0b-4b87-8cb6-f2862755fd3c@aklaver.com> In-Reply-To: From: Ron Johnson Date: Fri, 11 Jul 2025 07:46:45 -0400 X-Gm-Features: Ac12FXznH0SLgLOF5y0DLUUDqnkWr4OqZwbI3y2O3B6pdiKBALBdGklr-R718AE Message-ID: Subject: Re: Aggregate versions of hashing functions (md5, sha1, etc...) To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000ecf7140639a5dde8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ecf7140639a5dde8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 11, 2025 at 5:01=E2=80=AFAM Dominique Devienne wrote: > On Thu, Jul 10, 2025 at 7:11=E2=80=AFPM Ron Johnson > wrote: > > On Thu, Jul 10, 2025 at 12:26=E2=80=AFPM Adrian Klaver < > adrian.klaver@aklaver.com> wrote: > >> On 7/10/25 04:48, Dominique Devienne wrote: > >> > Seems so logical to me, that these hashing functions were available > >> > are aggregates, I can't be the first one to think of that, can it? > >> > >> I've been on this list since late 2002 and I don't recall this ever > >> being brought up. Now it is entirely possible that age has dimmed my > >> recall abilities:) Though a quick search seems to confirm my memory. > > > > What even is an aggregate hash function? (I can imagine a few > possibilities, but don't want to assume.) > > Well, it's so obvious to me, I wonder if you're baiting me :) > > Any hasher/digest inits some internal state, processes bytes, > typically in "streaming-fashion" via successive byte spans (equivalent > to PostgreSQL's bytea), and yields a digest of various length at the > end. The current md5() and pgcrypto.digest() functions roll the x1 > init, xN process, and x1 finish into a single call, processing a > single bytea (or perhaps more intelligently for TOAST'ed values, the > 2K "rows" of those in streaming-fashion, hopefully. Can a dev > confirm?). As an aggregate, the processing is extended to all values > aggregated. So it "appends" all the fields into one (virtual) mega-structure and takes the hash on that. It's what I expected but wanted to verify. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000ecf7140639a5dde8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Jul 11, 2025 at 5:01=E2=80=AFAM D= ominique Devienne <ddevienne@gmai= l.com> wrote:
=
On Thu, Jul 10, 2025 at 7= :11=E2=80=AFPM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
> On Thu, Jul 10, 2025 at 12:26=E2=80=AFPM Adrian Klaver <adrian.klaver@aklaver.c= om> wrote:
>> On 7/10/25 04:48, Dominique Devienne wrote:
>> > Seems so logical to me, that these hashing functions were ava= ilable
>> > are aggregates, I can't be the first one to think of that= , can it?
>>
>> I've been on this list since late 2002 and I don't recall = this ever
>> being brought up. Now it is entirely possible that age has dimmed = my
>> recall abilities:) Though a quick search seems to confirm my memor= y.
>
> What even is an aggregate hash function?=C2=A0 (I can imagine a few po= ssibilities, but don't want to assume.)

Well, it's so obvious to me, I wonder if you're baiting me :)

Any hasher/digest inits some internal state, processes bytes,
typically in "streaming-fashion" via successive byte spans (equiv= alent
to PostgreSQL's bytea), and yields a digest of various length at the end. The current md5() and pgcrypto.digest() functions roll the x1
init, xN process, and x1 finish into a single call, processing a
single bytea (or perhaps more intelligently for TOAST'ed values, the 2K "rows" of those in streaming-fashion, hopefully. Can a dev
confirm?). As an aggregate, the processing is extended to all values
aggregated.

So it "appends" all t= he fields into one (virtual) mega-structure and takes the hash on that.

It's what I expected but wanted to verify.
<= /div>

--
Death to <Reda= cted>, and butter sauce.
Don't boil me, I'm still alive.
=
<Redacted> lobster!
--000000000000ecf7140639a5dde8--