Bug fixing for postgresql