PostgreSQL 8.3.5 - Important Upgrade

Normally, minor releases just sail by… the bugs fixed are tiny things that don’t apply to your neck of the woods, but for 8.3.5 you will find this entry in the release notes:

Fix GiST index corruption due to marking the wrong index entry "dead" after a deletion (Teodor) This would result in index searches failing to find rows they should have found.

The PostGIS spatial index is built on top of GiST, so for any production table where entries are being deleted or updated, this bug could actually cause errors to crop up. Data would not be lost, but it would occasionally not be found in index-enabled searches.

If you are using PostGIS on PostgreSQL 8.3, upgrade to 8.3.5 as soon as possible. This bug has been seen in the wild, one of my clients just ran into it, it could affect you too.

Update: From Mark Cave-Ayland, the bug was only introduced during the last set of point releases, and was backpatched all the way to 8.1. So the complete list of affected PostgreSQL releases is: 8.1.14, 8.2.10 and 8.3.4. If your version is not one of those, you’re safe.

Local Color

One of the stranger rituals you will come across in Victoria is the annual fish stencil that the staff at the Goldstream Provincial Park put on for the kids every year during the salmon run. This is no ordinary fish stencil, because at Goldstream they use real dead salmon as the template.

Picture from Aaron Racicot on his recent Victoria trip.

Paint your fish, press a sheet of paper onto it, and voila, instant fish keepsake. If you come to Victoria in the late-October to early-November period, make sure Goldstream (just 20 minutes outside town) is on your agenda.

On Guard

While the “Obama-dot” in Charlie Savage’s rally snapshot is nice:

What really makes the picture, to my mind, is the snipers on the roof:

Nothing says democracy quite like snipers! :)

Best Election Map

I’ve always been a bit of a connoisseur of election maps, but most maps don’t really tell me much that I don’t already know. The maps I like best are those that show smaller geographies than usually reported (in Canada, maps of polls instead of ridings, in the USA, maps of counties instead of states) and those that show changes from previous results – “delta maps”. The New York Times is currently running one on their front page, here’s a snapshot.

2008 Delta Map

The colors are not reflective of number of votes, but of direction of movement. Hence, Montana colored blue even though McCain won it, because in every county Obama did better than Kerry did in 2004.

One of the things I found curious about the numbers in the paper today is that while Obama won a strong Electoral College victory, his popular vote share is not much different from the share Bush won in 2004, and Bush won a squeaker in the Electoral College. The map tells the tale.

McCain didn’t lose support across the board, he actually improved on Bush in places, but mostly in places where the Republicans were already winning smashing majorities – more votes in Alabama don’t get you any closer to the Presidency. So a respectable showing in the popular vote translates into an Electoral College whomping.

Somewhat disturbing is how nicely the red areas map into the phrase “rural white voters in former slave states”. History just never goes away, does it?

PostGIS Code Re-org

Most commit messages are pretty terse affairs (“Fix for issue #142.”, “Remove compile warnings.”) but this morning, Mark Cave-Ayland posted this novel along with his code changes:

r3224 /trunk/loader/ (Makefile.in pgsql2shp.c wkb.h)

Switch pgsql2shp over to using liblwgeom.

There are few commits that can be as satisfying as one which involves the removal of ~1200 lines of code. By using the liblwgeom parser instead of the in-built parser, we have now achieved the following:

i) all parsers within PostGIS, shp2pgsql and pgsql2shp are now the same which means they all follow the same rules. Also extended error reporting information including error text and position information is available.

ii) the complexity of the shp2pgsql/pgsql2shp is considerably reduced.

The slightly unfortunate cost is the overall executable size is larger, since we are linking with liblwgeom. However, from both a consistency and maintainability point of view, this is a big win. Note that while there may be a difference in behaviour in some corner cases, all regression tests pass here.

Some extra explanation is in order. Mark’s goal for the 1.4 release of PostGIS is to clean up the underlying code and make it easier to develop on. That has resulted in some major reorganization under the covers.

The geometry framework (liblwgeom) under PostGIS was written to be separable from the rest of the specific PgSQL code, but historically was managed right alongside it, in the same directory and built chain. Mark has broken it out into it’s own directory with a separate build out to a true library file.

Now that the geometry framework is a true library, it can be used in other places, not just the back-end. So hooking the data loader/dumpers into it is a first step, and as he notes, improves the code immensely.