diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod index ae84c2b82620381f3e5d1f5ae53483d562f7669a..83f5ce348c5675639100a9e4a66988e6684db4c3 100644 --- a/lib/modules/Sql.pmod/pgsql_util.pmod +++ b/lib/modules/Sql.pmod/pgsql_util.pmod @@ -749,26 +749,34 @@ class sql_result { //! Returns the command-complete status for this query. //! - //! @seealso - //! @[affected_rows()] + //! @note + //! This method should normally be called after EOF has been reached. + //! If it is called before, all unfetched result rows will be discarded. //! //! @note //! This function is PostgreSQL-specific. + //! + //! @[affected_rows()], @[eof()] /*semi*/final string status_command_complete() { + if (!statuscmdcomplete) + while (fetch_row_array()); return statuscmdcomplete; } //! Returns the number of affected rows by this query. //! - //! @seealso - //! @[status_command_complete()] + //! @note + //! This method should normally be called after EOF has been reached. + //! If it is called before, all unfetched result rows will be discarded. //! //! @note //! This function is PostgreSQL-specific. + //! + //! @seealso + //! @[status_command_complete()], @[eof()] /*semi*/final int affected_rows() { int rows; - if (statuscmdcomplete) - sscanf(statuscmdcomplete, "%*s %d %d", rows, rows); + sscanf(status_command_complete(), "%*s %d %d", rows, rows); return rows; }