You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A customer reported a bug from development team affecting queries with UPDATE SET (col2, col1, col3) = (.....)
The columns are reordered following their physical ordering in pg_attribute, leading to for example UPDATE SET (col1, col2, col3) = (.....) with the right part, after = unchanged, as a results wrong columns are updated...
I have a complete test case, and a PR which I'm going to link in a moment. I think the issue may affect silently many applications, even more because the behavior can change over time based on the DDL applied on the updated tables.
There are several issue, I'm going to collect what I fond and link here so maybe we can close several at once...
ruleutils in Citus is based on PostgreSQL source code, but in PostgreSQL
ruleutils is not used at the planner stage.
For instance, it is assumed after parser that targetList are ordered as
they were read, but it's not true after rewriter, the resulting rewrite
tree is then provided to planner (and citus), but the ordering of the list
is not granted anymore.
It's similar to others previous issues reported and still open, as well
as to other bugfixes/improvment over time, the most noticable being the
ProcessIndirection() which is for domain and similar.
However, the implications of this bug are huge for users of `UPDATE SET
(...)`:
1. if you used to order by columns order, you're maybe safe: `SET (col1,
col2, col3, ...)`
2. if you used not to order by column order: `SET (col2, col1, col3,
...)` then you probably found a problem, or you have one.
Note about 1. that despite appearance and your QA, you are at risk: if
physical columns ordering is changed (for example after DROPping/ADDing
some), the same query which use to apparently works well will silently
update other columns...
As it is this code is not optimized for performance, not sure it'll be
needed.
c2main
added a commit
to c2main/citus
that referenced
this issue
Nov 22, 2024
A customer reported a bug from development team affecting queries with
UPDATE SET (col2, col1, col3) = (.....)
The columns are reordered following their physical ordering in pg_attribute, leading to for example
UPDATE SET (col1, col2, col3) = (.....)
with the right part, after=
unchanged, as a results wrong columns are updated...I have a complete test case, and a PR which I'm going to link in a moment. I think the issue may affect silently many applications, even more because the behavior can change over time based on the DDL applied on the updated tables.
There are several issue, I'm going to collect what I fond and link here so maybe we can close several at once...
Please see https://github.com/citusdata/citus/actions/runs/10527721147#summary-29171656391 for some examples of the problem.
The text was updated successfully, but these errors were encountered: