PostgreSQL Source Code  git master
pg_lsn.h File Reference
#include "access/xlogdefs.h"
#include "fmgr.h"
Include dependency graph for pg_lsn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DatumGetLSN(X)   ((XLogRecPtr) DatumGetInt64(X))
 
#define LSNGetDatum(X)   (Int64GetDatum((int64) (X)))
 
#define PG_GETARG_LSN(n)   DatumGetLSN(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LSN(x)   return LSNGetDatum(x)
 

Functions

XLogRecPtr pg_lsn_in_internal (const char *str, bool *have_error)
 

Macro Definition Documentation

◆ DatumGetLSN

#define DatumGetLSN (   X)    ((XLogRecPtr) DatumGetInt64(X))

◆ LSNGetDatum

◆ PG_GETARG_LSN

◆ PG_RETURN_LSN

Function Documentation

◆ pg_lsn_in_internal()

XLogRecPtr pg_lsn_in_internal ( const char *  str,
bool have_error 
)

Definition at line 30 of file pg_lsn.c.

References Assert, InvalidXLogRecPtr, and MAXPG_LSNCOMPONENT.

Referenced by check_recovery_target_lsn(), and pg_lsn_in().

31 {
32  int len1,
33  len2;
34  uint32 id,
35  off;
36  XLogRecPtr result;
37 
38  Assert(have_error != NULL);
39  *have_error = false;
40 
41  /* Sanity check input format. */
42  len1 = strspn(str, "0123456789abcdefABCDEF");
43  if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/')
44  {
45  *have_error = true;
46  return InvalidXLogRecPtr;
47  }
48  len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF");
49  if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0')
50  {
51  *have_error = true;
52  return InvalidXLogRecPtr;
53  }
54 
55  /* Decode result. */
56  id = (uint32) strtoul(str, NULL, 16);
57  off = (uint32) strtoul(str + len1 + 1, NULL, 16);
58  result = ((uint64) id << 32) | off;
59 
60  return result;
61 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
unsigned int uint32
Definition: c.h:429
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:800
#define MAXPG_LSNCOMPONENT
Definition: pg_lsn.c:23