The Messenger of Allah ﷺ forbade a man from praying while needing to relieve himself.
حدثنا بشر بن آدم حدثنا زيد بن الحباب حدثنا معاوية بن صالح عن السفر بن نسير عن يزيد بن شريح
أن رسول الله ﷺ نهى أن يصلي الرجل وهو حاقن
No references are available.
[sahih] Ahmad reported it, 5/260, from Zayd bin Hubab, at length, with this chain, and Busiri said, "This isnad contains Safar, and he is daif, but the hadith has supporting narrations, among them the hadith that follows (619)."