Commit dd077ef8 authored by Robert Haas's avatar Robert Haas

postgres_fdw: Avoid sharing list substructure.

list_concat(list_concat(a, b), c) destructively changes both a and b;
to avoid such perils, copy lists of remote_conds before incorporating
them into larger lists via list_concat().

Ashutosh Bapat, per a report from Etsuro Fujita
parent 902fd1f4
...@@ -3488,30 +3488,30 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, ...@@ -3488,30 +3488,30 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
{ {
case JOIN_INNER: case JOIN_INNER:
fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo->remote_conds = list_concat(fpinfo->remote_conds,
fpinfo_i->remote_conds); list_copy(fpinfo_i->remote_conds));
fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo->remote_conds = list_concat(fpinfo->remote_conds,
fpinfo_o->remote_conds); list_copy(fpinfo_o->remote_conds));
break; break;
case JOIN_LEFT: case JOIN_LEFT:
fpinfo->joinclauses = list_concat(fpinfo->joinclauses, fpinfo->joinclauses = list_concat(fpinfo->joinclauses,
fpinfo_i->remote_conds); list_copy(fpinfo_i->remote_conds));
fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo->remote_conds = list_concat(fpinfo->remote_conds,
fpinfo_o->remote_conds); list_copy(fpinfo_o->remote_conds));
break; break;
case JOIN_RIGHT: case JOIN_RIGHT:
fpinfo->joinclauses = list_concat(fpinfo->joinclauses, fpinfo->joinclauses = list_concat(fpinfo->joinclauses,
fpinfo_o->remote_conds); list_copy(fpinfo_o->remote_conds));
fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo->remote_conds = list_concat(fpinfo->remote_conds,
fpinfo_i->remote_conds); list_copy(fpinfo_i->remote_conds));
break; break;
case JOIN_FULL: case JOIN_FULL:
fpinfo->joinclauses = list_concat(fpinfo->joinclauses, fpinfo->joinclauses = list_concat(fpinfo->joinclauses,
fpinfo_i->remote_conds); list_copy(fpinfo_i->remote_conds));
fpinfo->joinclauses = list_concat(fpinfo->joinclauses, fpinfo->joinclauses = list_concat(fpinfo->joinclauses,
fpinfo_o->remote_conds); list_copy(fpinfo_o->remote_conds));
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment