The Messenger of Allah said: "No one among the Muslims should stand to pray when he is suppressing (the need to urinate or defecate), until he has to relieve himself."
عَنْ رَسُولِ اللَّهِ ﷺ أَنَّهُ قَالَ لاَ يَقُومُ أَحَدٌ مِنَ الْمُسْلِمِينَ وَهُوَ حَاقِنٌ حَتَّى يَتَخَفَّفَ