diff options
| author | Simon Riggs | 2018-04-12 10:22:56 +0000 |
|---|---|---|
| committer | Simon Riggs | 2018-04-12 10:22:56 +0000 |
| commit | 08ea7a2291db21a618d19d612c8060cda68f1892 (patch) | |
| tree | 4d10675439742c7206e089bd21e793332562ae83 /src/test/isolation | |
| parent | c9c875a28fa6cbc38c227fb9e656dd7be948166f (diff) | |
Revert MERGE patch
This reverts commits d204ef63776b8a00ca220adec23979091564e465,
83454e3c2b28141c0db01c7d2027e01040df5249 and a few more commits thereafter
(complete list at the end) related to MERGE feature.
While the feature was fully functional, with sufficient test coverage and
necessary documentation, it was felt that some parts of the executor and
parse-analyzer can use a different design and it wasn't possible to do that in
the available time. So it was decided to revert the patch for PG11 and retry
again in the future.
Thanks again to all reviewers and bug reporters.
List of commits reverted, in reverse chronological order:
f1464c5380 Improve parse representation for MERGE
ddb4158579 MERGE syntax diagram correction
530e69e59b Allow cpluspluscheck to pass by renaming variable
01b88b4df5 MERGE minor errata
3af7b2b0d4 MERGE fix variable warning in non-assert builds
a5d86181ec MERGE INSERT allows only one VALUES clause
4b2d44031f MERGE post-commit review
4923550c20 Tab completion for MERGE
aa3faa3c7a WITH support in MERGE
83454e3c2b New files for MERGE
d204ef6377 MERGE SQL Command following SQL:2016
Author: Pavan Deolasee
Reviewed-by: Michael Paquier
Diffstat (limited to 'src/test/isolation')
| -rw-r--r-- | src/test/isolation/expected/merge-delete.out | 97 | ||||
| -rw-r--r-- | src/test/isolation/expected/merge-insert-update.out | 84 | ||||
| -rw-r--r-- | src/test/isolation/expected/merge-match-recheck.out | 106 | ||||
| -rw-r--r-- | src/test/isolation/expected/merge-update.out | 238 | ||||
| -rw-r--r-- | src/test/isolation/isolation_schedule | 4 | ||||
| -rw-r--r-- | src/test/isolation/specs/merge-delete.spec | 51 | ||||
| -rw-r--r-- | src/test/isolation/specs/merge-insert-update.spec | 52 | ||||
| -rw-r--r-- | src/test/isolation/specs/merge-match-recheck.spec | 79 | ||||
| -rw-r--r-- | src/test/isolation/specs/merge-update.spec | 133 |
9 files changed, 0 insertions, 844 deletions
diff --git a/src/test/isolation/expected/merge-delete.out b/src/test/isolation/expected/merge-delete.out deleted file mode 100644 index 40e62901b70..00000000000 --- a/src/test/isolation/expected/merge-delete.out +++ /dev/null @@ -1,97 +0,0 @@ -Parsed test spec with 2 sessions - -starting permutation: delete c1 select2 c2 -step delete: DELETE FROM target t WHERE t.key = 1; -step c1: COMMIT; -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: merge_delete c1 select2 c2 -step merge_delete: MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; -step c1: COMMIT; -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: delete c1 update1 select2 c2 -step delete: DELETE FROM target t WHERE t.key = 1; -step c1: COMMIT; -step update1: UPDATE target t SET val = t.val || ' updated by update1' WHERE t.key = 1; -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: merge_delete c1 update1 select2 c2 -step merge_delete: MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; -step c1: COMMIT; -step update1: UPDATE target t SET val = t.val || ' updated by update1' WHERE t.key = 1; -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: delete c1 merge2 select2 c2 -step delete: DELETE FROM target t WHERE t.key = 1; -step c1: COMMIT; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2a' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -step select2: SELECT * FROM target; -key val - -1 merge2a -step c2: COMMIT; - -starting permutation: merge_delete c1 merge2 select2 c2 -step merge_delete: MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; -step c1: COMMIT; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2a' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -step select2: SELECT * FROM target; -key val - -1 merge2a -step c2: COMMIT; - -starting permutation: delete update1 c1 select2 c2 -step delete: DELETE FROM target t WHERE t.key = 1; -step update1: UPDATE target t SET val = t.val || ' updated by update1' WHERE t.key = 1; <waiting ...> -step c1: COMMIT; -step update1: <... completed> -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: merge_delete update1 c1 select2 c2 -step merge_delete: MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; -step update1: UPDATE target t SET val = t.val || ' updated by update1' WHERE t.key = 1; <waiting ...> -step c1: COMMIT; -step update1: <... completed> -step select2: SELECT * FROM target; -key val - -step c2: COMMIT; - -starting permutation: delete merge2 c1 select2 c2 -step delete: DELETE FROM target t WHERE t.key = 1; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2a' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; <waiting ...> -step c1: COMMIT; -step merge2: <... completed> -step select2: SELECT * FROM target; -key val - -1 merge2a -step c2: COMMIT; - -starting permutation: merge_delete merge2 c1 select2 c2 -step merge_delete: MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2a' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; <waiting ...> -step c1: COMMIT; -step merge2: <... completed> -step select2: SELECT * FROM target; -key val - -1 merge2a -step c2: COMMIT; diff --git a/src/test/isolation/expected/merge-insert-update.out b/src/test/isolation/expected/merge-insert-update.out deleted file mode 100644 index 317fa16a3d5..00000000000 --- a/src/test/isolation/expected/merge-insert-update.out +++ /dev/null @@ -1,84 +0,0 @@ -Parsed test spec with 2 sessions - -starting permutation: merge1 c1 select2 c2 -step merge1: MERGE INTO target t USING (SELECT 1 as key, 'merge1' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge1'; -step c1: COMMIT; -step select2: SELECT * FROM target; -key val - -1 merge1 -step c2: COMMIT; - -starting permutation: merge1 c1 merge2 select2 c2 -step merge1: MERGE INTO target t USING (SELECT 1 as key, 'merge1' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge1'; -step c1: COMMIT; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; -step select2: SELECT * FROM target; -key val - -1 merge1 updated by merge2 -step c2: COMMIT; - -starting permutation: insert1 merge2 c1 select2 c2 -step insert1: INSERT INTO target VALUES (1, 'insert1'); -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; <waiting ...> -step c1: COMMIT; -step merge2: <... completed> -error in steps c1 merge2: ERROR: duplicate key value violates unique constraint "target_pkey" -step select2: SELECT * FROM target; -ERROR: current transaction is aborted, commands ignored until end of transaction block -step c2: COMMIT; - -starting permutation: merge1 merge2 c1 select2 c2 -step merge1: MERGE INTO target t USING (SELECT 1 as key, 'merge1' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge1'; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; <waiting ...> -step c1: COMMIT; -step merge2: <... completed> -error in steps c1 merge2: ERROR: duplicate key value violates unique constraint "target_pkey" -step select2: SELECT * FROM target; -ERROR: current transaction is aborted, commands ignored until end of transaction block -step c2: COMMIT; - -starting permutation: merge1 merge2 a1 select2 c2 -step merge1: MERGE INTO target t USING (SELECT 1 as key, 'merge1' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge1'; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; <waiting ...> -step a1: ABORT; -step merge2: <... completed> -step select2: SELECT * FROM target; -key val - -1 merge2 -step c2: COMMIT; - -starting permutation: delete1 insert1 c1 merge2 select2 c2 -step delete1: DELETE FROM target WHERE key = 1; -step insert1: INSERT INTO target VALUES (1, 'insert1'); -step c1: COMMIT; -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; -step select2: SELECT * FROM target; -key val - -1 insert1 updated by merge2 -step c2: COMMIT; - -starting permutation: delete1 insert1 merge2 c1 select2 c2 -step delete1: DELETE FROM target WHERE key = 1; -step insert1: INSERT INTO target VALUES (1, 'insert1'); -step merge2: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; <waiting ...> -step c1: COMMIT; -step merge2: <... completed> -error in steps c1 merge2: ERROR: duplicate key value violates unique constraint "target_pkey" -step select2: SELECT * FROM target; -ERROR: current transaction is aborted, commands ignored until end of transaction block -step c2: COMMIT; - -starting permutation: delete1 insert1 merge2i c1 select2 c2 -step delete1: DELETE FROM target WHERE key = 1; -step insert1: INSERT INTO target VALUES (1, 'insert1'); -step merge2i: MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; -step c1: COMMIT; -step select2: SELECT * FROM target; -key val - -1 insert1 -step c2: COMMIT; diff --git a/src/test/isolation/expected/merge-match-recheck.out b/src/test/isolation/expected/merge-match-recheck.out deleted file mode 100644 index 96a9f45ac88..00000000000 --- a/src/test/isolation/expected/merge-match-recheck.out +++ /dev/null @@ -1,106 +0,0 @@ -Parsed test spec with 2 sessions - -starting permutation: update1 merge_status c2 select1 c1 -step update1: UPDATE target t SET balance = balance + 10, val = t.val || ' updated by update1' WHERE t.key = 1; -step merge_status: - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND status = 's1' THEN - UPDATE SET status = 's2', val = t.val || ' when1' - WHEN MATCHED AND status = 's2' THEN - UPDATE SET status = 's3', val = t.val || ' when2' - WHEN MATCHED AND status = 's3' THEN - UPDATE SET status = 's4', val = t.val || ' when3'; - <waiting ...> -step c2: COMMIT; -step merge_status: <... completed> -step select1: SELECT * FROM target; -key balance status val - -1 170 s2 setup updated by update1 when1 -step c1: COMMIT; - -starting permutation: update2 merge_status c2 select1 c1 -step update2: UPDATE target t SET status = 's2', val = t.val || ' updated by update2' WHERE t.key = 1; -step merge_status: - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND status = 's1' THEN - UPDATE SET status = 's2', val = t.val || ' when1' - WHEN MATCHED AND status = 's2' THEN - UPDATE SET status = 's3', val = t.val || ' when2' - WHEN MATCHED AND status = 's3' THEN - UPDATE SET status = 's4', val = t.val || ' when3'; - <waiting ...> -step c2: COMMIT; -step merge_status: <... completed> -step select1: SELECT * FROM target; -key balance status val - -1 160 s3 setup updated by update2 when2 -step c1: COMMIT; - -starting permutation: update3 merge_status c2 select1 c1 -step update3: UPDATE target t SET status = 's3', val = t.val || ' updated by update3' WHERE t.key = 1; -step merge_status: - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND status = 's1' THEN - UPDATE SET status = 's2', val = t.val || ' when1' - WHEN MATCHED AND status = 's2' THEN - UPDATE SET status = 's3', val = t.val || ' when2' - WHEN MATCHED AND status = 's3' THEN - UPDATE SET status = 's4', val = t.val || ' when3'; - <waiting ...> -step c2: COMMIT; -step merge_status: <... completed> -step select1: SELECT * FROM target; -key balance status val - -1 160 s4 setup updated by update3 when3 -step c1: COMMIT; - -starting permutation: update5 merge_status c2 select1 c1 -step update5: UPDATE target t SET status = 's5', val = t.val || ' updated by update5' WHERE t.key = 1; -step merge_status: - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND status = 's1' THEN - UPDATE SET status = 's2', val = t.val || ' when1' - WHEN MATCHED AND status = 's2' THEN - UPDATE SET status = 's3', val = t.val || ' when2' - WHEN MATCHED AND status = 's3' THEN - UPDATE SET status = 's4', val = t.val || ' when3'; - <waiting ...> -step c2: COMMIT; -step merge_status: <... completed> -step select1: SELECT * FROM target; -key balance status val - -1 160 s5 setup updated by update5 -step c1: COMMIT; - -starting permutation: update_bal1 merge_bal c2 select1 c1 -step update_bal1: UPDATE target t SET balance = 50, val = t.val || ' updated by update_bal1' WHERE t.key = 1; -step merge_bal: - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND balance < 100 THEN - UPDATE SET balance = balance * 2, val = t.val || ' when1' - WHEN MATCHED AND balance < 200 THEN - UPDATE SET balance = balance * 4, val = t.val || ' when2' - WHEN MATCHED AND balance < 300 THEN - UPDATE SET balance = balance * 8, val = t.val || ' when3'; - <waiting ...> -step c2: COMMIT; -step merge_bal: <... completed> -step select1: SELECT * FROM target; -key balance status val - -1 100 s1 setup updated by update_bal1 when1 -step c1: COMMIT; diff --git a/src/test/isolation/expected/merge-update.out b/src/test/isolation/expected/merge-update.out deleted file mode 100644 index 00069a3e459..00000000000 --- a/src/test/isolation/expected/merge-update.out +++ /dev/null @@ -1,238 +0,0 @@ -Parsed test spec with 2 sessions - -starting permutation: merge1 c1 select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step c1: COMMIT; -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge1 -step c2: COMMIT; - -starting permutation: merge1 c1 merge2a select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step c1: COMMIT; -step merge2a: - MERGE INTO target t - USING (SELECT 1 as key, 'merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge1 -1 merge2a -step c2: COMMIT; - -starting permutation: merge1 merge2a c1 select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step merge2a: - MERGE INTO target t - USING (SELECT 1 as key, 'merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step c1: COMMIT; -step merge2a: <... completed> -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge1 -1 merge2a -step c2: COMMIT; - -starting permutation: merge1 merge2a a1 select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step merge2a: - MERGE INTO target t - USING (SELECT 1 as key, 'merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step a1: ABORT; -step merge2a: <... completed> -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge2a -step c2: COMMIT; - -starting permutation: merge1 merge2b c1 select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step merge2b: - MERGE INTO target t - USING (SELECT 1 as key, 'merge2b' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED AND t.key < 2 THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step c1: COMMIT; -step merge2b: <... completed> -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge1 -1 merge2b -step c2: COMMIT; - -starting permutation: merge1 merge2c c1 select2 c2 -step merge1: - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step merge2c: - MERGE INTO target t - USING (SELECT 1 as key, 'merge2c' as val) s - ON s.key = t.key AND t.key < 2 - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step c1: COMMIT; -step merge2c: <... completed> -step select2: SELECT * FROM target; -key val - -2 setup1 updated by merge1 -1 merge2c -step c2: COMMIT; - -starting permutation: pa_merge1 pa_merge2a c1 pa_select2 c2 -step pa_merge1: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set val = t.val || ' updated by ' || s.val; - -step pa_merge2a: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step c1: COMMIT; -step pa_merge2a: <... completed> -step pa_select2: SELECT * FROM pa_target; -key val - -2 initial -2 initial updated by pa_merge2a -step c2: COMMIT; - -starting permutation: pa_merge2 pa_merge2a c1 pa_select2 c2 -step pa_merge2: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step pa_merge2a: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - <waiting ...> -step c1: COMMIT; -step pa_merge2a: <... completed> -error in steps c1 pa_merge2a: ERROR: tuple to be deleted was already moved to another partition due to concurrent update -step pa_select2: SELECT * FROM pa_target; -ERROR: current transaction is aborted, commands ignored until end of transaction block -step c2: COMMIT; - -starting permutation: pa_merge2 c1 pa_merge2a pa_select2 c2 -step pa_merge2: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step c1: COMMIT; -step pa_merge2a: - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; - -step pa_select2: SELECT * FROM pa_target; -key val - -1 pa_merge2a -2 initial -2 initial updated by pa_merge1 -step c2: COMMIT; diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule index 4abad7c15ee..b3a34a8688d 100644 --- a/src/test/isolation/isolation_schedule +++ b/src/test/isolation/isolation_schedule @@ -33,10 +33,6 @@ test: insert-conflict-do-update test: insert-conflict-do-update-2 test: insert-conflict-do-update-3 test: insert-conflict-toast -test: merge-insert-update -test: merge-delete -test: merge-update -test: merge-match-recheck test: delete-abort-savept test: delete-abort-savept-2 test: aborted-keyrevoke diff --git a/src/test/isolation/specs/merge-delete.spec b/src/test/isolation/specs/merge-delete.spec deleted file mode 100644 index 656954f8474..00000000000 --- a/src/test/isolation/specs/merge-delete.spec +++ /dev/null @@ -1,51 +0,0 @@ -# MERGE DELETE -# -# This test looks at the interactions involving concurrent deletes -# comparing the behavior of MERGE, DELETE and UPDATE - -setup -{ - CREATE TABLE target (key int primary key, val text); - INSERT INTO target VALUES (1, 'setup1'); -} - -teardown -{ - DROP TABLE target; -} - -session "s1" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "delete" { DELETE FROM target t WHERE t.key = 1; } -step "merge_delete" { MERGE INTO target t USING (SELECT 1 as key) s ON s.key = t.key WHEN MATCHED THEN DELETE; } -step "c1" { COMMIT; } -step "a1" { ABORT; } - -session "s2" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "update1" { UPDATE target t SET val = t.val || ' updated by update1' WHERE t.key = 1; } -step "merge2" { MERGE INTO target t USING (SELECT 1 as key, 'merge2a' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; } -step "select2" { SELECT * FROM target; } -step "c2" { COMMIT; } - -# Basic effects -permutation "delete" "c1" "select2" "c2" -permutation "merge_delete" "c1" "select2" "c2" - -# One after the other, no concurrency -permutation "delete" "c1" "update1" "select2" "c2" -permutation "merge_delete" "c1" "update1" "select2" "c2" -permutation "delete" "c1" "merge2" "select2" "c2" -permutation "merge_delete" "c1" "merge2" "select2" "c2" - -# Now with concurrency -permutation "delete" "update1" "c1" "select2" "c2" -permutation "merge_delete" "update1" "c1" "select2" "c2" -permutation "delete" "merge2" "c1" "select2" "c2" -permutation "merge_delete" "merge2" "c1" "select2" "c2" diff --git a/src/test/isolation/specs/merge-insert-update.spec b/src/test/isolation/specs/merge-insert-update.spec deleted file mode 100644 index 704492be1f3..00000000000 --- a/src/test/isolation/specs/merge-insert-update.spec +++ /dev/null @@ -1,52 +0,0 @@ -# MERGE INSERT UPDATE -# -# This looks at how we handle concurrent INSERTs, illustrating how the -# behavior differs from INSERT ... ON CONFLICT - -setup -{ - CREATE TABLE target (key int primary key, val text); -} - -teardown -{ - DROP TABLE target; -} - -session "s1" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "merge1" { MERGE INTO target t USING (SELECT 1 as key, 'merge1' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge1'; } -step "delete1" { DELETE FROM target WHERE key = 1; } -step "insert1" { INSERT INTO target VALUES (1, 'insert1'); } -step "c1" { COMMIT; } -step "a1" { ABORT; } - -session "s2" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "merge2" { MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val) WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; } - -step "merge2i" { MERGE INTO target t USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2'; } - -step "select2" { SELECT * FROM target; } -step "c2" { COMMIT; } -step "a2" { ABORT; } - -# Basic effects -permutation "merge1" "c1" "select2" "c2" -permutation "merge1" "c1" "merge2" "select2" "c2" - -# check concurrent inserts -permutation "insert1" "merge2" "c1" "select2" "c2" -permutation "merge1" "merge2" "c1" "select2" "c2" -permutation "merge1" "merge2" "a1" "select2" "c2" - -# check how we handle when visible row has been concurrently deleted, then same key re-inserted -permutation "delete1" "insert1" "c1" "merge2" "select2" "c2" -permutation "delete1" "insert1" "merge2" "c1" "select2" "c2" -permutation "delete1" "insert1" "merge2i" "c1" "select2" "c2" diff --git a/src/test/isolation/specs/merge-match-recheck.spec b/src/test/isolation/specs/merge-match-recheck.spec deleted file mode 100644 index 193033da172..00000000000 --- a/src/test/isolation/specs/merge-match-recheck.spec +++ /dev/null @@ -1,79 +0,0 @@ -# MERGE MATCHED RECHECK -# -# This test looks at what happens when we have complex -# WHEN MATCHED AND conditions and a concurrent UPDATE causes a -# recheck of the AND condition on the new row - -setup -{ - CREATE TABLE target (key int primary key, balance integer, status text, val text); - INSERT INTO target VALUES (1, 160, 's1', 'setup'); -} - -teardown -{ - DROP TABLE target; -} - -session "s1" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "merge_status" -{ - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND status = 's1' THEN - UPDATE SET status = 's2', val = t.val || ' when1' - WHEN MATCHED AND status = 's2' THEN - UPDATE SET status = 's3', val = t.val || ' when2' - WHEN MATCHED AND status = 's3' THEN - UPDATE SET status = 's4', val = t.val || ' when3'; -} - -step "merge_bal" -{ - MERGE INTO target t - USING (SELECT 1 as key) s - ON s.key = t.key - WHEN MATCHED AND balance < 100 THEN - UPDATE SET balance = balance * 2, val = t.val || ' when1' - WHEN MATCHED AND balance < 200 THEN - UPDATE SET balance = balance * 4, val = t.val || ' when2' - WHEN MATCHED AND balance < 300 THEN - UPDATE SET balance = balance * 8, val = t.val || ' when3'; -} - -step "select1" { SELECT * FROM target; } -step "c1" { COMMIT; } -step "a1" { ABORT; } - -session "s2" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "update1" { UPDATE target t SET balance = balance + 10, val = t.val || ' updated by update1' WHERE t.key = 1; } -step "update2" { UPDATE target t SET status = 's2', val = t.val || ' updated by update2' WHERE t.key = 1; } -step "update3" { UPDATE target t SET status = 's3', val = t.val || ' updated by update3' WHERE t.key = 1; } -step "update5" { UPDATE target t SET status = 's5', val = t.val || ' updated by update5' WHERE t.key = 1; } -step "update_bal1" { UPDATE target t SET balance = 50, val = t.val || ' updated by update_bal1' WHERE t.key = 1; } -step "select2" { SELECT * FROM target; } -step "c2" { COMMIT; } - -# merge_status sees concurrently updated row and rechecks WHEN conditions, but recheck passes and final status = 's2' -permutation "update1" "merge_status" "c2" "select1" "c1" - -# merge_status sees concurrently updated row and rechecks WHEN conditions, recheck fails, so final status = 's3' not 's2' -permutation "update2" "merge_status" "c2" "select1" "c1" - -# merge_status sees concurrently updated row and rechecks WHEN conditions, recheck fails, so final status = 's4' not 's2' -permutation "update3" "merge_status" "c2" "select1" "c1" - -# merge_status sees concurrently updated row and rechecks WHEN conditions, recheck fails, but we skip update and MERGE does nothing -permutation "update5" "merge_status" "c2" "select1" "c1" - -# merge_bal sees concurrently updated row and rechecks WHEN conditions, recheck fails, so final balance = 100 not 640 -permutation "update_bal1" "merge_bal" "c2" "select1" "c1" diff --git a/src/test/isolation/specs/merge-update.spec b/src/test/isolation/specs/merge-update.spec deleted file mode 100644 index 625b477eb9f..00000000000 --- a/src/test/isolation/specs/merge-update.spec +++ /dev/null @@ -1,133 +0,0 @@ -# MERGE UPDATE -# -# This test exercises atypical cases -# 1. UPDATEs of PKs that change the join in the ON clause -# 2. UPDATEs with WHEN AND conditions that would fail after concurrent update -# 3. UPDATEs with extra ON conditions that would fail after concurrent update - -setup -{ - CREATE TABLE target (key int primary key, val text); - INSERT INTO target VALUES (1, 'setup1'); - - CREATE TABLE pa_target (key integer, val text) - PARTITION BY LIST (key); - CREATE TABLE part1 (key integer, val text); - CREATE TABLE part2 (val text, key integer); - CREATE TABLE part3 (key integer, val text); - - ALTER TABLE pa_target ATTACH PARTITION part1 FOR VALUES IN (1,4); - ALTER TABLE pa_target ATTACH PARTITION part2 FOR VALUES IN (2,5,6); - ALTER TABLE pa_target ATTACH PARTITION part3 DEFAULT; - - INSERT INTO pa_target VALUES (1, 'initial'); - INSERT INTO pa_target VALUES (2, 'initial'); -} - -teardown -{ - DROP TABLE target; - DROP TABLE pa_target CASCADE; -} - -session "s1" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "merge1" -{ - MERGE INTO target t - USING (SELECT 1 as key, 'merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "pa_merge1" -{ - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set val = t.val || ' updated by ' || s.val; -} -step "pa_merge2" -{ - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge1' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "c1" { COMMIT; } -step "a1" { ABORT; } - -session "s2" -setup -{ - BEGIN ISOLATION LEVEL READ COMMITTED; -} -step "merge2a" -{ - MERGE INTO target t - USING (SELECT 1 as key, 'merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "merge2b" -{ - MERGE INTO target t - USING (SELECT 1 as key, 'merge2b' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED AND t.key < 2 THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "merge2c" -{ - MERGE INTO target t - USING (SELECT 1 as key, 'merge2c' as val) s - ON s.key = t.key AND t.key < 2 - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "pa_merge2a" -{ - MERGE INTO pa_target t - USING (SELECT 1 as key, 'pa_merge2a' as val) s - ON s.key = t.key - WHEN NOT MATCHED THEN - INSERT VALUES (s.key, s.val) - WHEN MATCHED THEN - UPDATE set key = t.key + 1, val = t.val || ' updated by ' || s.val; -} -step "select2" { SELECT * FROM target; } -step "pa_select2" { SELECT * FROM pa_target; } -step "c2" { COMMIT; } - -# Basic effects -permutation "merge1" "c1" "select2" "c2" - -# One after the other, no concurrency -permutation "merge1" "c1" "merge2a" "select2" "c2" - -# Now with concurrency -permutation "merge1" "merge2a" "c1" "select2" "c2" -permutation "merge1" "merge2a" "a1" "select2" "c2" -permutation "merge1" "merge2b" "c1" "select2" "c2" -permutation "merge1" "merge2c" "c1" "select2" "c2" -permutation "pa_merge1" "pa_merge2a" "c1" "pa_select2" "c2" -permutation "pa_merge2" "pa_merge2a" "c1" "pa_select2" "c2" # fails -permutation "pa_merge2" "c1" "pa_merge2a" "pa_select2" "c2" # succeeds |
