diff --git a/lib/modules/Sql.pmod/pgsql.pike b/lib/modules/Sql.pmod/pgsql.pike index 76a90a2b995a21d1873aa5505f0882c138fa1e8f..b92979a36bd72ed83c645102d542737f58d3709d 100644 --- a/lib/modules/Sql.pmod/pgsql.pike +++ b/lib/modules/Sql.pmod/pgsql.pike @@ -1218,6 +1218,7 @@ private void procmessage() { //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface. /*semi*/final void close() { + throwdelayederror(this); Thread.MutexKey lock; if (qportals && qportals->size()) catch(cancelquery()); @@ -1232,8 +1233,17 @@ private void procmessage() { } protected void destroy() { - catch(close()); + string errstring; + mixed err = catch(close()); .pgsql_util.unregister_backend(); + /* + * Flush out any asynchronously reported errors to stderr; because we are + * inside a destructor, throwing an error will not work anymore. + */ + if (err || (err = catch(errstring = error(1)))) + werror(describe_backtrace(err)); + else if (sizeof(errstring)) + werror(errstring); } final void _connectfail(void|mixed err) {