Update DeferOneOrMany for PostgreSQL support

Casting slave_id VARCHAR to INTEGER, otherwise, no comparison can be made in PostgreSQL
Also use a dirty hackish method to determine ifnull PostgreSQL alternative in case of PostgreSQL usage
Nees some extra thought..