I cannot update a view in 1.2 if I include the distribution column in the where clause. Using another column works.
create table t1 (col1 int, col2 int);
insert into t1 values (1,1);
test1=# select * from t1;
co1l | col2
------+------
1 | 1
(1 row)
test1=# create view v1 as select * from t1;
CREATE VIEW
test1=# insert into v1 values (2,2);
INSERT 0 1
So far, so good:
test1=# select * from v1;
co1l | col2
------+------
1 | 1
2 | 2
(2 rows)
test1=# select * from t1;
co1l | col2
------+------
1 | 1
2 | 2
(2 rows)
test1=# update v1 set col2 = 20 where col1 = 2;
ERROR: column "col1" does not exist
LINE 1: update v1 set col2 = 20 where col1 = 2;
^
But, I can use col2 in the where clause:
test1=# update v1 set col2 = 20 where col2 = 2;
UPDATE 1
Note also that there is a similar issue with rules. Referring to a distribution column in rules results in an error where it cannot find the distribution column.
Please re-confirm the bug report because I was not able to reproduce it on REL1_2_STABLE.
Also please share the output of
explain verbose update v1 set col2 = 20 where col1 = 2;
test=# create table t1 (col1 int, col2 int);
CREATE TABLE
test=# insert into t1 values (1,1);
INSERT 0 1
test=#
test=# create view v1 as select * from t1;
CREATE VIEW
test=# insert into v1 values (2,2);
INSERT 0 1
test=# update v1 set col2 = 20 where col1 = 2;
UPDATE 1
test=# update v1 set col2 = 20 where col2 = 2;
UPDATE 0
test=# explain verbose update v1 set col2 = 20 where col1 = 2;
QUERY PLAN
Update on public.t1 (cost=0.00..0.00 rows=1000 width=14)
Node/s: data_node_1, data_node_2, data_node_3, data_node_4
Node expr: t1.col1
Remote query: UPDATE ONLY public.t1 SET col1 = $1, col2 = $2 WHERE ((t1.ctid = $3) AND (t1.xc_node_id = $4))
-> Data Node Scan on t1 "REMOTE_TABLE_QUERY" (cost=0.00..0.00 rows=1000 width=14)
Output: t1.col1, 20, t1.col1, t1.col1, t1.ctid, t1.xc_node_id
Node/s: data_node_3
Remote query: SELECT col1, ctid, xc_node_id FROM ONLY public.t1 WHERE (col1 = 2)
(8 rows)