Silent MALLOC/REALLOC error

TAKATSUKA Haruka <[email protected]>
Newsgroups gmane.comp.db.postgresql.odbc
Organization SRA OSS, Inc.
Message-ID <[email protected]>
Hello, psqlODBC team.

When we fetch large data via psqlodbc, we sometimes fail to 
get all rows completely without any API's error responses; 
SQLExecDirect returns SQL_SUCCESS and SQLFetch returns just SQL_NODATA.
But there are QR_REALLOC_error reported in mylog at that time.

I reproduced it by tweaking QR_REALLOC_return_with_error macro
to intentionally fail to allocate memory frequently. 

I propose the patch attached.
It makes the code in CC_send_query_append() go out the while-loop immediately 
after CC_from_PGresult() at the case PORES_BAD_RESPONSE, PORES_FATAL_ERROR or PORES_NO_MEMORY_ERROR.


Thanks,
Haruka Takatsuka
connection.c.diff (text/plain, 487 B)
diff --git a/connection.c b/connection.c
index 411e045..9833c39 100644
--- a/connection.c
+++ b/connection.c
@@ -2067,11 +2067,14 @@ inolog("Discarded a RELEASE result\n");
 					}
 					if (!CC_from_PGresult(res, stmt, self, cursor, &pgres))
 					{
+						aborted = TRUE;
 						if (QR_command_maybe_successful(res))
 							retres = NULL;
 						else
+						{
 							retres = cmdres;
-						aborted = TRUE;
+							goto cleanup;
+						}
 					}
 					query_completed = TRUE;
 				}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.