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 PG_GETARG_LSN(n)   DatumGetLSN(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LSN(x)   return LSNGetDatum(x)
 

Functions

static XLogRecPtr DatumGetLSN (Datum X)
 
static Datum LSNGetDatum (XLogRecPtr X)
 
XLogRecPtr pg_lsn_in_internal (const char *str, bool *have_error)
 

Macro Definition Documentation

◆ PG_GETARG_LSN

#define PG_GETARG_LSN (   n)    DatumGetLSN(PG_GETARG_DATUM(n))

Definition at line 33 of file pg_lsn.h.

◆ PG_RETURN_LSN

#define PG_RETURN_LSN (   x)    return LSNGetDatum(x)

Definition at line 34 of file pg_lsn.h.

Function Documentation

◆ DatumGetLSN()

static XLogRecPtr DatumGetLSN ( Datum  X)
inlinestatic

Definition at line 22 of file pg_lsn.h.

23{
24 return (XLogRecPtr) DatumGetInt64(X);
25}
static int64 DatumGetInt64(Datum X)
Definition: postgres.h:390
uint64 XLogRecPtr
Definition: xlogdefs.h:21

References DatumGetInt64().

Referenced by GetSubscriptionRelations(), GetSubscriptionRelState(), libpqrcv_create_slot(), parse_subscription_options(), and synchronize_slots().

◆ LSNGetDatum()

◆ pg_lsn_in_internal()

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

Definition at line 29 of file pg_lsn.c.

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

References Assert, InvalidXLogRecPtr, MAXPG_LSNCOMPONENT, and str.

Referenced by check_recovery_target_lsn(), and pg_lsn_in().