postgre LSN
Last updated on November 20, 2024 am
🧙 Questions
☄️ Ideas
查看当前lsn
0/4C12D718
SELECT pg_current_wal_lsn();
查看当前lsn
0/4C12D718
SELECT pg_current_wal_lsn();
lsn转long
public class PgLsnTranslate {
public static long lsnToLong(String lsn) {
String[] parts = lsn.split("/");
if (parts.length != 2) {
throw new IllegalArgumentException("Invalid LSN format: " + lsn);
}
// Convert segment number and offset to long values
long segment = Long.parseLong(parts[0], 16);
long offset = Long.parseLong(parts[1], 16);
// Combine segment and offset to get the LSN as a long
return (segment << 32) | offset;
}
public static void main(String[] args) {
String lsn = "0/4C12D718"; // Replace with your LSN
long result = lsnToLong(lsn);
System.out.println("LSN as long: " + result);
}
}
🔗 Links
postgre LSN
https://ispong.isxcode.com/db/postgre/postgre LSN/