• pg_export_snapshot函数


    psql (14.3)
    Type "help" for help.

    postgres=# \df+ pg_export_snapshot
    List of functions
    Schema | Name | Result data type | Argument data types | Type | Volatility | Parallel | Owner | Security | Access privileges | Language | Source code | Description
    ------------+--------------------+------------------+---------------------+------+------------+----------+----------+----------+-------------------+----------+--------------------+-------------------
    pg_catalog | pg_export_snapshot | text | | func | volatile | unsafe | postgres | invoker | | internal | pg_export_snapshot | export a snapshot
    (1 row)

    postgres=# \c tt;
    You are now connected to database "tt" as user "postgres".
    tt=# begin TRANSACTION ISOLATION LEVEL REPEATABLE READ;
    BEGIN
    Time: 0.150 ms
    tt=*# select * from t1 limit 10;
    id | name
    ----+-----------
    1 | 1_andyxi
    2 | 2_andyxi
    3 | 3_andyxi
    4 | 4_andyxi
    5 | 5_andyxi
    6 | 6_andyxi
    7 | 7_andyxi
    8 | 8_andyxi
    9 | 9_andyxi
    10 | 10_andyxi
    (10 rows)

    Time: 0.529 ms
    tt=*# select pg_export_snapshot(); ####查看当前快照
    pg_export_snapshot
    ---------------------
    00000004-00000118-1
    (1 row)

    Time: 0.290 ms

    [postgres@harbor pg_snapshots]$ ls -la
    总用量 8
    drwx------ 2 postgres postgres 33 9月 12 11:30 .
    drwx------ 20 postgres postgres 4096 9月 12 10:09 ..
    -rw------- 1 postgres postgres 89 9月 12 11:30 00000004-00000118-1  ###当前快照在/pgccc/pgdata/pg_snapshots目录下可以查看。
    [postgres@harbor pg_snapshots]$ pwd
    /pgccc/pgdata/pg_snapshots
    [postgres@harbor pg_snapshots]$

    1.适用于REPEATABLE READ和SERIALIZABLE事务中。

    2.在另一会话中我们可以导入这个快照。

    tt=# BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ ;
    BEGIN
    Time: 0.060 ms
    tt=*# set transaction SNAPSHOT '00000004-0000011D-1';
    SET
    Time: 0.147 ms
    tt=*# show tra
    trace_notify trace_sort track_activity_query_size track_counts track_io_timing transaction_deferrable transaction_read_only
    trace_recovery_messages track_activities track_commit_timestamp track_functions track_wal_io_timing transaction_isolation transform_null_equals
    tt=*# show transaction_isolation
    -#;
    transaction_isolation
    -----------------------
    repeatable read
    (1 row)

    Time: 0.510 ms
    tt=*# \q
    [postgres@harbor pg_snapshots]$ ls -la
    总用量 8
    drwx------ 2 postgres postgres 33 9月 12 11:45 .
    drwx------ 20 postgres postgres 4096 9月 12 10:09 ..
    -rw------- 1 postgres postgres 89 9月 12 11:45 00000004-0000011D-1

  • 相关阅读:
    洛谷P1428 小鱼比可爱 题解 枚举
    使用二分查找来判断一个有序序列中是否存在特定元素
    基础排序(冒泡、选择、插入)学习笔记
    CF1316B String Modification 题解 字符串模拟/找规律
    洛谷P2239 螺旋矩阵 题解 模拟
    洛谷P1076 寻宝 题解 模拟
    洛谷P1308 统计单词数 题解 模拟
    TypeError: unhashable type: 'dict'
    linux shell 多个命令一起执行的几种方法
    在Linux写shell脚本,执行python指令
  • 原文地址:https://www.cnblogs.com/chinaops/p/16685821.html
Copyright © 2020-2023  润新知