4.4、事务读一致性REPEATABLE READ

这种事务级别表示事务自始至终读取的数据都是一致的,如下所示

session1

  1. postgres=# create table t_repeatable_read (id int,mc text);
  2. NOTICE: Replica identity is needed for shard table, please add to this table through "alter table" command.
  3. CREATE TABLE
  4. postgres=# insert into t_repeatable_read values(1,'tbase');
  5. INSERT 0 1
  6. postgres=# begin isolation level repeatable read ;
  7. BEGIN
  8. postgres=# select * from t_repeatable_read ;
  9. id | mc
  10. ----+-------
  11. 1 | tbase
  12. (1 row)

session2

  1. postgres=# insert into t_repeatable_read values(1,'pgxz');
  2. INSERT 0 1
  3. postgres=# select * from t_repeatable_read;
  4. id | mc
  5. ----+-------
  6. 1 | tbase
  7. 1 | pgxz
  8. (2 rows)

session1

  1. postgres=# select * from t_repeatable_read ;
  2. id | mc
  3. ----+-------
  4. 1 | tbase
  5. (1 row)
  6. postgres=#