From: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
---|---|
To: | bashtanov(at)imap(dot)cc |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [patch] bit XOR aggregate functions |
Date: | 2021-02-10 05:42:04 |
Message-ID: | 20210210.144204.416723391133361234.horikyota.ntt@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At Tue, 9 Feb 2021 15:25:19 +0000, Alexey Bashtanov <bashtanov(at)imap(dot)cc> wrote in
> I personally use it as a checksum for a large unordered set, where
> performance and simplicity is prioritized over collision resilience.
> Maybe there are other ways to use them.
FWIW the BIT_XOR can be created using CREATE AGGREGATE.
CREATE OR REPLACE AGGREGATE BIT_XOR(IN v smallint) (SFUNC = int2xor, STYPE = smallint);
CREATE OR REPLACE AGGREGATE BIT_XOR(IN v int4) (SFUNC = int4xor, STYPE = int4);
CREATE OR REPLACE AGGREGATE BIT_XOR(IN v bigint) (SFUNC = int8xor, STYPE = bigint);
CREATE OR REPLACE AGGREGATE BIT_XOR(IN v bit) (SFUNC = bitxor, STYPE = bit);
The bit_and/bit_or aggregates are back to 2004, that commit says that:
> commit 8096fe45cee42ce02e602cbea08e969139a77455
> Author: Bruce Momjian <bruce(at)momjian(dot)us>
> Date: Wed May 26 15:26:28 2004 +0000
...
> (2) bitwise integer aggregates named bit_and and bit_or for
> int2, int4, int8 and bit types. They are not standard, but I find
> them useful. I needed them once.
We already had CREATE AGGREATE at the time, so BIT_XOR can be thought
as it falls into the same category with BIT_AND and BIT_OR, that is,
we may have BIT_XOR as an intrinsic aggregation?
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
From | Date | Subject | |
---|---|---|---|
Next Message | tsunakawa.takay@fujitsu.com | 2021-02-10 05:43:36 | RE: Parallel INSERT (INTO ... SELECT ...) |
Previous Message | Amit Kapila | 2021-02-10 05:32:24 | Re: Single transaction in the tablesync worker? |