Thank you for the additional information.
Dyschezia is the medical term used to describe painful defecation.This can be due to several things.
Colitis, prostate disease, problems in the pelvis. Anal polyps, growths in the colon, narrowing of the colon and many more.
Here is additional information
If he is this painful when passing stool then some additional testing really needs to be done.
X rays to look in the abdomen for any abnormalities. If x rays are normal the a scope of the rectum and colon would be warranted.
Problems with a disc in the lower back can also cause pain when defecating. Back injuries are common in small breeds and even more so in over weight dogs.
A perineal hernia can also cause this problem
I would suggest getting him back in to the vet as soon as you can for additional testing.
Please let me know how he is doing. Please reply back if you have additional questions or concerns.