Since 5.1.1 was never tagged correctly, it appears that there were two upgrade scripts left out of the 5.1.1 version, so when you upgrade to 5.1.3, you'll need to manually load the upgrade scripts:
psql < sql/postgresql/upgrade/upgrade-5.0.0b4-5.1.0d2.sql
psql < sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql
This type of stuff should become less common as we all move forward and use the tagging system we've set up.