Made all the IF EXISTS and IF NOT EXISTS code compatible with bin logging. Proper query is written into the bin log if it is successful. Tested manually, no test cases written yet.