BUG #7841: Multithreading in libpq is not working
BUG #7841: Multithreading in libpq is not working
От:
biernatj@interia.pl
Дата:
The following bug has been logged on the website:
Bug reference: 7841
Logged by: Joanna Biernat-Gerono
Email address: biernatj@interia.pl
PostgreSQL version: 9.2.2
Operating system: Windows 7
Description: =
Sample code that provides to access violation (I am using the latest libpq
that is compiled with multithread support, connection was made to two
different dbs). The code is below:
#define WINNT_OS
#include
#include
#include "libpq-fe.h"
#include
#define STD__NULL NULL
#define STD__SUCCESS 0
#define STD__FAILED -1
#define STD__FAIL -1
#define TIMEOUT 100
using namespace std;
volatile bool m_bLicenseCheckedOut =3D false;
enum status
{
idle, =
running,
stop,
done
} m_running =3D idle;
int m_renewalTime =3D 0;
HANDLE m_hThread =3D NULL;
HANDLE m_hEvent =3D NULL;
DWORD WINAPI threadProc(LPVOID lpvoid)
{ =
int step =3D 0;
while(m_running =3D=3D running) { =
PGconn *conn;
=
try { =
const char *keys[]=3D{"dbname", "user", "password", "host", "port",
"sslcert", "sslkey", "sslrootcert", "sslmode", NULL};
const char *values[]=3D{"put_value_here", "put_value_here" ,
"put_value_here" , "put_value_here" , "put_value_here" , "put_value_here",
"put_value_here", "put_value_here" ,"verify-full", NULL};
=
// conn =3D PQconnectdbParams(keys,values,0);
//conn =3D PQsetdbLogin("put_value_here", "put_value_here", NULL,
NULL, "dbname=3Dput_value_here sslcert=3Dput_value_here sslkey=3Dput_value_=
here
sslrootcert=3Dput_value_here sslmode=3Dverify-full", "put_value_here" ,
"put_value_here");
conn =3D PQsetdbLogin("put_value_here", "put_value_here", NULL, NUL=
L,
"put_value_here", "put_value_here" , "put_value_here");
long status =3D PQstatus(conn);
=
if (status =3D=3D CONNECTION_OK) {
cout << "\nSuccessfully connected to DB:"<