xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
+ char *result = (char *) palloc(16);
- /* maximum 32 bit unsigned integer representation takes 10 chars */
- char *str = palloc(11);
-
- snprintf(str, 11, "%lu", (unsigned long) transactionId);
-
- PG_RETURN_CSTRING(str);
+ snprintf(result, 16, "%lu", (unsigned long) transactionId);
+ PG_RETURN_CSTRING(result);
}
/*
Datum
cidin(PG_FUNCTION_ARGS)
{
- char *s = PG_GETARG_CSTRING(0);
- CommandId c;
-
- c = atoi(s);
+ char *str = PG_GETARG_CSTRING(0);
- PG_RETURN_COMMANDID(c);
+ PG_RETURN_COMMANDID((CommandId) strtoul(str, NULL, 0));
}
/*
CommandId c = PG_GETARG_COMMANDID(0);
char *result = (char *) palloc(16);
- snprintf(result, 16, "%u", (unsigned int) c);
+ snprintf(result, 16, "%lu", (unsigned long) c);
PG_RETURN_CSTRING(result);
}