Skip to content
Snippets Groups Projects
Commit 57c80fe4 authored by Stephen R. van den Berg's avatar Stephen R. van den Berg
Browse files

pgsql: Make affected_rows() and status_command_complete() wait for a meaningful result.

parent acdac0b8
No related branches found
No related tags found
No related merge requests found
...@@ -749,26 +749,34 @@ class sql_result { ...@@ -749,26 +749,34 @@ class sql_result {
//! Returns the command-complete status for this query. //! Returns the command-complete status for this query.
//! //!
//! @seealso //! @note
//! @[affected_rows()] //! This method should normally be called after EOF has been reached.
//! If it is called before, all unfetched result rows will be discarded.
//! //!
//! @note //! @note
//! This function is PostgreSQL-specific. //! This function is PostgreSQL-specific.
//!
//! @[affected_rows()], @[eof()]
/*semi*/final string status_command_complete() { /*semi*/final string status_command_complete() {
if (!statuscmdcomplete)
while (fetch_row_array());
return statuscmdcomplete; return statuscmdcomplete;
} }
//! Returns the number of affected rows by this query. //! Returns the number of affected rows by this query.
//! //!
//! @seealso //! @note
//! @[status_command_complete()] //! This method should normally be called after EOF has been reached.
//! If it is called before, all unfetched result rows will be discarded.
//! //!
//! @note //! @note
//! This function is PostgreSQL-specific. //! This function is PostgreSQL-specific.
//!
//! @seealso
//! @[status_command_complete()], @[eof()]
/*semi*/final int affected_rows() { /*semi*/final int affected_rows() {
int rows; int rows;
if (statuscmdcomplete) sscanf(status_command_complete(), "%*s %d %d", rows, rows);
sscanf(statuscmdcomplete, "%*s %d %d", rows, rows);
return rows; return rows;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment