Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCGBs-0008TU-CO for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Aug 2013 21:43:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VCGBq-0001hc-H2 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Aug 2013 21:43:42 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCGBo-0001hS-TP for pgsql-hackers@postgresql.org; Wed, 21 Aug 2013 21:43:41 +0000 Received: from mimolette.dalibo.net ([212.85.154.222]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCGBf-0008Py-Td for pgsql-hackers@postgresql.org; Wed, 21 Aug 2013 21:43:39 +0000 Received: from [192.168.0.38] (ip-68.net-81-220-133.standre.rev.numericable.fr [81.220.133.68]) by mimolette.dalibo.net (Postfix) with ESMTPSA id 79F1C4502857 for ; Wed, 21 Aug 2013 23:43:30 +0200 (CEST) Message-ID: <5215346B.7070800@dalibo.com> Date: Wed, 21 Aug 2013 23:43:07 +0200 From: Vik Fearing User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: PG Hackers Subject: pg_system_identifier() Content-Type: multipart/mixed; boundary="------------010807020809030308030205" X-Pg-Spam-Score: -0.5 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------010807020809030308030205 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 --------------010807020809030308030205 Content-Type: text/x-patch; name="sysident.v1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sysident.v1.patch" *** 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 ---- + pg_system_identifier() + text + system identifier for the database cluster + + + pg_trigger_depth() int current nesting level of 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_ )); --------------010807020809030308030205 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------010807020809030308030205--