[NOVICE] Executing prepared statements in the multithreaded envs - Mailing list pgsql-novice

From Ruslan R. Laishev
Subject [NOVICE] Executing prepared statements in the multithreaded envs
Date
Msg-id 344601508248844@web36g.yandex.ru
Whole thread Raw
Responses Re: [NOVICE] Executing prepared statements in the multithreaded envs  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-novice
Hi All!
 
I'd like to use a pool of connections in multi-threaded environment, so:
 
1. I created a pool of N-connection by calling PQconnectdb().
2. Do I'm need to calling PQprepare() for the every sql_query for the every connection from the pool ?
 
#define POOLSZ 3
PGconn pool[POOLSZ];
 
#define QUERYSZ 2
const char SQL_Qry_name [QUERYSZ][32] = { {"add_pdp11"}, {"add_mvax2"} };
const char SQL_Qry_expr [QUERYSZ][128] = { {"select add_pdp11($1, $1, $3);"}, {"select add_mvax2($1, $1, $3, $4, $5);" } };
 
/* Create connections pool ... */
for (i = 0; i < POOLSZ; i++)
pool[i] = PGconnectdb(...);
 
/* Prepare every SQL expression in the every session */
for (i = 0; i < POOLSZ; i++)
for (j = 0; j < QUERYSZ; i++)
PQrepare(SQL_Qry_name[j], SQL_Qry_expr[j], ...);
 
 
 
So, do I running in the right direction ?
 
-- 
С уважением,
Ruslan R. Laishev
OpenVMS bigot, natural born system/network progger, C contractor.
+79013163222
+79910009922
 

pgsql-novice by date:

Previous
From: Gerald Cheves
Date:
Subject: Re: [NOVICE] The server does not listen
Next
From: "David G. Johnston"
Date:
Subject: Re: [NOVICE] Executing prepared statements in the multithreaded envs