Hi Antonio,
the upgrade script upgrade-5.7.0d8-5.7.0d9.sql has been written to be executed with PG 8.x and so I suspect that you were executing it with PG 9.x.
I did a lot of upgrades restoring the database from PG 8.2 to an intermediate PG 8.4, upgrading to OACS 5.8 and finally restoring from PG 8.4 to PG 9.x.