The Prophet (peace and blessings be upon him) said:
"None of you should stand for prayer while he is in discomfort (from holding back urine or stool)."
Hadith Referenceصحیح الجامع الصغیر / حرف اللام ألف / 7769
Hadith Gradingالألبانی:صحيح
Hadith Takhrij[هـ] عن أبي هريرة. ضعيف أبي داود ١٢.