| -- @Description Tests that a delete operation in progress will block all other deletes |
| -- until the transaction is committed. |
| -- |
| DROP TABLE IF EXISTS ao; |
| DROP |
| CREATE TABLE ao (a INT) USING @amname@ DISTRIBUTED BY (a); |
| CREATE |
| insert into ao select generate_series(1,100); |
| INSERT 100 |
| |
| -- The actual test begins |
| 1: BEGIN; |
| BEGIN |
| 2: BEGIN; |
| BEGIN |
| 2: DELETE FROM ao WHERE a = 2; |
| DELETE 1 |
| 2: SELECT * FROM locktest_master WHERE coalesce = 'ao'; |
| coalesce | mode | locktype | node |
| ----------+---------------+----------+-------- |
| ao | ExclusiveLock | relation | master |
| (1 row) |
| 2: SELECT * FROM locktest_segments WHERE coalesce = 'ao'; |
| coalesce | mode | locktype | node |
| ----------+---------------+----------+----------- |
| ao | ExclusiveLock | relation | 1 segment |
| (1 row) |
| -- The case here should delete a tuple at the same seg with(2). |
| -- Under jump hash, (2) and (3) are on the same seg(seg0). |
| 1&: DELETE FROM ao WHERE a = 3; <waiting ...> |
| 2: COMMIT; |
| COMMIT |
| 1<: <... completed> |
| DELETE 1 |
| 1: COMMIT; |
| COMMIT |
| 3: BEGIN; |
| BEGIN |
| 3: SELECT * FROM ao WHERE a < 5 ORDER BY a; |
| a |
| --- |
| 1 |
| 4 |
| (2 rows) |
| 3: COMMIT; |
| COMMIT |
| 0U: SELECT * FROM gp_toolkit.__gp_aovisimap('ao'); |
| tid | segno | row_num |
| --------------+-------+--------- |
| (33554432,2) | 1 | 1 |
| (33554432,3) | 1 | 2 |
| (2 rows) |