Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A detailed introduction to PostgreSQL version identification

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Today's editor to share with you is a detailed introduction of PostgreSQL version identification, I believe many people do not know much, in order to let you know more about PostgreSQL version identification, so give you a summary of the following content, let's look down. I'm sure you'll get something.

Insert\ delete\ update locates through the ctid and looks at the changes to the record xmin\ xmax.

Xid: transactional ID of the database

Xmin: the xid information of the row header. Xmin represents the transaction ID that inserted the record.

Xmax: indicates the transaction ID that deletes or lock the record

Xid_snapshot: the transaction that is ending in the current cluster

Clog: transaction commit status log

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

1) check which functions are related to xid. What is needed here is the txid_current function.

2) you can see the current transaction ID

Postgres=# select * from txid_current (); txid_current- 1676 (1 row) 3) after insert, the transaction ID has been + 1postgres=# insert into tt values (1); INSERT 0 1postgres=# select ctid,xmin,xmax,cmin,cmax,id from tt Ctid | xmin | xmax | cmin | cmax | id-+---- (0jue 1) | 1677 | 0 | 0 | 1 (1 row)

4) after starting a transaction, update

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

5) View in another session

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

Look at currently unfinished transactions, or unopened transactions

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

Record whether the transaction is committed. In this file, bit:

-rw-. 1 pg pg 8192 Jun 10 04:19 0000 [pg@localhost pg_clog] $pwd/home/pg/data/pg_clog

The above is a detailed introduction to the identification of the PostgreSQL version. Have you gained anything after reading it? If you want to know more about it, welcome to the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report