"The Messenger of Allah said, 'No one of you should stand to pray when he feels some discomfort (because of needing to urinate or defecate).'" (Using translation from Ibn Mājah 618)
قَالَ رَسُولُ اللهِ ﷺ لَا يَقُومَنَّ أَحَدُكُمْ إِلَى الصَّلَاةِ وَبِهِ أَذًى مِنْ غَائِطٍ أَوْ بَوْلٍ