mirror of https://github.com/citusdata/citus.git
Check more carrefuly UPDATE SET ()=(SELECT) query
Produce an ERROR when attribute in the target list have been reordered by PostgreSQL rewritter.pull/7675/head
parent
7ceb49068e
commit
2a6b9ffd39
|
@ -3509,6 +3509,9 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
SubLink *cur_ma_sublink;
|
SubLink *cur_ma_sublink;
|
||||||
List *ma_sublinks;
|
List *ma_sublinks;
|
||||||
|
|
||||||
|
AttrNumber previous_attnum = InvalidAttrNumber;
|
||||||
|
int paramid_increment = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
||||||
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
||||||
|
@ -3631,11 +3634,48 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
*/
|
*/
|
||||||
if (cur_ma_sublink != NULL)
|
if (cur_ma_sublink != NULL)
|
||||||
{
|
{
|
||||||
|
AttrNumber attnum = InvalidAttrNumber;
|
||||||
|
if (IsA(expr, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) expr;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
}
|
||||||
|
else if (IsA(expr, FuncExpr))
|
||||||
|
{
|
||||||
|
FuncExpr *func = (FuncExpr *) expr;
|
||||||
|
ListCell *lc;
|
||||||
|
|
||||||
|
/* Iterate through the arguments of the FuncExpr */
|
||||||
|
foreach(lc, func->args)
|
||||||
|
{
|
||||||
|
Node *arg = (Node *) lfirst(lc);
|
||||||
|
|
||||||
|
/* Check if the argument is a PARAM node */
|
||||||
|
if (IsA(arg, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) arg;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
|
||||||
|
break; /* Exit loop once we find the PARAM node */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous_attnum >= attnum)
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg(
|
||||||
|
"cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order"),
|
||||||
|
errhint("Sort the columns on the left side by physical order.")));
|
||||||
|
|
||||||
|
previous_attnum = attnum;
|
||||||
|
|
||||||
if (--remaining_ma_columns > 0)
|
if (--remaining_ma_columns > 0)
|
||||||
continue; /* not the last column of multiassignment */
|
continue; /* not the last column of multiassignment */
|
||||||
|
|
||||||
appendStringInfoChar(buf, ')');
|
appendStringInfoChar(buf, ')');
|
||||||
expr = (Node *) cur_ma_sublink;
|
expr = (Node *) cur_ma_sublink;
|
||||||
cur_ma_sublink = NULL;
|
cur_ma_sublink = NULL;
|
||||||
|
paramid_increment = previous_attnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfoString(buf, " = ");
|
appendStringInfoString(buf, " = ");
|
||||||
|
|
|
@ -3525,6 +3525,9 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
SubLink *cur_ma_sublink;
|
SubLink *cur_ma_sublink;
|
||||||
List *ma_sublinks;
|
List *ma_sublinks;
|
||||||
|
|
||||||
|
AttrNumber previous_attnum = InvalidAttrNumber;
|
||||||
|
int paramid_increment = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
||||||
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
||||||
|
@ -3647,11 +3650,48 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
*/
|
*/
|
||||||
if (cur_ma_sublink != NULL)
|
if (cur_ma_sublink != NULL)
|
||||||
{
|
{
|
||||||
|
AttrNumber attnum = InvalidAttrNumber;
|
||||||
|
if (IsA(expr, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) expr;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
}
|
||||||
|
else if (IsA(expr, FuncExpr))
|
||||||
|
{
|
||||||
|
FuncExpr *func = (FuncExpr *) expr;
|
||||||
|
ListCell *lc;
|
||||||
|
|
||||||
|
/* Iterate through the arguments of the FuncExpr */
|
||||||
|
foreach(lc, func->args)
|
||||||
|
{
|
||||||
|
Node *arg = (Node *) lfirst(lc);
|
||||||
|
|
||||||
|
/* Check if the argument is a PARAM node */
|
||||||
|
if (IsA(arg, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) arg;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
|
||||||
|
break; /* Exit loop once we find the PARAM node */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous_attnum >= attnum)
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg(
|
||||||
|
"cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order"),
|
||||||
|
errhint("Sort the columns on the left side by physical order.")));
|
||||||
|
|
||||||
|
previous_attnum = attnum;
|
||||||
|
|
||||||
if (--remaining_ma_columns > 0)
|
if (--remaining_ma_columns > 0)
|
||||||
continue; /* not the last column of multiassignment */
|
continue; /* not the last column of multiassignment */
|
||||||
|
|
||||||
appendStringInfoChar(buf, ')');
|
appendStringInfoChar(buf, ')');
|
||||||
expr = (Node *) cur_ma_sublink;
|
expr = (Node *) cur_ma_sublink;
|
||||||
cur_ma_sublink = NULL;
|
cur_ma_sublink = NULL;
|
||||||
|
paramid_increment = previous_attnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfoString(buf, " = ");
|
appendStringInfoString(buf, " = ");
|
||||||
|
|
|
@ -3542,6 +3542,9 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
SubLink *cur_ma_sublink;
|
SubLink *cur_ma_sublink;
|
||||||
List *ma_sublinks;
|
List *ma_sublinks;
|
||||||
|
|
||||||
|
AttrNumber previous_attnum = InvalidAttrNumber;
|
||||||
|
int paramid_increment = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
* Prepare to deal with MULTIEXPR assignments: collect the source SubLinks
|
||||||
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
* into a list. We expect them to appear, in ID order, in resjunk tlist
|
||||||
|
@ -3664,11 +3667,48 @@ get_update_query_targetlist_def(Query *query, List *targetList,
|
||||||
*/
|
*/
|
||||||
if (cur_ma_sublink != NULL)
|
if (cur_ma_sublink != NULL)
|
||||||
{
|
{
|
||||||
|
AttrNumber attnum = InvalidAttrNumber;
|
||||||
|
if (IsA(expr, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) expr;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
}
|
||||||
|
else if (IsA(expr, FuncExpr))
|
||||||
|
{
|
||||||
|
FuncExpr *func = (FuncExpr *) expr;
|
||||||
|
ListCell *lc;
|
||||||
|
|
||||||
|
/* Iterate through the arguments of the FuncExpr */
|
||||||
|
foreach(lc, func->args)
|
||||||
|
{
|
||||||
|
Node *arg = (Node *) lfirst(lc);
|
||||||
|
|
||||||
|
/* Check if the argument is a PARAM node */
|
||||||
|
if (IsA(arg, Param))
|
||||||
|
{
|
||||||
|
Param *param = (Param *) arg;
|
||||||
|
attnum = param->paramid + paramid_increment;
|
||||||
|
|
||||||
|
break; /* Exit loop once we find the PARAM node */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous_attnum >= attnum)
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg(
|
||||||
|
"cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order"),
|
||||||
|
errhint("Sort the columns on the left side by physical order.")));
|
||||||
|
|
||||||
|
previous_attnum = attnum;
|
||||||
|
|
||||||
if (--remaining_ma_columns > 0)
|
if (--remaining_ma_columns > 0)
|
||||||
continue; /* not the last column of multiassignment */
|
continue; /* not the last column of multiassignment */
|
||||||
|
|
||||||
appendStringInfoChar(buf, ')');
|
appendStringInfoChar(buf, ')');
|
||||||
expr = (Node *) cur_ma_sublink;
|
expr = (Node *) cur_ma_sublink;
|
||||||
cur_ma_sublink = NULL;
|
cur_ma_sublink = NULL;
|
||||||
|
paramid_increment = previous_attnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfoString(buf, " = ");
|
appendStringInfoString(buf, " = ");
|
||||||
|
|
|
@ -103,103 +103,113 @@ SELECT * FROM test_dist_indirection_new ORDER BY id;
|
||||||
-- now UPDATEs
|
-- now UPDATEs
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_bool, col_date, col_int, col_text)
|
SET (col_bool, col_date, col_int, col_text)
|
||||||
= (SELECT true, '1970-12-31'::date, 1, 'ok')
|
= (SELECT true, '1970-01-01'::date, 1, 'ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 12-31-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 12-31-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 12-31-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 12-31-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_bool, col_date, col_int, col_text)
|
SET (col_bool, col_date, col_int, col_text)
|
||||||
= (SELECT true, '1970-12-31'::date, 1, 'ok')
|
= (SELECT true, '1970-01-01'::date, 1, 'ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 12-31-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 12-31-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 12-31-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 12-31-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_bool, col_date) = (select true, '1970-06-06'::date)
|
SET (col_bool, col_date) = (select true, '1970-01-01'::date)
|
||||||
, (col_int, col_text) = (select 1, 'still ok')
|
, (col_int, col_text) = (select 1, 'still ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | still ok
|
1 | t | 01-01-1970 | 1 | still ok
|
||||||
2 | t | 06-06-1970 | 1 | still ok
|
2 | t | 01-01-1970 | 1 | still ok
|
||||||
3 | t | 06-06-1970 | 1 | still ok
|
3 | t | 01-01-1970 | 1 | still ok
|
||||||
4 | t | 06-06-1970 | 1 | still ok
|
4 | t | 01-01-1970 | 1 | still ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_bool, col_date) = (select true, '1970-06-06'::date)
|
SET (col_bool, col_date) = (select true, '1970-01-01'::date)
|
||||||
, (col_int, col_text) = (select 1, 'still ok')
|
, (col_int, col_text) = (select 1, 'still ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | still ok
|
1 | t | 01-01-1970 | 1 | still ok
|
||||||
2 | t | 06-06-1970 | 1 | still ok
|
2 | t | 01-01-1970 | 1 | still ok
|
||||||
3 | t | 06-06-1970 | 1 | still ok
|
3 | t | 01-01-1970 | 1 | still ok
|
||||||
4 | t | 06-06-1970 | 1 | still ok
|
4 | t | 01-01-1970 | 1 | still ok
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
UPDATE test_ref_indirection
|
||||||
|
SET (col_bool, col_int) = (select true, 1)
|
||||||
|
, (col_text) = (select 'ok')
|
||||||
|
RETURNING *;
|
||||||
|
id | col_bool | col_date | col_int | col_text
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT * FROM test_ref_indirection ORDER BY id;
|
SELECT * FROM test_ref_indirection ORDER BY id;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | still ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 06-06-1970 | 1 | still ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 06-06-1970 | 1 | still ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 06-06-1970 | 1 | still ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT * FROM test_dist_indirection ORDER BY id;
|
SELECT * FROM test_dist_indirection ORDER BY id;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | still ok
|
1 | t | 01-01-1970 | 1 | still ok
|
||||||
2 | t | 06-06-1970 | 1 | still ok
|
2 | t | 01-01-1970 | 1 | still ok
|
||||||
3 | t | 06-06-1970 | 1 | still ok
|
3 | t | 01-01-1970 | 1 | still ok
|
||||||
4 | t | 06-06-1970 | 1 | still ok
|
4 | t | 01-01-1970 | 1 | still ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
-- but those should not:
|
-- but those should not:
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_date, col_text, col_int, col_bool)
|
SET (col_date, col_text, col_int, col_bool)
|
||||||
= (SELECT '1970-12-31'::date, 'not ok', 2, false)
|
= (SELECT '1970-06-06'::date, 'not ok', 2, false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type date
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_date, col_text, col_int, col_bool)
|
SET (col_date, col_text, col_int, col_bool)
|
||||||
= (SELECT '1970-12-31'::date, 'not ok', 2, false)
|
= (SELECT '1970-06-06'::date, 'not ok', 2, false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type date
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
UPDATE test_ref_indirection
|
||||||
-- TODO wrong ERROR
|
SET (col_int, col_text) = (select 2, 'not ok')
|
||||||
|
, (col_bool) = (select false)
|
||||||
|
RETURNING *;
|
||||||
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
|
HINT: Sort the columns on the left side by physical order.
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
||||||
, (col_text, col_bool) = (select 'not ok', false)
|
, (col_text, col_bool) = (select 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type integer
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
||||||
, (col_text, col_bool) = (select 'not ok', false)
|
, (col_text, col_bool) = (select 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type integer
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
--
|
--
|
||||||
-- more restrictive ones, just in case we miss a wrong value
|
-- more restrictive ones, just in case we miss a wrong value
|
||||||
--
|
--
|
||||||
|
@ -209,10 +219,10 @@ UPDATE test_ref_indirection
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 06-06-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 06-06-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 06-06-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
|
@ -220,10 +230,10 @@ UPDATE test_dist_indirection
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 06-06-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 06-06-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 06-06-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
|
@ -232,7 +242,7 @@ WHERE id = 1
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
|
@ -241,60 +251,51 @@ WHERE id = 1
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM test_ref_indirection ORDER BY id;
|
SELECT * FROM test_ref_indirection ORDER BY id;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 06-06-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 06-06-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 06-06-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT * FROM test_dist_indirection ORDER BY id;
|
SELECT * FROM test_dist_indirection ORDER BY id;
|
||||||
id | col_bool | col_date | col_int | col_text
|
id | col_bool | col_date | col_int | col_text
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | t | 06-06-1970 | 1 | ok
|
1 | t | 01-01-1970 | 1 | ok
|
||||||
2 | t | 06-06-1970 | 1 | ok
|
2 | t | 01-01-1970 | 1 | ok
|
||||||
3 | t | 06-06-1970 | 1 | ok
|
3 | t | 01-01-1970 | 1 | ok
|
||||||
4 | t | 06-06-1970 | 1 | ok
|
4 | t | 01-01-1970 | 1 | ok
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
-- those should not
|
-- those should not
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
WHERE id = 2
|
WHERE id = 2
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
WHERE id = 2
|
WHERE id = 2
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- several updates in CTE shoult not work
|
-- several updates in CTE shoult not work
|
||||||
-- TODO wrong ERROR
|
|
||||||
with qq3 as (
|
with qq3 as (
|
||||||
update test_ref_indirection
|
update test_ref_indirection
|
||||||
SET (col_text, col_bool)
|
SET (col_text, col_bool)
|
||||||
|
@ -310,10 +311,8 @@ qq4 as (
|
||||||
returning *
|
returning *
|
||||||
)
|
)
|
||||||
select * from qq3 union all select * from qq4;
|
select * from qq3 union all select * from qq4;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
with qq3 as (
|
with qq3 as (
|
||||||
update test_dist_indirection
|
update test_dist_indirection
|
||||||
SET (col_text, col_bool)
|
SET (col_text, col_bool)
|
||||||
|
@ -329,9 +328,8 @@ qq4 as (
|
||||||
returning *
|
returning *
|
||||||
)
|
)
|
||||||
select * from qq3 union all select * from qq4;
|
select * from qq3 union all select * from qq4;
|
||||||
ERROR: column "col_bool" is of type boolean but expression is of type text
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
HINT: You will need to rewrite or cast the expression.
|
HINT: Sort the columns on the left side by physical order.
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
DROP TABLE test_dist_indirection;
|
DROP TABLE test_dist_indirection;
|
||||||
DROP TABLE test_dist_indirection_new;
|
DROP TABLE test_dist_indirection_new;
|
||||||
DROP TABLE test_ref_indirection;
|
DROP TABLE test_ref_indirection;
|
||||||
|
@ -351,6 +349,8 @@ SELECT create_reference_table('indirections.update_test');
|
||||||
UPDATE update_test
|
UPDATE update_test
|
||||||
SET (b,a) = (select a,b from update_test where b = 41 and c = 'car')
|
SET (b,a) = (select a,b from update_test where b = 41 and c = 'car')
|
||||||
WHERE a = 100 AND b = 20;
|
WHERE a = 100 AND b = 20;
|
||||||
|
ERROR: cannot plan distributed UPDATE SET (..) = (SELECT ...) query when not sorted by physical order
|
||||||
|
HINT: Sort the columns on the left side by physical order.
|
||||||
-- https://github.com/citusdata/citus/pull/5692
|
-- https://github.com/citusdata/citus/pull/5692
|
||||||
DROP SCHEMA indirections CASCADE;
|
DROP SCHEMA indirections CASCADE;
|
||||||
NOTICE: drop cascades to 2 other objects
|
NOTICE: drop cascades to 2 other objects
|
||||||
|
|
|
@ -65,43 +65,48 @@ SELECT * FROM test_dist_indirection_new ORDER BY id;
|
||||||
-- now UPDATEs
|
-- now UPDATEs
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_bool, col_date, col_int, col_text)
|
SET (col_bool, col_date, col_int, col_text)
|
||||||
= (SELECT true, '1970-12-31'::date, 1, 'ok')
|
= (SELECT true, '1970-01-01'::date, 1, 'ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_bool, col_date, col_int, col_text)
|
SET (col_bool, col_date, col_int, col_text)
|
||||||
= (SELECT true, '1970-12-31'::date, 1, 'ok')
|
= (SELECT true, '1970-01-01'::date, 1, 'ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_bool, col_date) = (select true, '1970-06-06'::date)
|
SET (col_bool, col_date) = (select true, '1970-01-01'::date)
|
||||||
, (col_int, col_text) = (select 1, 'still ok')
|
, (col_int, col_text) = (select 1, 'still ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_bool, col_date) = (select true, '1970-06-06'::date)
|
SET (col_bool, col_date) = (select true, '1970-01-01'::date)
|
||||||
, (col_int, col_text) = (select 1, 'still ok')
|
, (col_int, col_text) = (select 1, 'still ok')
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
|
UPDATE test_ref_indirection
|
||||||
|
SET (col_bool, col_int) = (select true, 1)
|
||||||
|
, (col_text) = (select 'ok')
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
SELECT * FROM test_ref_indirection ORDER BY id;
|
SELECT * FROM test_ref_indirection ORDER BY id;
|
||||||
SELECT * FROM test_dist_indirection ORDER BY id;
|
SELECT * FROM test_dist_indirection ORDER BY id;
|
||||||
|
|
||||||
-- but those should not:
|
-- but those should not:
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_date, col_text, col_int, col_bool)
|
SET (col_date, col_text, col_int, col_bool)
|
||||||
= (SELECT '1970-12-31'::date, 'not ok', 2, false)
|
= (SELECT '1970-06-06'::date, 'not ok', 2, false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_date, col_text, col_int, col_bool)
|
SET (col_date, col_text, col_int, col_bool)
|
||||||
= (SELECT '1970-12-31'::date, 'not ok', 2, false)
|
= (SELECT '1970-06-06'::date, 'not ok', 2, false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- TODO wrong ERROR
|
UPDATE test_ref_indirection
|
||||||
|
SET (col_int, col_text) = (select 2, 'not ok')
|
||||||
|
, (col_bool) = (select false)
|
||||||
|
RETURNING *;
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
||||||
, (col_text, col_bool) = (select 'not ok', false)
|
, (col_text, col_bool) = (select 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
SET (col_int, col_date) = (select 2, '1970-06-06'::date)
|
||||||
, (col_text, col_bool) = (select 'not ok', false)
|
, (col_text, col_bool) = (select 'not ok', false)
|
||||||
|
@ -131,28 +136,23 @@ SELECT * FROM test_ref_indirection ORDER BY id;
|
||||||
SELECT * FROM test_dist_indirection ORDER BY id;
|
SELECT * FROM test_dist_indirection ORDER BY id;
|
||||||
|
|
||||||
-- those should not
|
-- those should not
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_ref_indirection
|
UPDATE test_ref_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
WHERE id = 2
|
WHERE id = 2
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
-- TODO wrong ERROR
|
|
||||||
UPDATE test_dist_indirection
|
UPDATE test_dist_indirection
|
||||||
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
SET (col_text, col_bool) = (SELECT 'not ok', false)
|
||||||
WHERE id = 2
|
WHERE id = 2
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- several updates in CTE shoult not work
|
-- several updates in CTE shoult not work
|
||||||
-- TODO wrong ERROR
|
|
||||||
with qq3 as (
|
with qq3 as (
|
||||||
update test_ref_indirection
|
update test_ref_indirection
|
||||||
SET (col_text, col_bool)
|
SET (col_text, col_bool)
|
||||||
|
@ -168,7 +168,6 @@ qq4 as (
|
||||||
returning *
|
returning *
|
||||||
)
|
)
|
||||||
select * from qq3 union all select * from qq4;
|
select * from qq3 union all select * from qq4;
|
||||||
-- TODO wrong ERROR
|
|
||||||
with qq3 as (
|
with qq3 as (
|
||||||
update test_dist_indirection
|
update test_dist_indirection
|
||||||
SET (col_text, col_bool)
|
SET (col_text, col_bool)
|
||||||
|
|
Loading…
Reference in New Issue