All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
If a person stands while touching one of the pillars of the masjid while praying, or touching its wall, or anything else, this does not affect the validity of his prayer as long as what is touched is pure.
However, if you mean leaning on the pillar to use it as support, then please refer to fatwa 352123.
Allah knows best.