parallel_update_2.out 1.5 KB
Newer Older
J
Jimmy Yih 已提交
1 2 3
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
-- 
4 5 6 7 8 9
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
J
Jimmy Yih 已提交
10

11 12 13 14 15 16
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE

-- The actual test begins
J
Jimmy Yih 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
1: BEGIN;
BEGIN
2: BEGIN;
BEGIN
2: UPDATE ao SET b = 42 WHERE a = 1;
UPDATE 1
2: SELECT * FROM locktest WHERE coalesce = 'ao';
coalesce|mode               |locktype                
--------+-------------------+------------------------
ao      |AccessExclusiveLock|append-only segment file
ao      |ExclusiveLock      |relation                
(2 rows)
1&: UPDATE ao SET b = 42 WHERE a = 2;  <waiting ...>
2: COMMIT;
COMMIT
1<:  <... completed>
UPDATE 1
1: COMMIT;
COMMIT
3: SELECT * FROM ao WHERE a < 5 ORDER BY a;
a|b 
-+--
1|42
2|42
3|3 
4|4 
(4 rows)
44
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
J
Jimmy Yih 已提交
45 46 47 48
tid             |segno|row_num
----------------+-----+-------
(33554432,32769)|1    |1      
(1 row)