[#542] Remove usage of postgres' function that's not available in < 9.1

The function left() was only added in Postgres 9.1, but we can easily use
substr() to achieve the same effect.

Fixes #542.