Thread: dblink_get_connections() result for no connections

dblink_get_connections() result for no connections

From
Tom Lane
Date:
While fooling around with the array_agg(anyarray) patch, I noted
that dblink_get_connections() returns NULL if there are no active
connections.  It seems like an empty array might be a saner
definition --- thoughts?
        regards, tom lane



Re: dblink_get_connections() result for no connections

From
Joe Conway
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/25/2014 12:49 PM, Tom Lane wrote:
> While fooling around with the array_agg(anyarray) patch, I noted 
> that dblink_get_connections() returns NULL if there are no active 
> connections.  It seems like an empty array might be a saner 
> definition --- thoughts?

(Sorry for the slow response -- was traveling all day yesterday)

The original patch introducing this function is seen here:

http://www.postgresql.org/message-id/44C50F4A.7050708@joeconway.com

and committed by me here:

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52a3ed9fac32e16f6061cbc49046c0bd97f8f77a

In particular, the original author said:
8<-------------------------
Added functions:
[...]
dblink_get_connections()     List all open dblink connections by name.     Returns a comma separated string of all
connectionnames.     Takes no params
 
     Example: SELECT string_to_array(dblink_get_connections(), ',');
8<-------------------------

He really did not specify what the return value should be if there are
no connections. Somewhere between submission and commit I changed that
to return an array rather than comma separated string.

To be honest I have no idea why I did not make it an empty array
instead of a NULL in that case, but that does make more sense to me
now that you mention it. Might cause some breakage for people
depending on that though...

Joe


- -- 
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUdphsAAoJEDfy90M199hlXuUP/i72+AKHdDS18gjHv7/axvS1
/6v0KMK9GvQBbfaHHlQ22eoCBkX6eZI3XW7FYymD4oDYBEK3rihck6sjBxFokrK7
QSYWiSX0tgeAvE99WCI3aLxyXZDTxnlaobfTwg1OMUsz2a8O23fppDrevYe+4EDC
t40dpiJiG/6r7wektARSJQG0DtINaEeRwvGVBhMExvGo+76GNfotqTaRLex0Fugi
8FoE7VP61Kx9P7wMV/QOB3VK+apfPVEd4jN6lsSYp0MDKI64dk6ITfxng9KTMbUi
wP+01WK7oljJeUBQRM1Co/OBXcAUTWXhr6wwwZgUqw1eeMU7rXLuDDtIz4B2NEFY
tp6mFuAb15x+BmdBjJSYTz/ckG7n+NEJ4VyiK/gQWe3+WUajRqAPh38xpiWniTL4
l7cajIAWy5kO7RKXyaFxmRqXI148lUO2DosF/uL0nbOrCYjdf9VSGnDzq9bST2BE
mz7i7l5Ej/Pt1OPu4oeKRyEo39GkyD/2fsstVv66403LYaEWwyyKUA2rg1W1T2aN
WALXUgCmpEVstTtHJFS6cvGy4dw4QobUihJWOZEOtesF7XIxQcXLttTUrydPBfVC
6zOZIoVcKO1O2ER0nFBmSVVo+63Y4rgK8WLnJJ2C7WcFvC0Kd5BfzQ1BSMoPeCA2
2KhIlr2QbyeUeY6Ebz+o
=vNw9
-----END PGP SIGNATURE-----



Re: dblink_get_connections() result for no connections

From
Robert Haas
Date:
On Tue, Nov 25, 2014 at 3:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> While fooling around with the array_agg(anyarray) patch, I noted
> that dblink_get_connections() returns NULL if there are no active
> connections.  It seems like an empty array might be a saner
> definition --- thoughts?

I don't think it matters much.  I wouldn't break backward
compatibility to change it from this behavior to that one, and if we'd
picked the other one I wouldn't break compatibility to change it to
this behavior.  Anybody who cares can wrap a COALESCE() around it.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company