"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)
قَالَ رَسُولُ اللهِ ﷺ لَا يَقُومَنَّ أَحَدُكُمْإِلَى الصَّلَاةِ وَبِهِ أَذًى يَعْنِي الْبَوْلَ وَالْغَائِطَ