pgsql: Repair bogus handling of multi-assignment Params in upper plan l

2018-12-12 Thread Tom Lane
Repair bogus handling of multi-assignment Params in upper plan levels. Our support for multiple-set-clauses in UPDATE assumes that the Params referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan in the targetlist of the plan node that calculates the updated row. (Yeah, it's a ha

pgsql: Repair bogus handling of multi-assignment Params in upper plan l

2018-12-12 Thread Tom Lane
Repair bogus handling of multi-assignment Params in upper plan levels. Our support for multiple-set-clauses in UPDATE assumes that the Params referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan in the targetlist of the plan node that calculates the updated row. (Yeah, it's a ha

pgsql: Repair bogus handling of multi-assignment Params in upper plan l

2018-12-12 Thread Tom Lane
Repair bogus handling of multi-assignment Params in upper plan levels. Our support for multiple-set-clauses in UPDATE assumes that the Params referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan in the targetlist of the plan node that calculates the updated row. (Yeah, it's a ha

pgsql: Repair bogus handling of multi-assignment Params in upper plan l

2018-12-12 Thread Tom Lane
Repair bogus handling of multi-assignment Params in upper plan levels. Our support for multiple-set-clauses in UPDATE assumes that the Params referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan in the targetlist of the plan node that calculates the updated row. (Yeah, it's a ha

pgsql: Repair bogus handling of multi-assignment Params in upper plan l

2018-12-12 Thread Tom Lane
Repair bogus handling of multi-assignment Params in upper plan levels. Our support for multiple-set-clauses in UPDATE assumes that the Params referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan in the targetlist of the plan node that calculates the updated row. (Yeah, it's a ha

pgsql: Repair bogus EPQ plans generated for postgres_fdw foreign joins.

2018-12-12 Thread Tom Lane
Repair bogus EPQ plans generated for postgres_fdw foreign joins. postgres_fdw's postgresGetForeignPlan() assumes without checking that the outer_plan it's given for a join relation must have a NestLoop, MergeJoin, or HashJoin node at the top. That's been wrong at least since commit 4bbf6edfb (whi

pgsql: Repair bogus EPQ plans generated for postgres_fdw foreign joins.

2018-12-12 Thread Tom Lane
Repair bogus EPQ plans generated for postgres_fdw foreign joins. postgres_fdw's postgresGetForeignPlan() assumes without checking that the outer_plan it's given for a join relation must have a NestLoop, MergeJoin, or HashJoin node at the top. That's been wrong at least since commit 4bbf6edfb (whi

pgsql: Repair bogus EPQ plans generated for postgres_fdw foreign joins.

2018-12-12 Thread Tom Lane
Repair bogus EPQ plans generated for postgres_fdw foreign joins. postgres_fdw's postgresGetForeignPlan() assumes without checking that the outer_plan it's given for a join relation must have a NestLoop, MergeJoin, or HashJoin node at the top. That's been wrong at least since commit 4bbf6edfb (whi

pgsql: Repair bogus EPQ plans generated for postgres_fdw foreign joins.

2018-12-12 Thread Tom Lane
Repair bogus EPQ plans generated for postgres_fdw foreign joins. postgres_fdw's postgresGetForeignPlan() assumes without checking that the outer_plan it's given for a join relation must have a NestLoop, MergeJoin, or HashJoin node at the top. That's been wrong at least since commit 4bbf6edfb (whi

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th

pgsql: Fix deadlock in GIN vacuum introduced by 218f51584d5

2018-12-12 Thread Alexander Korotkov
Fix deadlock in GIN vacuum introduced by 218f51584d5 Before 218f51584d5 if posting tree page is about to be deleted, then the whole posting tree is locked by LockBufferForCleanup() on root preventing all the concurrent inserts. 218f51584d5 reduced locking to the subtree containing page to be dele

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Fix deadlock in GIN vacuum introduced by 218f51584d5

2018-12-12 Thread Alexander Korotkov
Fix deadlock in GIN vacuum introduced by 218f51584d5 Before 218f51584d5 if posting tree page is about to be deleted, then the whole posting tree is locked by LockBufferForCleanup() on root preventing all the concurrent inserts. 218f51584d5 reduced locking to the subtree containing page to be dele

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th

pgsql: Fix deadlock in GIN vacuum introduced by 218f51584d5

2018-12-12 Thread Alexander Korotkov
Fix deadlock in GIN vacuum introduced by 218f51584d5 Before 218f51584d5 if posting tree page is about to be deleted, then the whole posting tree is locked by LockBufferForCleanup() on root preventing all the concurrent inserts. 218f51584d5 reduced locking to the subtree containing page to be dele

pgsql: Prevent deadlock in ginRedoDeletePage()

2018-12-12 Thread Alexander Korotkov
Prevent deadlock in ginRedoDeletePage() On standby ginRedoDeletePage() can work concurrently with read-only queries. Those queries can traverse posting tree in two ways. 1) Using rightlinks by ginStepRight(), which locks the next page before unlocking its left sibling. 2) Using downlinks by gin

pgsql: Prevent GIN deleted pages from being reclaimed too early

2018-12-12 Thread Alexander Korotkov
Prevent GIN deleted pages from being reclaimed too early When GIN vacuum deletes a posting tree page, it assumes that no concurrent searchers can access it, thanks to ginStepRight() locking two pages at once. However, since 9.4 searches can skip parts of posting trees descending from the root. Th