Re: pg_system_identifier()

From: Satoshi Nagayasu <snaga(at)uptime(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Jim Nasby <jim(at)nasby(dot)net>, Greg Stark <stark(at)mit(dot)edu>, Hannu Krosing <hannu(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_system_identifier()
Date: 2013-09-16 05:25:37
Message-ID: 52369651.7000208@uptime.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I'm catching up with the discussion as a reviewer...

(2013/08/27 5:35), Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2013-08-26 10:10:54 -0700, Josh Berkus wrote:
>>> I'm going to reverse my vote, and vote against this patch. The reason
>>> why is that I think we should instead have a function:
>>>
>>> pg_controldata(parameter text)
>>>
>>> ... which would report *all* strings in pg_controldata. Hence, you'd do
>>> instead:
>>>
>>> pg_controldata('system identifier')
>>>
>>> This will hopefully spare us from 15 patches incrementally adding all of
>>> the individual items in controldata.
>
>> If anything but the proposed feature, it should be an SRF - passing in
>> text parameters isn't very discoverable.
>
> I'm not pleased with the idea that we'd have to dumb all the relevant
> datatypes down to text so that we could push them through this single
> function.
>
> Also, what about i18n? pg_controldata localizes all the strings it
> prints, but I doubt that's a great idea for either the input or the
> output of this proposed function.

How about adding new system view with new function which returns
a single pg_controldata value in text type, and using a cast for
each column in the view definition?

CREATE VIEW pg_catalog.pg_controldata AS
SELECT pg_controldata('control_version')::integer AS control_version,
pg_controldata('catalog_version')::integer AS catalog_version,
pg_controldata('system_identifier')::bigint AS system_identifier,
...
pg_controldata('next_xlog_file')::char(25) AS next_xlog_file,
...
pg_controldata('encoding')::text AS encoding;

Given that the view can work like a SRF, and it allows us to retrieve
all the values of pg_controldata with appropriate types in single
record from the view:

select * from pg_catalog.pg_controldata;

To get the system identifier value:

select system_identifier from pg_catalog.pg_controldata;

Regards,
--
Satoshi Nagayasu <snaga(at)uptime(dot)jp>
Uptime Technologies, LLC. http://www.uptime.jp

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2013-09-16 05:37:10 Re: Hstore: Query speedups with Gin index
Previous Message Abhijit Menon-Sen 2013-09-16 05:06:00 Re: [PATCH] bitmap indexes