Bug 1376922 Union query on a view returns wrong results Qifan investigated this bug and found the problem in replacePivs().
Rather than forcing the parent's partitioning function on the child, the fix takes the child's function and only replaces the PIVs in it.
- The replacePivs() method used a ValueIdSet for the PIVs. This should be a list, since we use multiple PIVs often by position in the list. - We don't need the code in replacePivs() that fixes predicates in scan nodes, since we call replacePivs() before calling preCodeGen() on the child and therefore the child node does not yet have predicates that refer to PIVs. - We don't need to replace the partitioning expression anymore, since it does not refer to any PIVs and we leave the partitioning key predicates almost unchanged. - Fixing a small, unrelated, thing: When sourcing in sqenv.sh twice, it reported an error message, due to a shell variable that didn't get initialized to an empty string (workstation environment only).