Hello:
I find that the real timestamp format(got from the file which is produced by copying binary to ) is different from what
ifind in timestamp_send func.
i do think that the binary format of a timestamp "2006-04-18 11:20:20" should be "44 2B B0 6A 00 00 00 00" standing
for"secs:1143713898, usecs:0" but in fact it is:"41A7 7DBA D400 0000 "
timestamp is defined as int64 or float8, when it is defined as int64, it looks like timeval, first 32 bits for
seconds,second32 bits for usec.
and from the timestamp_send func, it just changes the first 32 bits to binary then combines the next 32 bits
/* codes from timestamp_send*/
Datum
timestamp_send(PG_FUNCTION_ARGS)
{Timestamp timestamp = PG_GETARG_TIMESTAMP(0);StringInfoData buf;
pq_begintypsend(&buf);
#ifdef HAVE_INT64_TIMESTAMPpq_sendint64(&buf, timestamp);
#elsepq_sendfloat8(&buf, timestamp);
#endifPG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
/* codes from pq_sendint64*/
void
pq_sendint64(StringInfo buf, int64 i)
{uint32 n32;
/* High order half first, since we're doing MSB-first */
#ifdef INT64_IS_BUSTED/* don't try a right shift of 32 on a 32-bit word */n32 = (i < 0) ? -1 : 0;
#elsen32 = (uint32) (i >> 32);
#endifn32 = htonl(n32);appendBinaryStringInfo(buf, (char *) &n32, 4);
/* Now the low order half */n32 = (uint32) i;n32 = htonl(n32);appendBinaryStringInfo(buf, (char *) &n32, 4);
}
so i do think that the binary format of a timestamp "2006-04-18 11:20:20" should be "44 2B B0 6A 00 00 00 00" standing
for"secs:1143713898, usecs:0"
but in fact it is:" 41A7 7DBA D400 0000 " , i don't know why.
maybe, i have looked into a wrong func, then which is the right one?