From: | Ian Lawrence Barwick <barwick(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: function pg_setting_value_split() to parse shared_preload_libraries etc. |
Date: | 2020-10-23 02:06:08 |
Message-ID: | CAB8KJ=iuC_rz-kkjf7g__oRmVu=JsdUMZVFyqB5sqBcXXJuB+Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2020年10月23日(金) 9:53 Ian Lawrence Barwick <barwick(at)gmail(dot)com>:
>
> Hi
>
> From time to time I find myself in a situation where it would be very useful to
> be able to programatically determine whether a particular library is included in
> "shared_preload_libraries", which accepts a comma-separated list of values.
>
> Unfortunately it's not as simple as splitting the list on the commas, as while
> that will *usually* work, the following is also valid:
>
> shared_preload_libraries = 'foo,bar,"baz ,"'
>
> and reliably splitting it up into its constituent parts would mean re-inventing
> a wheel (and worse possibly introducing some regular expressions into the
> process, cf. https://xkcd.com/1171/ ).
>
> Now, while it's highly unlikely someone will go to the trouble of creating a
> library name with commas and spaces in it, "highly unlikely" is not the same as
> "will definitely never ever happen". So it would be very handy to be able to use
> the same function PostgreSQL uses internally ("SplitDirectoriesString()") to
> produce the guaranteed same result.
>
> Attached patch provides a new function "pg_setting_value_split()" which does
> exactly this, i.e. called with a string containing such a list, it calls
> "SplitDirectoriesString()" and returns the result as a set of text, e.g.:
>
> postgres# SELECT setting FROM pg_setting_value_split('foo,bar,"baz ,"');
>
> setting
> ---------
> foo
> bar
> baz ,
> (3 rows)
>
> though a more likely use would be:
>
> SELECT setting FROM
> pg_setting_value_split(current_setting('shared_preload_libraries'));
>
> Other GUCs this applies to:
>
> - local_preload_libraries
> - session_preload_libraries
> - unix_socket_directories
Having just submitted this, I realised I'm focussing on the GUCs which call
"SplitDirectoriesString()" (as my specific uses case is for
"shared_preload_libraries")
but the patch does not consider the other GUC_LIST_INPUT settings, which
call "SplitIdentifierString()", so as is, it might produce unexpected
results for those.
I'll rethink and submit an updated version.
Regards
Ian Barwick
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2020-10-23 02:10:30 | Re: Would it be helpful for share the patch merge result from cfbot |
Previous Message | Michael Paquier | 2020-10-23 02:05:34 | Re: Would it be helpful for share the patch merge result from cfbot |