*** pgsql/src/backend/optimizer/path/allpaths.c 2009/02/15 20:16:21 1.180 --- pgsql/src/backend/optimizer/path/allpaths.c 2009/03/10 20:58:26 1.181 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.179 2009/01/01 17:23:43 momjian Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.180 2009/02/15 20:16:21 tgl Exp $ * *------------------------------------------------------------------------- */ *************** set_subquery_pathlist(PlannerInfo *root, *** 523,528 **** --- 523,535 ---- PlannerInfo *subroot; List *pathkeys; + /* + * Must copy the Query so that planning doesn't mess up the RTE contents + * (really really need to fix the planner to not scribble on its input, + * someday). + */ + subquery = copyObject(subquery); + /* We need a workspace for keeping track of set-op type coercions */ differentTypes = (bool *) palloc0((list_length(subquery->targetList) + 1) * sizeof(bool));