Fix 34855 / 455 / 462 /Solve postgres temp table issue

Based on information found in [0, 1]

[0] https://bugzilla.wikimedia.org/show_bug.cgi?id=34855
[1] https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114764