Hi hackers, At the moment, I'm working on the TimescaleDB extension for Postgres. Among other things, it implements inheritance-based partitioning, and one part of this is a custom plan node that behaves like an Append.
I was investigating a bug in this node when used under an UPDATE, and ran into a problem that seems to be impossible to fix on the extension level. Namely, while the ROWID_VARs are supposed not to survive the planning past a certain point, they are still present in the root->processed_targetlist. It is then applied to the custom plan by apply_scanjoin_target_to_paths(). However: 1) A Projection node that has this ROWID in output targetlist will complain about "variable not found in subplan targetlist" if the same ROWID is not present in the output targetlist of the custom node. 2) A custom node cannot have a ROWID_VAR in the output targetlist, otherwise it hits an assertion during setrefs processing (set_customscan_references() applies fix_scan_expr_mutator() to either custom_scan_tlist or the targetlist). One fix that comes to mind is replacing the ROWID_VARS in the root->processed_targetlist, after we finished processing them. Would that be the correct approach? Best regards Alexander Kuzmenkov TigerData
