if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("invalid input syntax for transaction log location: \"%s\"", str)));
+ errmsg("invalid input syntax for type pg_lsn: \"%s\"", str)));
len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF");
if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("invalid input syntax for transaction log location: \"%s\"", str)));
+ errmsg("invalid input syntax for type pg_lsn: \"%s\"", str)));
/* Decode result. */
id = (uint32) strtoul(str, NULL, 16);
off = (uint32) strtoul(str + len1 + 1, NULL, 16);
- result = (XLogRecPtr) ((uint64) id << 32) | off;
+ result = ((uint64) id << 32) | off;
PG_RETURN_LSN(result);
}
Datum
pg_lsn_out(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn = (XLogRecPtr) PG_GETARG_LSN(0);
+ XLogRecPtr lsn = PG_GETARG_LSN(0);
char buf[MAXPG_LSNLEN + 1];
char *result;
uint32 id, off;
Datum
pg_lsn_send(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn = (XLogRecPtr) PG_GETARG_LSN(0);
+ XLogRecPtr lsn = PG_GETARG_LSN(0);
StringInfoData buf;
pq_begintypsend(&buf);
Datum
pg_lsn_eq(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 == lsn2);
}
Datum
pg_lsn_ne(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 != lsn2);
}
Datum
pg_lsn_lt(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 < lsn2);
}
Datum
pg_lsn_gt(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 > lsn2);
}
Datum
pg_lsn_le(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 <= lsn2);
}
Datum
pg_lsn_ge(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_BOOL(lsn1 >= lsn2);
}
Datum
pg_lsn_mi(PG_FUNCTION_ARGS)
{
- XLogRecPtr lsn1 = (XLogRecPtr) PG_GETARG_LSN(0);
- XLogRecPtr lsn2 = (XLogRecPtr) PG_GETARG_LSN(1);
+ XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+ XLogRecPtr lsn2 = PG_GETARG_LSN(1);
char buf[256];
Datum result;
#define PG_GETARG_CHAR(n) DatumGetChar(PG_GETARG_DATUM(n))
#define PG_GETARG_BOOL(n) DatumGetBool(PG_GETARG_DATUM(n))
#define PG_GETARG_OID(n) DatumGetObjectId(PG_GETARG_DATUM(n))
-#define PG_GETARG_LSN(n) DatumGetLSN(PG_GETARG_DATUM(n))
#define PG_GETARG_POINTER(n) DatumGetPointer(PG_GETARG_DATUM(n))
#define PG_GETARG_CSTRING(n) DatumGetCString(PG_GETARG_DATUM(n))
#define PG_GETARG_NAME(n) DatumGetName(PG_GETARG_DATUM(n))
#define PG_RETURN_CHAR(x) return CharGetDatum(x)
#define PG_RETURN_BOOL(x) return BoolGetDatum(x)
#define PG_RETURN_OID(x) return ObjectIdGetDatum(x)
-#define PG_RETURN_LSN(x) return LSNGetDatum(x)
#define PG_RETURN_POINTER(x) return PointerGetDatum(x)
#define PG_RETURN_CSTRING(x) return CStringGetDatum(x)
#define PG_RETURN_NAME(x) return NameGetDatum(x)
INSERT INTO PG_LSN_TBL VALUES ('FFFFFFFF/FFFFFFFF');
-- Incorrect input
INSERT INTO PG_LSN_TBL VALUES ('G/0');
-ERROR: invalid input syntax for transaction log location: "G/0"
+ERROR: invalid input syntax for type pg_lsn: "G/0"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('G/0');
^
INSERT INTO PG_LSN_TBL VALUES ('-1/0');
-ERROR: invalid input syntax for transaction log location: "-1/0"
+ERROR: invalid input syntax for type pg_lsn: "-1/0"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('-1/0');
^
INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
-ERROR: invalid input syntax for transaction log location: " 0/12345678"
+ERROR: invalid input syntax for type pg_lsn: " 0/12345678"
LINE 1: INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
^
INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
-ERROR: invalid input syntax for transaction log location: "ABCD/"
+ERROR: invalid input syntax for type pg_lsn: "ABCD/"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
^
INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
-ERROR: invalid input syntax for transaction log location: "/ABCD"
+ERROR: invalid input syntax for type pg_lsn: "/ABCD"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
^
DROP TABLE PG_LSN_TBL;