Home  >  Article  >  Database  >  Detailed explanation of PostgreSQL version identification

Detailed explanation of PostgreSQL version identification

jacklove
jackloveOriginal
2018-06-11 17:22:422331browse

Insert\delete\updateLocate via ctid, and view the changes in the record xmin\xmax.

Xid: Database transaction ID;

Xmin: Row header xidInformation, xmin represents the transaction that inserted the recordID

Xmax : Indicates deletion or lockThe transaction of this recordID

xid_snapshot: Ended in the current cluster Transaction

Clog: Transaction submission status log

Definition of record format: htup_details.h:POSTGRES heap tuple header definitions.

1) View all xid related functions. What is needed here is txid_currentFunction

##2)

can be seen Current transaction ID

postgres=# select * from txid_current();
 txid_current
--------------
         1676
(1 row)
 
3)进行一次insert后,看事务ID已经+1
postgres=# insert into tt values(1);
INSERT 0 1
postgres=# select ctid,xmin,xmax,cmin,cmax,id from tt;
 ctid  | xmin | xmax | cmin | cmax | id
-------+------+------+------+------+----
 (0,1) | 1677 |    0 |    0 |    0 |  1
(1 row)

4)

After opening a transaction, proceed update

postgres=# begin;
BEGIN
 
postgres=# update tt set id=3;
UPDATE 1
postgres=# select ctid,xmin,xmax,cmin,cmax,id from tt;
 ctid  | xmin | xmax | cmin | cmax | id
-------+------+------+------+------+----
 (0,2) | 1678 |    0 |    0 |    0 |  3
(1 row)

5) View

postgres=#  select ctid,xmin,xmax,cmin,cmax,id from tt;
 ctid  | xmin | xmax | cmin | cmax | id
-------+------+------+------+------+----
 (0,1) | 1677 | 1678 |    0 |    0 |  1
(1 row)


## in another session to see the current unfinished transactions or unopened transactions Transaction

##

postgres=# select *from txid_current_snapshot();
 txid_current_snapshot
-----------------------
 1684:1684:
(1 row)
 
postgres=# select * from txid_current();
 txid_current
--------------
         1684
(1 row)

Record whether the transaction is submitted, in In this file,

bit

:

-rw-------. 1 pg pg 8192 Jun 10 04:19 0000
[pg@localhost pg_clog]$ pwd
/home/pg/data/pg_clog
This article introduces PostgreSQL version identification. For more related content, please pay attention to the php Chinese website.

Related recommendations:

Explain what B/S and C/S are


How to achieve it through css3 html5 Vertical menu


#Related explanations about HTML5 local storage

The above is the detailed content of Detailed explanation of PostgreSQL version identification. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn