Andres Freund <and...@2ndquadrant.com> writes: > On 2014-01-16 14:23:47 -0500, Tom Lane wrote: >> Dunno, I think that a transition state containing both an int64 and >> a (presumably separately palloc'd) numeric will be a real PITA.
> Yea, not sure myself. I just dislike the idea of having a good part of a > 128bit math implementation for a single transition function. Not sure how you figure that we need very much new code beyond the overflow test. > Well, you don't need to check the second variable for lots of > operations. Say, the current sum is 0 and you add a -1. With the two > variables scheme that requires checking the second variable, > manipulating it etc. I'm envisioning just state->lowhalf += input; if (overflowed_up) state->highhalf++; else if (overflowed_down) state->highhalf--; The only thing that might take a moment's thought, or extra cycles in the normal case, is extending the overflow test so that it can tell whether we need to increment or decrement the upper half. [ thinks a bit... ] Note that I'm supposing that the state is defined as (highhalf * 2^64) + lowhalf, not that we need the two variables to be exactly a 128-bit twos-complement value, which is what I think you're talking about. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers