update.out 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --
  2. -- UPDATE syntax tests
  3. --
  4. CREATE TABLE update_test (
  5. a INT DEFAULT 10,
  6. b INT,
  7. c TEXT
  8. );
  9. CREATE TABLE upsert_test (
  10. a INT PRIMARY KEY,
  11. b TEXT
  12. );
  13. INSERT INTO update_test VALUES (5, 10, 'foo');
  14. INSERT INTO update_test(b, a) VALUES (15, 10);
  15. SELECT * FROM update_test;
  16. a | b | c
  17. ----+----+-----
  18. 5 | 10 | foo
  19. 10 | 15 |
  20. (2 rows)
  21. --
  22. -- Test multiple-set-clause syntax
  23. --
  24. INSERT INTO update_test SELECT a,b+1,c FROM update_test;
  25. -- Test ON CONFLICT DO UPDATE
  26. INSERT INTO upsert_test VALUES(1, 'Boo'), (3, 'Zoo');
  27. DROP TABLE update_test;
  28. DROP TABLE upsert_test;
  29. CREATE TABLE upsert_test_2 (b TEXT, a INT PRIMARY KEY);
  30. -- Create partitions intentionally in descending bound order, so as to test
  31. -- that update-row-movement works with the leaf partitions not in bound order.
  32. CREATE TABLE part_b_20_b_30 (e varchar, c numeric, a text, b bigint, d int);
  33. CREATE TABLE part_c_1_100 (e varchar, d int, c numeric, b bigint, a text);
  34. \set init_range_parted 'truncate range_parted; insert into range_parted VALUES (''a'', 1, 1, 1), (''a'', 10, 200, 1), (''b'', 12, 96, 1), (''b'', 13, 97, 2), (''b'', 15, 105, 16), (''b'', 17, 105, 19)'
  35. \set show_data 'select tableoid::regclass::text COLLATE "C" partname, * from range_parted ORDER BY 1, 2, 3, 4, 5, 6'
  36. -- Common table needed for multiple test scenarios.
  37. CREATE TABLE mintab(c1 int);
  38. INSERT into mintab VALUES (120);
  39. DROP TABLE mintab;
  40. CREATE TABLE sub_part1(b int, c int8, a numeric);
  41. CREATE TABLE sub_part2(b int, c int8, a numeric);
  42. CREATE TABLE list_part1(a numeric, b int, c int8);
  43. -- UPDATE partition-key with FROM clause. If join produces multiple output
  44. -- rows for the same row to be modified, we should tuple-route the row only
  45. -- once. There should not be any rows inserted.
  46. CREATE TABLE non_parted (id int);
  47. INSERT into non_parted VALUES (1), (1), (1), (2), (2), (2), (3), (3), (3);
  48. DROP TABLE non_parted;