(2013/06/12 1:26), Andres Freund wrote:
On 2013-06-11 19:20:57 +0300, Heikki Linnakangas wrote:
On 11.06.2013 19:04, Joshua Berry wrote:
Hiroshi Inoue has developed the attached patch to correct the issue that
was reported. More of the dialogue can be found in the pgsql-odbc list.
I tried to follow that thread over at pgsql-odbc, but couldn't quite
understand what the problem is. Did you have a test program to reproduce it?
Or failing that, what is the sequence of protocol messages that causes the
problem?
I'd guess creating a SQL level WITH HOLD cursor and then fetching that
via the extended protocol, outside the transaction, should do the trick.
OK I made a test C program which reproduces the crash.
The program uses libpq and a hack.
I attached the program.
Please modify the connect operation suitable for your environment.
Note that the connection should be non-ssl.
Also add error checkings if needed.
regards,
Hiroshi Inoue
#include <libpq-fe.h>
#ifdef WIN32
#include <WinSock2.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#endif
#define MY_CUR "mycur"
int main(int argc, const char **argv)
{
const char *connstr;
PGconn *conn;
PGresult *result;
int sock;
int len, count;
if (argc > 1)
connstr = argv[1];
else
connstr = "host=localhost port=5432 dbname=xxxxx user=xxxxx password=xxxxx";
conn = PQconnectdb(connstr);
result = PQexec(conn, "declare " MY_CUR " cursor with hold for select * from generate_series(1, 2) as i");
if (PQgetssl(conn) != NULL)
{
printf("Use non-ssl connection\n");
return 1;
}
sock = PQsocket(conn);
if (sock < 0)
{
printf("socket error\n");
return 1;
}
// send execute message
send(sock, "E", 1, 0);
len = sizeof(len) + strlen(MY_CUR) + 1 + sizeof(count);
len = htonl(len);
send(sock, (const char *) &len, sizeof(len), 0);
send(sock, MY_CUR, strlen(MY_CUR) + 1, 0);
count = htonl(1);
send(sock, (const char *) &count, sizeof(count), 0);
result = PQexec(conn, "close " MY_CUR);
if (!result)
printf("close error\n");
else
printf("result error=%s\n", PQresultErrorMessage(result));
PQfinish(conn);
return 0;
}
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs