The following review has been posted through the commitfest application:
make installcheck-world: not tested
Implements feature: not tested
Spec compliant: not tested
Documentation: not tested
This is a mini-review of to_oct :-)
The function seems useful to me, and is obviously correct.
I don't know whether optimization at such a low level is considered in PostgreSQL, but here goes.
The calculation of quotient and remainder can be replaced by less costly masking and shifting.
Defining
#define OCT_DIGIT_BITS 3
#define OCT_DIGIT_BITMASK 0x7
the content of the loop can be replaced by
*--ptr = digits[value & OCT_DIGIT_BITMASK];
value >>= OCT_DIGIT_BITS;
Also, the check for ptr > buf in the while loop can be removed. The check is superfluous, since buf cannot possibly be
exhaustedby a 32 bit integer (the maximum octal number being 37777777777).
Best regards
Dag Lem
The new status of this patch is: Waiting on Author