Fixing XOR for postgresql and mysql