How did you install 5.2.0? It appears that your install of 5.2.0 is broken.
Try running the file found in packages/sql/postgresql/upgrade/upgrade-5.2.0a1-5.2.0a2.sql
This fixes this problem. It looks like either 5.2.0 was released with broken code, or you installed a pre-released version of 5.2.
The 5.2.0 installation was a fresh install, so i guess it was released broken.
Sourcing upgrade-5.2.0a1-5.2.0a2.sql fixed the problem, thanks.