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.
oid3220descrPostgreSQL LSNtypacl_null_typlen8typelem0typnamepg_lsntypsendpg_lsn_sendtyptypebtypaligndtyparray0typbyvalFLOAT8PASSBYVALtypdelim','typinputpg_lsn_intypmodin-typndims0typownerPOSTGREStyprelid0typmodout-typoutputpg_lsn_outtyptypmod-1typanalyze-typdefault_null_typnotnullftypreceivepg_lsn_recvtypstorageptypbasetype0typcategoryUtypcollation0typisdefinedttypnamespacepg_catalogtypsubscript-typdefaultbin_null_array_type_oid3221typispreferredfarray_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.
| Operator | Left operand | Right operand | Result | Meaning | Implementation |
|---|---|---|---|---|---|
= | pg_lsn | pg_lsn | bool | equal | pg_lsn_eq |
<> | pg_lsn | pg_lsn | bool | not equal | pg_lsn_ne |
< | pg_lsn | pg_lsn | bool | less than | pg_lsn_lt |
> | pg_lsn | pg_lsn | bool | greater than | pg_lsn_gt |
<= | pg_lsn | pg_lsn | bool | less than or equal | pg_lsn_le |
>= | pg_lsn | pg_lsn | bool | greater than or equal | pg_lsn_ge |
- | pg_lsn | pg_lsn | numeric | minus | pg_lsn_mi |
+ | pg_lsn | numeric | pg_lsn | add | pg_lsn_pli |
+ | numeric | pg_lsn | pg_lsn | add | numeric_pl_pg_lsn |
- | pg_lsn | numeric | pg_lsn | subtract | pg_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.
| Class | Index method | Input type | Family | Default | Storage type |
|---|---|---|---|---|---|
pg_lsn_ops | btree | pg_lsn | btree/pg_lsn_ops | Yes | Same as input |
pg_lsn_ops | hash | pg_lsn | hash/pg_lsn_ops | Yes | Same as input |
pg_lsn_minmax_ops | brin | pg_lsn | brin/pg_lsn_minmax_ops | Yes | pg_lsn |
pg_lsn_minmax_multi_ops | brin | pg_lsn | brin/pg_lsn_minmax_multi_ops | No | pg_lsn |
pg_lsn_bloom_ops | brin | pg_lsn | brin/pg_lsn_bloom_ops | No | pg_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.