mirror of https://github.com/citusdata/citus.git
Allow references to columns in UPDATE statements
parent
0ce1e3ddaf
commit
1d1d95f80f
|
@ -272,7 +272,7 @@ ErrorIfModifyQueryNotSupported(Query *queryTree)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsA(targetEntry->expr, Const))
|
||||
if (contain_mutable_functions((Node *) targetEntry->expr))
|
||||
{
|
||||
hasNonConstTargetEntryExprs = true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
CREATE TABLE modifications (
|
||||
key VARCHAR,
|
||||
counter INT,
|
||||
time TIMESTAMPTZ
|
||||
);
|
||||
SELECT master_create_distributed_table('modifications', 'key', 'hash');
|
||||
master_create_distributed_table
|
||||
---------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT master_create_worker_shards('modifications', 4, 1);
|
||||
master_create_worker_shards
|
||||
-----------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO modifications VALUES ('one', 0, null);
|
||||
UPDATE modifications SET counter = counter + 1;
|
||||
ERROR: distributed modifications must target exactly one shard
|
||||
UPDATE modifications SET counter = counter + 1 WHERE key = 'one';
|
||||
UPDATE modifications SET time = now() WHERE key = 'one';
|
||||
ERROR: cannot plan sharded modification containing values which are not constants or constant expressions
|
||||
SELECT * FROM modifications;
|
||||
key | counter | time
|
||||
-----+---------+------
|
||||
one | 1 |
|
||||
(1 row)
|
||||
|
||||
DROP TABLE modifications;
|
|
@ -141,3 +141,9 @@ test: multi_large_shardid
|
|||
# multi_drop_extension makes sure we can safely drop and recreate the extension
|
||||
# ----------
|
||||
test: multi_drop_extension
|
||||
|
||||
# ----------
|
||||
# multi_expanded_modifications includes some tests that we can reference columns in
|
||||
# UPDATEs
|
||||
# ----------
|
||||
test: multi_expanded_modifications
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
CREATE TABLE modifications (
|
||||
key VARCHAR,
|
||||
counter INT,
|
||||
time TIMESTAMPTZ
|
||||
);
|
||||
SELECT master_create_distributed_table('modifications', 'key', 'hash');
|
||||
SELECT master_create_worker_shards('modifications', 4, 1);
|
||||
|
||||
INSERT INTO modifications VALUES ('one', 0, null);
|
||||
|
||||
UPDATE modifications SET counter = counter + 1;
|
||||
|
||||
UPDATE modifications SET counter = counter + 1 WHERE key = 'one';
|
||||
|
||||
UPDATE modifications SET time = now() WHERE key = 'one';
|
||||
|
||||
SELECT * FROM modifications;
|
||||
|
||||
DROP TABLE modifications;
|
Loading…
Reference in New Issue