Updated patch. Fixed a few minor things, added documentation and regression
tests. Unfortunately I can't test the regression tests because I get a
segmentation fault earlier in the same file due to a GIN index build. So I
haven't updated the "expected" output.