Re: [patch] bit XOR aggregate functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Vik Fearing <vik(at)postgresfriends(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "bashtanov(at)imap(dot)cc" <bashtanov(at)imap(dot)cc>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [patch] bit XOR aggregate functions
Date: 2021-03-07 16:31:57
Message-ID: 1623146.1615134717@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> But this is offtopic in this discussion :)

The whole topic is off-topic. As a general rule, things that depend on
input order shouldn't be declared as aggregates --- they should be window
functions or ordered-set aggregates, for which the syntax forces you to
specify input order. All of the standard aggregates, and most of our
custom ones (including BIT_XOR) do not depend on input order (... mumble
floating-point roundoff error mumble ...), so forcing users to write an
ordering clause would be useless, not to mention being a SQL spec
violation.

There are a small minority like array_agg that do have such a dependency,
but as far as I recall our docs for each of those warn about the need to
sort the input for reproducible results. I think that's sufficient.
Who's to say whether a particular query actually requires reproducible
results? Seeing that we don't provide reproducible row ordering
without an ORDER BY, I'm not sure why we should apply a different
standard to array_agg.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2021-03-07 16:45:33 Re: EXPLAIN/EXPLAIN ANALYZE REFRESH MATERIALIZED VIEW
Previous Message Fujii Masao 2021-03-07 14:39:10 Re: Nicer error when connecting to standby with hot_standby=off