The current _pg_keypositions function generates the numbers from 1 to 32 using a massive union, shouldn't it just use generate_series instead (to make it faster/simpler)?
Chris