Attaching v6 patch, rebased because of a recent commit3d65b0593c5578014f62e09d4008006f1783f64d. Please consider this forfurther review.
With Regards,Bharath Rupireddy.EnterpriseDB: http://www.enterprisedb.com