Regarding these prior threads:
http://www.postgresql.org/message-id/cac2surjlmtkyvcs6dbxdyurhy+wke-94cbugnwcxag914cw...@mail.gmail.com
http://www.postgresql.org/message-id/[email protected]
It's somewhat less than pretty, but you *can* simply:
select substring(pg_read_binary_file('global/pg_control'),1,8);
then, knowing whether the system is little- or big-endian, decode the
resulting hex representation of a uint64 however you find to be
convenient, like say:
#!/usr/bin/python
import struct
import sys
print struct.unpack("Q", sys.argv[1].decode("hex"))[0]
... or your preferred spelling in C/Perl/LOLCode/whatever.
For many purposes the raw hex representation will be sufficient in any case.
The main downside here is the requirement of a superuser connection.
It'd be fairly trivial (and a lot saner) to write an extension to expose
GetSystemIdentifier() via SQL. Unfortunately that won't work for my
purposes because I need something that'll work on potentially quite old
servers and with minimal intrusiveness, but it'd be a reasonable answer
for people who want it for cluster/replication management.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services