Fixed query for PG 8.4

Posgtres cannot find a cast rule.
Fixed query for PG 8.3

The AS keyword was required.
Ignore AFTER triggers sorting after z_repack_trigger

They are not a problem, and they fore after the BEFORE trigger anyway.

To be checked against more PostgreSQL versions.