dblink_get_result returns NULL if remote query throws error
The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/9.3/static/contrib-dblink-get-result.html Description: Please consider clarifying this page: https://www.postgresql.org/docs/current/static/contrib-dblink-get-result.html to state that if you call select dblink_get_result ('mylink',false), you will receive back a NULL if the remote query threw an error. It is not clear on the page. At least an example would be nice. Thanks!
Re: dblink_get_result returns NULL if remote query throws error
On 09/25/2018 11:41 AM, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: > https://www.postgresql.org/docs/9.3/static/contrib-dblink-get-result.html > Description: > > Please consider clarifying this page: > https://www.postgresql.org/docs/current/static/contrib-dblink-get-result.html > to state that if you call > select dblink_get_result ('mylink',false), you will receive back a NULL if > the remote query threw an error. It is not clear on the page. At least an > example would be nice. I will look at this as well as the similar one from a month+ ago that has been languishing in my inbox. Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development signature.asc Description: OpenPGP digital signature
Re: dblink_error_message return value
On 08/08/2018 11:57 AM, Tom Lane wrote: > =?utf-8?q?PG_Doc_comments_form?= writes: >> The following documentation comment has been logged on the website: >> Documentation says: > >> Return Value >> Returns last error message, or an empty string if there has been no error in >> this connection. >> Which is invalid. >> Actually it returns 'OK' string if no error was raised. > > Good catch! The code's quite clear about it, but the SGML docs need > fixed. As mentioned on the nearby thread, will fix. I suppose this ought to be back-patched. >> Secondly >> dblink_is_busy must be first called to make dblink_error_message returns an >> error message. (Tested on 9.6.9) > > Meh. I see what you're getting at here, I think, but that seems like a > completely wrong/misleading statement of the issue. Joe, can you think of > better phraseology? Maybe a note, something like this? When asynchronous queries are initiated by dblink_send_query(), the error message associated with the connection might not get updated until the server's response message is consumed. This typically means that dblink_is_busy() or dblink_get_result() should be called prior to dblink_error_message(), so that any error generated by the asynchronous query() will be visible. Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development signature.asc Description: OpenPGP digital signature
Re: dblink_get_result returns NULL if remote query throws error
On 09/25/2018 01:06 PM, Joe Conway wrote: > On 09/25/2018 11:41 AM, PG Doc comments form wrote: >> The following documentation comment has been logged on the website: >> >> Page: >> https://www.postgresql.org/docs/9.3/static/contrib-dblink-get-result.html >> Description: >> >> Please consider clarifying this page: >> https://www.postgresql.org/docs/current/static/contrib-dblink-get-result.html >> to state that if you call >> select dblink_get_result ('mylink',false), you will receive back a NULL if >> the remote query threw an error. It is not clear on the page. At least an >> example would be nice. > > I will look at this as well as the similar one from a month+ ago that > has been languishing in my inbox. Actually, the doc page says this: 8<-- fail_on_error If true (the default when omitted) then an error thrown on the remote side of the connection causes an error to also be thrown locally. If false, the remote error is locally reported as a NOTICE, and the function returns no rows. 8<-- The case you describe does *not* return NULL, it returns no rows, which is exactly what the above says. I don't see anything needing fixing. If you have evidence otherwise, please provide an example. Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development signature.asc Description: OpenPGP digital signature
Re: dblink_error_message return value
On 09/25/2018 01:50 PM, Joe Conway wrote: > On 08/08/2018 11:57 AM, Tom Lane wrote: >> =?utf-8?q?PG_Doc_comments_form?= writes: >>> The following documentation comment has been logged on the website: >>> Documentation says: >> >>> Return Value >>> Returns last error message, or an empty string if there has been no error in >>> this connection. >>> Which is invalid. >>> Actually it returns 'OK' string if no error was raised. >> >> Good catch! The code's quite clear about it, but the SGML docs need >> fixed. > > > As mentioned on the nearby thread, will fix. I suppose this ought to be > back-patched. > > >>> Secondly >>> dblink_is_busy must be first called to make dblink_error_message returns an >>> error message. (Tested on 9.6.9) >> >> Meh. I see what you're getting at here, I think, but that seems like a >> completely wrong/misleading statement of the issue. Joe, can you think of >> better phraseology? > > Maybe a note, something like this? > > When asynchronous queries are initiated by dblink_send_query(), the > error message associated with the connection might not get updated until > the server's response message is consumed. This typically means that > dblink_is_busy() or dblink_get_result() should be called prior to > dblink_error_message(), so that any error generated by the asynchronous > query() will be visible. > And now with the corresponding patch attached. Thoughts/comments? Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development diff --git a/doc/src/sgml/dblink.sgml b/doc/src/sgml/dblink.sgml index 87e14ea..97dc3b8 100644 *** a/doc/src/sgml/dblink.sgml --- b/doc/src/sgml/dblink.sgml *** dblink_error_message(text connname) retu *** 1165,1175 Return Value ! Returns last error message, or an empty string if there has been no error in this connection. Examples --- 1165,1189 Return Value ! Returns last error message, or OK if there has been no error in this connection. + +Notes + + + When asynchronous queries are initiated by + dblink_send_query, the error message associated with + the connection might not get updated until the server's response message + is consumed. This typically means that dblink_is_busy + or dblink_get_result should be called prior to + dblink_error_message, so that any error generated by + the asynchronous query will be visible. + + + Examples signature.asc Description: OpenPGP digital signature