A patch fixing this bughttps://www.postgresql.org/message-id/flat/15738-21723084f3009ceb%40postgresql.org