↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Data Types / Other built-in types

pg_lsn

PostgreSQL Log Sequence Number

Reading PostgreSQL 18.6.

PG10–20 core source inventory. Casts and operator classes show explicitly declared relationships; absent rows do not rule out coercions or indexing through other mechanisms.

Definition

PostgreSQL Log Sequence Number

pg_lsn
Catalog name
pg_catalog.pg_lsn
Type OID
3220
Type kind
Base type
Declared length
8 bytes
Storage strategy
plain
Input function
pg_lsn_in
Output function
pg_lsn_out

English manual

Read the complete manual section

Read the source definition

8.20. pg_lsn Type

The pg_lsn data type can be used to store LSN (Log Sequence Number) data which is a pointer to a location in the WAL. This type is a representation of XLogRecPtr and an internal system type of PostgreSQL.

Internally, an LSN is a 64-bit integer, representing a byte position in the write-ahead log stream. It is printed as two hexadecimal numbers of up to 8 digits each, separated by a slash; for example, 16/B374D848. The pg_lsn type supports the standard comparison operators, like = and >. Two LSNs can be subtracted using the - operator; the result is the number of bytes separating those write-ahead log locations. Also the number of bytes can be added into and subtracted from LSN using the +(pg_lsn,numeric) and -(pg_lsn,numeric) operators, respectively. Note that the calculated LSN should be in the range of pg_lsn type, i.e., between 0/0 and FFFFFFFF/FFFFFFFF.

Catalog attributes

Source bootstrap values for this build. See pg_type for field meanings. Header defaults are included; build-dependent constants remain symbolic. This is not a live-server measurement.

oid
3220
descr
PostgreSQL LSN
typacl
_null_
typlen
8
typelem
0
typname
pg_lsn
typsend
pg_lsn_send
typtype
b
typalign
d
typarray
0
typbyval
FLOAT8PASSBYVAL
typdelim
','
typinput
pg_lsn_in
typmodin
-
typndims
0
typowner
POSTGRES
typrelid
0
typmodout
-
typoutput
pg_lsn_out
typtypmod
-1
typanalyze
-
typdefault
_null_
typnotnull
f
typreceive
pg_lsn_recv
typstorage
p
typbasetype
0
typcategory
U
typcollation
0
typisdefined
t
typnamespace
pg_catalog
typsubscript
-
typdefaultbin
_null_
array_type_oid
3221
typispreferred
f
array_type_name
_pg_lsn

Operator overloads 10

Each operand signature is a separate overload. Catalog implementation functions and result types belong to the same source build.

OperatorLeft operandRight operandResultMeaningImplementation
=pg_lsnpg_lsnboolequalpg_lsn_eq
<>pg_lsnpg_lsnboolnot equalpg_lsn_ne
<pg_lsnpg_lsnboolless thanpg_lsn_lt
>pg_lsnpg_lsnboolgreater thanpg_lsn_gt
<=pg_lsnpg_lsnboolless than or equalpg_lsn_le
>=pg_lsnpg_lsnboolgreater than or equalpg_lsn_ge
-pg_lsnpg_lsnnumericminuspg_lsn_mi
+pg_lsnnumericpg_lsnaddpg_lsn_pli
+numericpg_lsnpg_lsnaddnumeric_pl_pg_lsn
-pg_lsnnumericpg_lsnsubtractpg_lsn_mii

Operator classes 5

Operator classes whose declared input type matches this type. Polymorphic classes, casts and expression indexes can provide additional index paths; this list is not an exhaustive yes/no index-support test.

ClassIndex methodInput typeFamilyDefaultStorage type
pg_lsn_opsbtreepg_lsnbtree/pg_lsn_opsYesSame as input
pg_lsn_opshashpg_lsnhash/pg_lsn_opsYesSame as input
pg_lsn_minmax_opsbrinpg_lsnbrin/pg_lsn_minmax_opsYespg_lsn
pg_lsn_minmax_multi_opsbrinpg_lsnbrin/pg_lsn_minmax_multi_opsNopg_lsn
pg_lsn_bloom_opsbrinpg_lsnbrin/pg_lsn_bloom_opsNopg_lsn

Version comparison

PostgreSQL 17.11 → 18.6. Source build identifiers and prose are excluded from attribute changes.

No catalog or structured attribute changes between these samples.

Documentation and source

Build
18.6 · https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
Fingerprint
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

Related entries

All Data Types · Download this version as JSON · The first recorded sample does not establish when a type was introduced.