pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedCC_send_query_append crash
7+ messages / 4 participants
[nested] [flat]
* CC_send_query_append crash
@ 2014-04-29 16:44 Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Malcolm MacLeod @ 2014-04-29 16:44 UTC (permalink / raw)
To: pgsql-odbc
Hello,
While stress testing our software to handle network
reconnects/disconnects I have run into a crash in your ODBC driver.
The crash seems to occur because CC_send_query_append crash takes a
local copy of the pointer 'self->sock' at the top of the function,
'self' is then passed around to various functions (some of which have
the side effect of setting self->sock to NULL (and deleting) if there is
a lost connection) and then the local copy of the pointer (which is now
dangling) is dereferenced lower down in the function.
Essentially if there is a disconnect while CC_send_query_append is
running there is a risk of crash.
I hope that you can fix this soon.
Regards,
Malcolm MacLeod
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
Dangling_socket_pointer_fix.diff (text/x-patch, 8.1K) download
--- C:\Users\m\Desktop\psqlodbc-09.03.0210\connection.c 2014-03-06 15:48:44.000000000 +0200
+++ C:\Users\m\Desktop\psqlodbc-09.03.0210_fixed\connection.c 2014-04-06 22:47:59.000000000 +0200
@@ -2743,13 +2743,13 @@
CSTR per_query_svp = "_per_query_svp_";
CSTR rlscmd = "RELEASE";
static size_t lenbgncmd = 0, lenrbkcmd = 0, lensvpcmd = 0,
lenrlscmd = 0, lenperqsvp = 0;
size_t qrylen;
int id;
- SocketClass *sock = self->sock;
+ //SocketClass *sock = self->sock;
int maxlen,
empty_reqs;
BOOL ReadyToReturn = FALSE,
query_completed = FALSE,
beforeV2 = PG_VERSION_LT(self, 6.4),
aborted = FALSE,
@@ -2812,13 +2812,13 @@
if ((NULL == query) || (query[0] == '\0'))
{
CLEANUP_FUNC_CONN_CS(func_cs_count, self);
return NULL;
}
- if (SOCK_get_errcode(sock) != 0)
+ if (SOCK_get_errcode(self->sock) != 0)
{
CC_set_error(self, CONNECTION_COULD_NOT_SEND, "Could not send Query to backend", func);
CC_on_abort(self, CONN_DEAD);
CLEANUP_FUNC_CONN_CS(func_cs_count, self);
return NULL;
}
@@ -2866,14 +2866,14 @@
goto cleanup;
}
}
}
}
- SOCK_put_char(sock, 'Q');
- if (SOCK_get_errcode(sock) != 0)
+ SOCK_put_char(self->sock, 'Q');
+ if (SOCK_get_errcode(self->sock) != 0)
{
CC_set_error(self, CONNECTION_COULD_NOT_SEND, "Could not send Query to backend", func);
goto cleanup;
}
if (stmt)
SC_forget_unnamed(stmt);
@@ -2896,46 +2896,46 @@
if (query_rollback)
{
leng += (UInt4) (lensvpcmd + 1 + lenperqsvp + 1);
leng += (UInt4) (1 + lenrlscmd + 1 + lenperqsvp);
}
leng++;
- SOCK_put_int(sock, leng + 4, 4);
+ SOCK_put_int(self->sock, leng + 4, 4);
inolog("leng=%d\n", leng);
}
if (issue_begin)
{
- SOCK_put_n_char(sock, bgncmd, lenbgncmd);
- SOCK_put_n_char(sock, semi_colon, 1);
+ SOCK_put_n_char(self->sock, bgncmd, lenbgncmd);
+ SOCK_put_n_char(self->sock, semi_colon, 1);
discard_next_begin = TRUE;
}
if (query_rollback)
{
char cmd[64];
snprintf(cmd, sizeof(cmd), "%s %s;", svpcmd, per_query_svp);
- SOCK_put_n_char(sock, cmd, strlen(cmd));
+ SOCK_put_n_char(self->sock, cmd, strlen(cmd));
discard_next_savepoint = TRUE;
}
- SOCK_put_n_char(sock, query, qrylen);
+ SOCK_put_n_char(self->sock, query, qrylen);
if (appendq)
{
- SOCK_put_n_char(sock, semi_colon, 1);
- SOCK_put_n_char(sock, appendq, strlen(appendq));
+ SOCK_put_n_char(self->sock, semi_colon, 1);
+ SOCK_put_n_char(self->sock, appendq, strlen(appendq));
}
if (query_rollback)
{
char cmd[64];
snprintf(cmd, sizeof(cmd), ";%s %s", rlscmd, per_query_svp);
- SOCK_put_n_char(sock, cmd, strlen(cmd));
+ SOCK_put_n_char(self->sock, cmd, strlen(cmd));
}
- SOCK_put_n_char(sock, NULL_STRING, 1);
- leng = SOCK_flush_output(sock);
+ SOCK_put_n_char(self->sock, NULL_STRING, 1);
+ leng = SOCK_flush_output(self->sock);
- if (SOCK_get_errcode(sock) != 0)
+ if (SOCK_get_errcode(self->sock) != 0)
{
CC_set_error(self, CONNECTION_COULD_NOT_SEND, "Could not send Query to backend", func);
goto cleanup;
}
mylog("send_query: done sending query %dbytes flushed\n", leng);
@@ -2958,40 +2958,40 @@
}
}
res = cmdres;
while (!ReadyToReturn)
{
/* what type of message is coming now ? */
- id = SOCK_get_id(sock);
+ id = SOCK_get_id(self->sock);
- if ((SOCK_get_errcode(sock) != 0) || (id == EOF))
+ if ((SOCK_get_errcode(self->sock) != 0) || (id == EOF))
{
CC_set_error(self, CONNECTION_NO_RESPONSE, "No response from the backend", func);
mylog("send_query: 'id' - %s\n", CC_get_errormsg(self));
kill_conn = TRUE;
ReadyToReturn = TRUE;
break;
}
mylog("send_query: got id = '%c'\n", id);
- response_length = SOCK_get_response_length(sock);
+ response_length = SOCK_get_response_length(self->sock);
inolog("send_query response_length=%d\n", response_length);
switch (id)
{
case 'A': /* Asynchronous Messages are ignored */
- (void) SOCK_get_int(sock, 4); /* id of notification */
- SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
+ (void) SOCK_get_int(self->sock, 4); /* id of notification */
+ SOCK_get_string(self->sock, msgbuffer, ERROR_MSG_LENGTH);
/* name of the relation the message comes from */
break;
case 'C': /* portal query command, no tuples
* returned */
/* read in the return message from the backend */
- SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
- if (SOCK_get_errcode(sock) != 0)
+ SOCK_get_string(self->sock, cmdbuffer, ERROR_MSG_LENGTH);
+ if (SOCK_get_errcode(self->sock) != 0)
{
CC_set_error(self, CONNECTION_NO_RESPONSE, "No response from backend while receiving a portal query command", func);
mylog("send_query: 'C' - %s\n", CC_get_errormsg(self));
ReadyToReturn = TRUE;
}
else
@@ -3083,14 +3083,14 @@
* empty query, and keep reading out of the pipe until
* an 'I' is received
*/
if (empty_reqs == 0)
{
- SOCK_put_string(sock, "Q ");
- SOCK_flush_output(sock);
+ SOCK_put_string(self->sock, "Q ");
+ SOCK_flush_output(self->sock);
empty_reqs++;
}
}
break;
case 'Z': /* Backend is ready for new query (6.4) */
if (empty_reqs == 0)
@@ -3110,14 +3110,14 @@
case 'I': /* The server sends an empty query */
/* There is a closing '\0' following the 'I', so we eat it */
if (PROTOCOL_74(ci) && 0 == response_length)
swallow = '\0';
else
- swallow = SOCK_get_char(sock);
- if ((swallow != '\0') || SOCK_get_errcode(sock) != 0)
+ swallow = SOCK_get_char(self->sock);
+ if ((swallow != '\0') || SOCK_get_errcode(self->sock) != 0)
{
CC_set_errornumber(self, CONNECTION_BACKEND_CRAZY);
QR_set_message(res, "Unexpected protocol character from backend (send_query - I)");
QR_set_rstatus(res, PORES_FATAL_ERROR);
kill_conn = TRUE;
ReadyToReturn = TRUE;
@@ -3143,13 +3143,13 @@
aborted = TRUE;
query_completed = TRUE;
break;
case 'P': /* get the Portal name */
- SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
+ SOCK_get_string(self->sock, msgbuffer, ERROR_MSG_LENGTH);
break;
case 'T': /* Tuple results start here */
if (query_completed)
{
res->next = QR_Constructor();
if (!res->next)
@@ -3239,31 +3239,31 @@
alsize *= 2;
pos = len;
continue;
}
}
}
- SOCK_put_char(sock, 'd'); /* CopyData */
- SOCK_put_int(sock, 4 + len, 4);
- SOCK_put_n_char(sock, buf, len);
+ SOCK_put_char(self->sock, 'd'); /* CopyData */
+ SOCK_put_int(self->sock, 4 + len, 4);
+ SOCK_put_n_char(self->sock, buf, len);
pos = 0;
}
if (aborted)
{
mylog("copy fail\n");
- SOCK_put_char(sock, 'f'); /* CopyFail */
- SOCK_put_int(sock, 18, 4);
- SOCK_put_string(sock, "Out of memory");
+ SOCK_put_char(self->sock, 'f'); /* CopyFail */
+ SOCK_put_int(self->sock, 18, 4);
+ SOCK_put_string(self->sock, "Out of memory");
}
else
{
mylog("copy done\n");
- SOCK_put_char(sock, 'c'); /* CopyDone */
- SOCK_put_int(sock, 4, 4);
+ SOCK_put_char(self->sock, 'c'); /* CopyDone */
+ SOCK_put_int(self->sock, 4, 4);
}
- SOCK_flush_output(sock);
+ SOCK_flush_output(self->sock);
free(buf);
}
break;
case 'H': /* Copy out command began successfully */
break;
case 'c': /* Copy out command donesuccessfully */
@@ -3313,13 +3313,13 @@
mylog("send_query: error - %s\n", CC_get_errormsg(self));
ReadyToReturn = TRUE;
retres = NULL;
break;
}
- if (SOCK_get_errcode(sock) != 0)
+ if (SOCK_get_errcode(self->sock) != 0)
break;
if (CONN_DOWN == self->status)
break;
/*
* There was no ReadyForQuery response before 6.4.
*/
@@ -3328,13 +3328,13 @@
if (empty_reqs == 0 && query_completed)
break;
}
}
cleanup:
- if (SOCK_get_errcode(sock) != 0)
+ if (self->sock && SOCK_get_errcode(self->sock) != 0)
{
if (0 == CC_get_errornumber(self))
CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, "Communication error while sending query", func);
kill_conn = TRUE;
ReadyToReturn = TRUE;
}
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
@ 2014-05-01 03:18 ` Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Paquier @ 2014-05-01 03:18 UTC (permalink / raw)
To: malcolm.macleod@tshwanedje.com; +Cc: pgsql-odbc
On Wed, Apr 30, 2014 at 1:44 AM, Malcolm MacLeod
<malcolm.macleod@tshwanedje.com> wrote:
> The crash seems to occur because CC_send_query_append crash takes a
> local copy of the pointer 'self->sock' at the top of the function,
> 'self' is then passed around to various functions (some of which have
> the side effect of setting self->sock to NULL (and deleting) if there is
> a lost connection) and then the local copy of the pointer (which is now
> dangling) is dereferenced lower down in the function.
> Essentially if there is a disconnect while CC_send_query_append is
> running there is a risk of crash.
Looking at the code, I am seeing that the problem is related to
CC_on_abort where conn->sock is set to NULL when the connection is
considered as dead. And I am indeed seeing two code paths (when
sending the 'C' message there is an ABORT check and in cleanup
section) that could use this NULL socket afterwards. Your patch is
perhaps a bit too much. So I am proposing the attached patch instead.
Let me know if this fixes your issue as well.
Regards,
--
Michael
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
20140501_psqlodbc_socket_fix.patch (text/plain, 1.6K) download
diff --git a/connection.c b/connection.c
index 154ada9..1673a8a 100644
--- a/connection.c
+++ b/connection.c
@@ -3065,6 +3065,13 @@ inolog("Discarded the first SAVEPOINT\n");
}
}
+ /*
+ * Leave if socket has been dropped due to a dead
+ * connection.
+ */
+ if (!self->sock)
+ break;
+
if (QR_command_successful(res))
QR_set_rstatus(res, PORES_COMMAND_OK);
QR_set_command(res, cmdbuffer);
@@ -3078,13 +3085,12 @@ inolog("Discarded the first SAVEPOINT\n");
* backend may produce more than one result for some
* commands we need to poll until clear so we send an
* empty query, and keep reading out of the pipe until
- * an 'I' is received
+ * an 'I' is received.
*/
-
- if (empty_reqs == 0)
+ if (self->sock && empty_reqs == 0)
{
- SOCK_put_string(sock, "Q ");
- SOCK_flush_output(sock);
+ SOCK_put_string(self->sock, "Q ");
+ SOCK_flush_output(self->sock);
empty_reqs++;
}
}
@@ -3313,7 +3319,7 @@ mylog("!!! copydata len=%d\n", response_length);
break;
}
- if (SOCK_get_errcode(sock) != 0)
+ if (self->sock && SOCK_get_errcode(self->sock) != 0)
break;
if (CONN_DOWN == self->status)
break;
@@ -3328,7 +3334,7 @@ mylog("!!! copydata len=%d\n", response_length);
}
cleanup:
- if (SOCK_get_errcode(sock) != 0)
+ if (self->sock && SOCK_get_errcode(self->sock) != 0)
{
if (0 == CC_get_errornumber(self))
CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, "Communication error while sending query", func);
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
@ 2014-05-01 11:47 ` Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-05 08:07 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 1 reply; 7+ messages in thread
From: Malcolm MacLeod @ 2014-05-01 11:47 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc
> <malcolm.macleod@tshwanedje.com> wrote:
> > The crash seems to occur because CC_send_query_append crash takes a
> > local copy of the pointer 'self->sock' at the top of the function,
> > 'self' is then passed around to various functions (some of which have
> > the side effect of setting self->sock to NULL (and deleting) if there is
> > a lost connection) and then the local copy of the pointer (which is now
> > dangling) is dereferenced lower down in the function.
> > Essentially if there is a disconnect while CC_send_query_append is
> > running there is a risk of crash.
> Looking at the code, I am seeing that the problem is related to
> CC_on_abort where conn->sock is set to NULL when the connection is
> considered as dead. And I am indeed seeing two code paths (when
> sending the 'C' message there is an ABORT check and in cleanup
> section) that could use this NULL socket afterwards. Your patch is
> perhaps a bit too much. So I am proposing the attached patch instead.
> Let me know if this fixes your issue as well.
Thanks for the fast response!
Your proposed patch would also fix the issue, so I have no problem with
it being used instead.
I guess from my side I just don't personally understand the point of
keeping the local pointer copy at all (it just seems like an invitation
for this sort of thing to occur) - so it made more sense to me to remove
it entirely to prevent future occurrences of similar issues - although I
suppose also the less code disturbed the better. I am not overly
familiar with the code so can't say what is best.
Thanks,
Malcolm
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
@ 2014-05-05 08:07 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-07 14:37 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
0 siblings, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2014-05-05 08:07 UTC (permalink / raw)
To: malcolm.macleod@tshwanedje.com, Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc
On 05/01/2014 02:47 PM, Malcolm MacLeod wrote:
>
>> <malcolm.macleod@tshwanedje.com> wrote:
>>> The crash seems to occur because CC_send_query_append crash takes a
>>> local copy of the pointer 'self->sock' at the top of the function,
>>> 'self' is then passed around to various functions (some of which have
>>> the side effect of setting self->sock to NULL (and deleting) if there is
>>> a lost connection) and then the local copy of the pointer (which is now
>>> dangling) is dereferenced lower down in the function.
>>> Essentially if there is a disconnect while CC_send_query_append is
>>> running there is a risk of crash.
>> Looking at the code, I am seeing that the problem is related to
>> CC_on_abort where conn->sock is set to NULL when the connection is
>> considered as dead. And I am indeed seeing two code paths (when
>> sending the 'C' message there is an ABORT check and in cleanup
>> section) that could use this NULL socket afterwards. Your patch is
>> perhaps a bit too much. So I am proposing the attached patch instead.
>> Let me know if this fixes your issue as well.
>
> Thanks for the fast response!
> Your proposed patch would also fix the issue, so I have no problem with
> it being used instead.
>
> I guess from my side I just don't personally understand the point of
> keeping the local pointer copy at all (it just seems like an invitation
> for this sort of thing to occur) - so it made more sense to me to remove
> it entirely to prevent future occurrences of similar issues - although I
> suppose also the less code disturbed the better. I am not overly
> familiar with the code so can't say what is best.
I agree that keeping the local pointer copy is an accident waiting to
happen. Michael's more surgical approach would make sense if we had to
carefully track the places where self->sock might become NULL. But we
don't, as all the SOCK_* macros and functions contain NULL checks.
I think the extra null check that both patch versions added to the
cleanup code path is also unnecessary and wrong. SOCK_get_errcode()
returns SOCKET_CLOSED error if the argument is null, which will cause
the connection to be marked as dead, which is the right thing to do.
However, when I removed that check, the "diagnostics" regression test
started to fail. What happens is that when the socket is closed while
processing results in CC_send_query_append, the incomplete QResult
object is discarded, even though it contained a useful error message. So
we lose some information that way. But that in turn is pretty simple to
fix: if we don't set ReadyToReturn in the cleanup routine, then the
partial QResult object is returned again.
Looking closer at the loop in CC_send_query_append(), I think it's
basically wrong to set ReadyToReturn when an error occurs. ReadyToReturn
indicates that the whole result set has been processed, and we're ready
to send a new query. In many of the error conditions where we currently
set ReadyToReturn, we're clearly not ready to process the next query.
For example, in the 'T' case, if QR_Constructor() fails because of
out-of-memory, we set ReadyToReturn=true and just bail out of the loop.
That's wrong - we must process the rest of the result set before returning.
Anyway, I committed your original patch with minor changes, which fixes
your original problem (commit 22b151e). But the error handling in that
function could use some more work...
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-05 08:07 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
@ 2014-05-07 14:37 ` Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-12 08:19 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 1 reply; 7+ messages in thread
From: Malcolm MacLeod @ 2014-05-07 14:37 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-odbc
On Mon, 2014-05-05 at 11:07 +0300, Heikki Linnakangas wrote:
> On 05/01/2014 02:47 PM, Malcolm MacLeod wrote:
> >
> >> <malcolm.macleod@tshwanedje.com> wrote:
> >>> The crash seems to occur because CC_send_query_append crash takes a
> >>> local copy of the pointer 'self->sock' at the top of the function,
> >>> 'self' is then passed around to various functions (some of which have
> >>> the side effect of setting self->sock to NULL (and deleting) if there is
> >>> a lost connection) and then the local copy of the pointer (which is now
> >>> dangling) is dereferenced lower down in the function.
> >>> Essentially if there is a disconnect while CC_send_query_append is
> >>> running there is a risk of crash.
> >> Looking at the code, I am seeing that the problem is related to
> >> CC_on_abort where conn->sock is set to NULL when the connection is
> >> considered as dead. And I am indeed seeing two code paths (when
> >> sending the 'C' message there is an ABORT check and in cleanup
> >> section) that could use this NULL socket afterwards. Your patch is
> >> perhaps a bit too much. So I am proposing the attached patch instead.
> >> Let me know if this fixes your issue as well.
> >
> > Thanks for the fast response!
> > Your proposed patch would also fix the issue, so I have no problem with
> > it being used instead.
> >
> > I guess from my side I just don't personally understand the point of
> > keeping the local pointer copy at all (it just seems like an invitation
> > for this sort of thing to occur) - so it made more sense to me to remove
> > it entirely to prevent future occurrences of similar issues - although I
> > suppose also the less code disturbed the better. I am not overly
> > familiar with the code so can't say what is best.
>
> I agree that keeping the local pointer copy is an accident waiting to
> happen. Michael's more surgical approach would make sense if we had to
> carefully track the places where self->sock might become NULL. But we
> don't, as all the SOCK_* macros and functions contain NULL checks.
>
> I think the extra null check that both patch versions added to the
> cleanup code path is also unnecessary and wrong. SOCK_get_errcode()
> returns SOCKET_CLOSED error if the argument is null, which will cause
> the connection to be marked as dead, which is the right thing to do.
> However, when I removed that check, the "diagnostics" regression test
> started to fail. What happens is that when the socket is closed while
> processing results in CC_send_query_append, the incomplete QResult
> object is discarded, even though it contained a useful error message. So
> we lose some information that way. But that in turn is pretty simple to
> fix: if we don't set ReadyToReturn in the cleanup routine, then the
> partial QResult object is returned again.
>
> Looking closer at the loop in CC_send_query_append(), I think it's
> basically wrong to set ReadyToReturn when an error occurs. ReadyToReturn
> indicates that the whole result set has been processed, and we're ready
> to send a new query. In many of the error conditions where we currently
> set ReadyToReturn, we're clearly not ready to process the next query.
> For example, in the 'T' case, if QR_Constructor() fails because of
> out-of-memory, we set ReadyToReturn=true and just bail out of the loop.
> That's wrong - we must process the rest of the result set before returning.
>
> Anyway, I committed your original patch with minor changes, which fixes
> your original problem (commit 22b151e). But the error handling in that
> function could use some more work...
Thanks! Will get a copy of the latest code and use it for testing.
Unfortunately I don't have the time to get familiar with the code myself
or I would try help a bit more. I will throw our stress tests at the
latest code and see if anything else turns up though.
Any idea on when the next official psqlodbc build is likely to take
place? Would be nice to know for planning purposes so we can get our
clients onto a fixed version.
- Malcolm MacLeod
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-05 08:07 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-07 14:37 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
@ 2014-05-12 08:19 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-12 12:52 ` Re: CC_send_query_append crash Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2014-05-12 08:19 UTC (permalink / raw)
To: malcolm.macleod@tshwanedje.com; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-odbc; Hiroshi Saito <hiroshi@winpg.jp>
On 05/07/2014 05:37 PM, Malcolm MacLeod wrote:
> Any idea on when the next official psqlodbc build is likely to take
> place? Would be nice to know for planning purposes so we can get our
> clients onto a fixed version.
CC'ing Hiroshi Saito. He has usually prepared the releases, I don't know
if he has any imminent plans.
There have been a few bug fixes since last release, including this one,
so it would be nice to get a release out. Then again, none of the bugs
fixed have been very serious, so there's no big hurry.
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CC_send_query_append crash
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Re: CC_send_query_append crash Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-05 08:07 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-07 14:37 ` Re: CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-12 08:19 ` Re: CC_send_query_append crash Heikki Linnakangas <hlinnakangas@vmware.com>
@ 2014-05-12 12:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 7+ messages in thread
From: Alvaro Herrera @ 2014-05-12 12:52 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: malcolm.macleod@tshwanedje.com, Michael Paquier <michael.paquier@gmail.com>; pgsql-odbc; Hiroshi Saito <hiroshi@winpg.jp>
Heikki Linnakangas wrote:
> On 05/07/2014 05:37 PM, Malcolm MacLeod wrote:
> >Any idea on when the next official psqlodbc build is likely to take
> >place? Would be nice to know for planning purposes so we can get our
> >clients onto a fixed version.
>
> CC'ing Hiroshi Saito. He has usually prepared the releases, I don't
> know if he has any imminent plans.
>
> There have been a few bug fixes since last release, including this
> one, so it would be nice to get a release out. Then again, none of
> the bugs fixed have been very serious, so there's no big hurry.
Can I direct your attention towards
http://www.postgresql.org/message-id/20140318183906.GW6899@eldon.alvh.no-ip.org
? I'm not in a position to produce a tested patch, but it should be
fairly trivial in nature.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2014-05-12 12:52 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29 16:44 CC_send_query_append crash Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-01 03:18 ` Michael Paquier <michael.paquier@gmail.com>
2014-05-01 11:47 ` Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-05 08:07 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-07 14:37 ` Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
2014-05-12 08:19 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-05-12 12:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox