From: Vik Fearing <vik.fearing@dalibo.com>
To: PG Hackers <pgsql-hackers@postgresql.org>
Subject: pg_system_identifier()
Date: Wed, 21 Aug 2013 23:43:07 +0200
Message-ID: <5215346B.7070800@dalibo.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
After someone in IRC asked if there was an equivalent to MySQL's
server_id, it was noted that we do have a system identifier but it's not
very accessible.
The attached patch implements a pg_system_identifier() function that
exposes it.
Shall I add this to the next commitfest?
--
Vik
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:
[text/x-patch] sysident.v1.patch (2.7K, ../5215346B.7070800@dalibo.com/2-sysident.v1.patch)
download | inline diff:
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
***************
*** 13473,13478 **** SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
--- 13473,13484 ----
</row>
<row>
+ <entry><literal><function>pg_system_identifier()</function></literal></entry>+ <entry><type>text</type></entry>+ <entry>system identifier for the database cluster</entry>+ </row>+ + <row>
<entry><literal><function>pg_trigger_depth()</function></literal></entry>
<entry><type>int</type></entry>
<entry>current nesting level of <productname>PostgreSQL</> triggers
*** a/src/backend/access/transam/xlogfuncs.c
--- b/src/backend/access/transam/xlogfuncs.c
***************
*** 35,40 ****
--- 35,50 ----
static void validate_xlog_location(char *str);
+ /*+ * pg_system_identifier+ */+ Datum+ pg_system_identifier(PG_FUNCTION_ARGS)+ {+ char ret[32];+ sprintf(ret, UINT64_FORMAT, GetSystemIdentifier());+ PG_RETURN_TEXT_P(cstring_to_text(ret));+ }
/*
* pg_start_backup: set up for taking an on-line backup dump
*** a/src/include/access/xlog_fn.h
--- b/src/include/access/xlog_fn.h
***************
*** 13,18 ****
--- 13,19 ----
#include "fmgr.h"
+ extern Datum pg_system_identifier(PG_FUNCTION_ARGS);
extern Datum pg_start_backup(PG_FUNCTION_ARGS);
extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
extern Datum pg_switch_xlog(PG_FUNCTION_ARGS);
*** a/src/include/catalog/catversion.h
--- b/src/include/catalog/catversion.h
***************
*** 53,58 ****
--- 53,59 ----
*/
/* yyyymmddN */
+ /* needs bump */
#define CATALOG_VERSION_NO 201307221
#endif
*** a/src/include/catalog/pg_proc.h
--- b/src/include/catalog/pg_proc.h
***************
*** 2954,2959 **** DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v
--- 2954,2961 ----
DESCR("cancel a server process' current query");
DATA(insert OID = 2096 ( pg_terminate_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 16 "23" _null_ _null_ _null_ _null_ pg_terminate_backend _null_ _null_ _null_ ));
DESCR("terminate a server process");
+ DATA(insert OID = 3179 ( pg_system_identifier PGNSP PGUID 12 1 0 0 0 f f f f f f i 0 0 25 "" _null_ _null_ _null_ _null_ pg_system_identifier _null_ _null_ _null_ ));+ DESCR("database system identifier");
DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 25 "25 16" _null_ _null_ _null_ _null_ pg_start_backup _null_ _null_ _null_ ));
DESCR("prepare for taking an online backup");
DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_stop_backup _null_ _null_ _null_ ));
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: vik.fearing@dalibo.com
Subject: Re: pg_system_identifier()
In-Reply-To: <5215346B.7070800@dalibo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox