Re: Executing prepared statements in the multithreaded envs

From: Ruslan R(dot) Laishev <zator(at)yandex(dot)ru>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Executing prepared statements in the multithreaded envs
Date: 2017-10-17 15:16:35
Message-ID: 2410381508253395@web22g.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<div><div>A quotation from the docs "for me" :</div><div> </div><div>PQprepare</div><div>Submits a request to create a prepared statement with the given parameters, and waits for com-</div><div>pletion.</div><div>PGresult</div><div>* PQprepare(PGconn * conn,</div><div>const char</div><div>* stmtName,</div><div>const char</div><div>* query,</div><div>int nParams,</div><div>const Oid</div><div>* paramTypes);</div><div>PQprepare creates a prepared statement for later execution with PQexecPrepared . This fea-</div><div>ture allows commands to be executed repeatedly without being parsed and planned each time;</div><div>see PREPARE for details. PQprepare is supported only in protocol 3.0 and later connections; it</div><div>will fail when using protocol 2.0.</div><div>The function creates a prepared statement named stmtName from the query string, which must</div><div>contain a single SQL command. stmtName can be "" to create an unnamed statement, in which</div><div>case any pre-existing unnamed statement is automatically replaced; otherwise it is an error if the</div><div>statement name is already defined in the current session. If any parameters are used, they are</div><div>referred to in the query as $1 , $2 , etc. nParams is the number of parameters for which types</div><div>are pre-specified in the array paramTypes[] . (The array pointer can be NULL when nParams is</div><div>zero.) paramTypes[] specifies, by OID, the data types to be assigned to the parameter symbols.</div><div>If paramTypes is NULL , or any particular element in the array is zero, the server assigns a data</div><div>type to the parameter symbol in the same way it would do for an untyped literal string. Also, the</div><div>query can use parameter symbols with numbers higher than nParams ; data types will be inferred</div><div>for these symbols as well. (See PQdescribePrepared for a means to find out what data types</div><div>were inferred.)</div><div> </div><div> </div><div>The result is not documented at all. So ...</div><div>Thanks David for your time. :-)</div><div> </div></div><div> </div><div>17.10.2017, 18:08, "David G. Johnston" &lt;david(dot)g(dot)johnston(at)gmail(dot)com&gt;:</div><blockquote type="cite"><div><div style="font-family:arial,helvetica,sans-serif;"><span style="font-family:arial,sans-serif;">On Tue, Oct 17, 2017 at 8:02 AM, Ruslan R. Laishev </span><span style="font-family:arial,sans-serif;">&lt;<a target="_blank" href="mailto:zator(at)yandex(dot)ru">zator(at)yandex(dot)ru</a>&gt;</span><span style="font-family:arial,sans-serif;"> wrote:</span></div><div><div><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>Ho to check the PQprepare result ?</div><div>NULL or noNULL ?</div><div> </div></blockquote><div> </div><div style="font-family:arial,helvetica,sans-serif;">That seems like it should be documented...I'm not a C programmer and don't have time right now to go look at the docs for you.</div><div style="font-family:arial,helvetica,sans-serif;"> </div><div style="font-family:arial,helvetica,sans-serif;">David J.​</div></div></div></div></blockquote><div> </div><div> </div><div>-- </div><div>С уважением,<br />Ruslan R. Laishev</div><div>OpenVMS bigot, natural born system/network progger, C contractor.</div><div>+79013163222</div><div>+79910009922</div><div> </div>

Attachment Content-Type Size
unknown_filename text/html 3.3 KB

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2017-10-17 15:25:49 Re: Executing prepared statements in the multithreaded envs
Previous Message David G. Johnston 2017-10-17 15:08:26 Re: Executing prepared statements in the multithreaded envs