psql version friendly

Could be reverted.
left -- available only in 9.1 and later
substr -- available in all versions