Re: Abbreviated keys for Numeric - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Abbreviated keys for Numeric
Date
Msg-id CAM3SWZT-xHa2Er1-dEC9NzU+D==kNj8+sYYbyoSdVckiq0VNdw@mail.gmail.com
Whole thread Raw
In response to Re: Abbreviated keys for Numeric  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Abbreviated keys for Numeric  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-hackers
On Sun, Mar 22, 2015 at 1:01 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
> So here's a version 3 patch:

By the way, there was another bug in this that I forgot to point out,
but removed, here:

+ if (nss->estimating)
+ {
+ uint32 tmp = (uint32)result;
+ addHyperLogLog(&nss->abbr_card, hash_uint32(tmp));
+ }

And here:

+ if (nss->estimating)
+ {
+ uint32 tmp = ((uint32)result) ^ (uint32)((uint64) result >> 32);
+ addHyperLogLog(&nss->abbr_card, hash_uint32(tmp));
+ }

(I simply operate on the raw Datum when hashing for hyperLogLog, in a
similar manner to the text opclass, which is safe with 8 byte datums +
pass by value int64).

The problem here is that you're not calling hash_uint32() through
DatumGetUInt32() - hash_uint32() returns Datum. And yes, that matters
- see commit 2c22afaa.

You also need to indent this code correctly.

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Table-level log_autovacuum_min_duration
Next
From: Ashutosh Bapat
Date:
Subject: Re: Display of multi-target-table Modify plan nodes in EXPLAIN