summaryrefslogtreecommitdiff
path: root/src/test/regress/sql/update.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress/sql/update.sql')
-rw-r--r--src/test/regress/sql/update.sql26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/test/regress/sql/update.sql b/src/test/regress/sql/update.sql
index 51007b2ff1..2df2995810 100644
--- a/src/test/regress/sql/update.sql
+++ b/src/test/regress/sql/update.sql
@@ -1,14 +1,15 @@
--
--- UPDATE ... SET <col> = DEFAULT;
+-- UPDATE syntax tests
--
CREATE TABLE update_test (
a INT DEFAULT 10,
- b INT
+ b INT,
+ c TEXT
);
-INSERT INTO update_test VALUES (5, 10);
-INSERT INTO update_test VALUES (10, 15);
+INSERT INTO update_test VALUES (5, 10, 'foo');
+INSERT INTO update_test(b, a) VALUES (15, 10);
SELECT * FROM update_test;
@@ -30,10 +31,25 @@ SELECT * FROM update_test;
--
UPDATE update_test SET a=v.i FROM (VALUES(100, 20)) AS v(i, j)
- WHERE update_test.b = v.j;
+ WHERE update_test.b = v.j;
SELECT * FROM update_test;
+--
+-- Test multiple-set-clause syntax
+--
+
+UPDATE update_test SET (c,b,a) = ('bugle', b+11, DEFAULT) WHERE c = 'foo';
+SELECT * FROM update_test;
+UPDATE update_test SET (c,b) = ('car', a+b), a = a + 1 WHERE a = 10;
+SELECT * FROM update_test;
+-- fail, multi assignment to same column:
+UPDATE update_test SET (c,b) = ('car', a+b), b = a + 1 WHERE a = 10;
+
+-- XXX this should work, but doesn't yet:
+UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo')
+ WHERE a = 10;
+
-- if an alias for the target table is specified, don't allow references
-- to the original table name
BEGIN;