Get the App
SLTechnology News&Howtos  ›  Database  › 

A detailed introduction to PostgreSQL version identification

Shulou Source: shulou.com Published: 2022-06-01 20:44:18 10月05日 Update

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!

Tags: Transaction version content function information header that is data database file log more format status see industry information cluster change location Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi Docker Shulou Information Linux