Hi Danish,
> I have tried on version 12 of PostgreSQL getting same error
As of today PG12 is end-of-life and will no longer receive bug fixes [1].
Does the issue reproduce with PG13, 14 or 15?
[1]: https://www.postgresql.org/about/news/postgresql-171-165-159-1414-1317-and-1221-released-2955/
--
Best regards,
Aleksander Alekseev