#include "postgres.h"#include <limits.h>#include "access/transam.h"#include "access/xact.h"#include "libpq/pqformat.h"#include "utils/builtins.h"
Go to the source code of this file.
Defines | |
| #define | PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n)) |
| #define | PG_RETURN_TRANSACTIONID(x) return TransactionIdGetDatum(x) |
| #define | PG_GETARG_COMMANDID(n) DatumGetCommandId(PG_GETARG_DATUM(n)) |
| #define | PG_RETURN_COMMANDID(x) return CommandIdGetDatum(x) |
Functions | |
| Datum | xidin (PG_FUNCTION_ARGS) |
| Datum | xidout (PG_FUNCTION_ARGS) |
| Datum | xidrecv (PG_FUNCTION_ARGS) |
| Datum | xidsend (PG_FUNCTION_ARGS) |
| Datum | xideq (PG_FUNCTION_ARGS) |
| Datum | xid_age (PG_FUNCTION_ARGS) |
| int | xidComparator (const void *arg1, const void *arg2) |
| Datum | cidin (PG_FUNCTION_ARGS) |
| Datum | cidout (PG_FUNCTION_ARGS) |
| Datum | cidrecv (PG_FUNCTION_ARGS) |
| Datum | cidsend (PG_FUNCTION_ARGS) |
| Datum | cideq (PG_FUNCTION_ARGS) |
| #define PG_GETARG_COMMANDID | ( | n | ) | DatumGetCommandId(PG_GETARG_DATUM(n)) |
| #define PG_GETARG_TRANSACTIONID | ( | n | ) | DatumGetTransactionId(PG_GETARG_DATUM(n)) |
| #define PG_RETURN_COMMANDID | ( | x | ) | return CommandIdGetDatum(x) |
| #define PG_RETURN_TRANSACTIONID | ( | x | ) | return TransactionIdGetDatum(x) |
| Datum cideq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 182 of file xid.c.
References PG_GETARG_COMMANDID, and PG_RETURN_BOOL.
{
CommandId arg1 = PG_GETARG_COMMANDID(0);
CommandId arg2 = PG_GETARG_COMMANDID(1);
PG_RETURN_BOOL(arg1 == arg2);
}
| Datum cidin | ( | PG_FUNCTION_ARGS | ) |
Definition at line 133 of file xid.c.
References PG_GETARG_CSTRING, and PG_RETURN_COMMANDID.
{
char *s = PG_GETARG_CSTRING(0);
CommandId c;
c = atoi(s);
PG_RETURN_COMMANDID(c);
}
| Datum cidout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 147 of file xid.c.
References palloc(), PG_GETARG_COMMANDID, PG_RETURN_CSTRING, and snprintf().
{
CommandId c = PG_GETARG_COMMANDID(0);
char *result = (char *) palloc(16);
snprintf(result, 16, "%u", (unsigned int) c);
PG_RETURN_CSTRING(result);
}
| Datum cidrecv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 160 of file xid.c.
References buf, PG_GETARG_POINTER, PG_RETURN_COMMANDID, and pq_getmsgint().
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
PG_RETURN_COMMANDID((CommandId) pq_getmsgint(buf, sizeof(CommandId)));
}
| Datum cidsend | ( | PG_FUNCTION_ARGS | ) |
Definition at line 171 of file xid.c.
References buf, PG_GETARG_COMMANDID, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), and pq_sendint().
{
CommandId arg1 = PG_GETARG_COMMANDID(0);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendint(&buf, arg1, sizeof(arg1));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
| Datum xid_age | ( | PG_FUNCTION_ARGS | ) |
Definition at line 93 of file xid.c.
References GetStableLatestTransactionId(), now(), PG_GETARG_TRANSACTIONID, PG_RETURN_INT32, and TransactionIdIsNormal.
{
TransactionId xid = PG_GETARG_TRANSACTIONID(0);
TransactionId now = GetStableLatestTransactionId();
/* Permanent XIDs are always infinitely old */
if (!TransactionIdIsNormal(xid))
PG_RETURN_INT32(INT_MAX);
PG_RETURN_INT32((int32) (now - xid));
}
| int xidComparator | ( | const void * | arg1, | |
| const void * | arg2 | |||
| ) |
Definition at line 113 of file xid.c.
Referenced by ProcArrayApplyRecoveryInfo().
{
TransactionId xid1 = *(const TransactionId *) arg1;
TransactionId xid2 = *(const TransactionId *) arg2;
if (xid1 > xid2)
return 1;
if (xid1 < xid2)
return -1;
return 0;
}
| Datum xideq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 81 of file xid.c.
References PG_GETARG_TRANSACTIONID, PG_RETURN_BOOL, and TransactionIdEquals.
{
TransactionId xid1 = PG_GETARG_TRANSACTIONID(0);
TransactionId xid2 = PG_GETARG_TRANSACTIONID(1);
PG_RETURN_BOOL(TransactionIdEquals(xid1, xid2));
}
| Datum xidin | ( | PG_FUNCTION_ARGS | ) |
Definition at line 32 of file xid.c.
References NULL, PG_GETARG_CSTRING, and PG_RETURN_TRANSACTIONID.
{
char *str = PG_GETARG_CSTRING(0);
PG_RETURN_TRANSACTIONID((TransactionId) strtoul(str, NULL, 0));
}
| Datum xidout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 40 of file xid.c.
References palloc(), PG_GETARG_TRANSACTIONID, PG_RETURN_CSTRING, and snprintf().
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
/* maximum 32 bit unsigned integer representation takes 10 chars */
char *str = palloc(11);
snprintf(str, 11, "%lu", (unsigned long) transactionId);
PG_RETURN_CSTRING(str);
}
| Datum xidrecv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 56 of file xid.c.
References buf, PG_GETARG_POINTER, PG_RETURN_TRANSACTIONID, and pq_getmsgint().
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
PG_RETURN_TRANSACTIONID((TransactionId) pq_getmsgint(buf, sizeof(TransactionId)));
}
| Datum xidsend | ( | PG_FUNCTION_ARGS | ) |
Definition at line 67 of file xid.c.
References buf, PG_GETARG_TRANSACTIONID, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), and pq_sendint().
{
TransactionId arg1 = PG_GETARG_TRANSACTIONID(0);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendint(&buf, arg1, sizeof(arg1));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
1.7.1