Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitefc3a25

Browse files
committed
Update libpq to make new features of FE/BE protocol available to
client applications. Some editorial work on libpq.sgml, too.
1 parentb8d601e commitefc3a25

File tree

11 files changed

+2524
-832
lines changed

11 files changed

+2524
-832
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 1184 additions & 462 deletions
Large diffs are not rendered by default.

‎doc/src/sgml/lobj.sgml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/lobj.sgml,v 1.28 2003/03/13 01:30:28 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/lobj.sgml,v 1.29 2003/06/21 21:51:33 tgl Exp $
33
-->
44

55
<chapter id="largeObjects">
@@ -181,7 +181,8 @@ int lo_open(PGconn *conn, Oid lobjId, int mode);
181181
<function>lo_open</function> returns a large object descriptor
182182
for later use in <function>lo_read</function>, <function>lo_write</function>,
183183
<function>lo_lseek</function>, <function>lo_tell</function>, and
184-
<function>lo_close</function>.
184+
<function>lo_close</function>. The descriptor is only valid for
185+
the duration of the current transaction.
185186
</para>
186187
</sect2>
187188

@@ -256,6 +257,11 @@ int lo_close(PGconn *conn, int fd);
256257
<function>lo_open</function>. On success, <function>lo_close</function>
257258
returns zero. On error, the return value is negative.
258259
</para>
260+
261+
<para>
262+
Any large object descriptors that remain open at the end of a
263+
transaction will be closed automatically.
264+
</para>
259265
</sect2>
260266

261267
<sect2>
@@ -296,6 +302,14 @@ SELECT lo_export(image.raster, '/tmp/motd') FROM image
296302
WHERE name = 'beautiful image';
297303
</programlisting>
298304
</para>
305+
306+
<para>
307+
These functions read and write files in the server's filesystem, using the
308+
permissions of the database's owning user. Therefore, their use is restricted
309+
to superusers. (In contrast, the client-side import and export functions
310+
read and write files in the client's filesystem, using the permissions of
311+
the client program. Their use is not restricted.)
312+
</para>
299313
</sect1>
300314

301315
<sect1 id="lo-examplesect">

‎src/interfaces/libpq/blibpqdll.def

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ EXPORTS
9797
_pg_utf_mblen @ 93
9898
_PQunescapeBytea @ 94
9999
_PQfreemem @ 95
100+
_PQtransactionStatus @ 96
101+
_PQparameterStatus @ 97
102+
_PQprotocolVersion @ 98
103+
_PQsetErrorVerbosity @ 99
104+
_PQsetNoticeReceiver @ 100
105+
_PQexecParams @ 101
106+
_PQsendQueryParams @ 102
107+
_PQputCopyData @ 103
108+
_PQputCopyEnd @ 104
109+
_PQgetCopyData @ 105
110+
_PQresultErrorField @ 106
111+
_PQftable @ 107
112+
_PQftablecol @ 108
113+
_PQfformat @ 109
100114

101115
; Aliases for MS compatible names
102116
PQconnectdb = _PQconnectdb
@@ -194,4 +208,17 @@ EXPORTS
194208
pg_utf_mblen = _pg_utf_mblen
195209
PQunescapeBytea = _PQunescapeBytea
196210
PQfreemem = _PQfreemem
197-
211+
PQtransactionStatus = _PQtransactionStatus
212+
PQparameterStatus = _PQparameterStatus
213+
PQprotocolVersion = _PQprotocolVersion
214+
PQsetErrorVerbosity = _PQsetErrorVerbosity
215+
PQsetNoticeReceiver = _PQsetNoticeReceiver
216+
PQexecParams = _PQexecParams
217+
PQsendQueryParams = _PQsendQueryParams
218+
PQputCopyData = _PQputCopyData
219+
PQputCopyEnd = _PQputCopyEnd
220+
PQgetCopyData = _PQgetCopyData
221+
PQresultErrorField = _PQresultErrorField
222+
PQftable = _PQftable
223+
PQftablecol = _PQftablecol
224+
PQfformat = _PQfformat

‎src/interfaces/libpq/fe-connect.c

Lines changed: 92 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.249 2003/06/20 04:09:12 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.250 2003/06/21 21:51:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -176,6 +176,7 @@ static PQconninfoOption *conninfo_parse(const char *conninfo,
176176
PQExpBuffererrorMessage);
177177
staticchar*conninfo_getval(PQconninfoOption*connOptions,
178178
constchar*keyword);
179+
staticvoiddefaultNoticeReceiver(void*arg,constPGresult*res);
179180
staticvoiddefaultNoticeProcessor(void*arg,constchar*message);
180181
staticintparseServiceInfo(PQconninfoOption*options,
181182
PQExpBuffererrorMessage);
@@ -1804,11 +1805,14 @@ makeEmptyPGconn(void)
18041805
/* Zero all pointers and booleans */
18051806
MemSet((char*)conn,0,sizeof(PGconn));
18061807

1807-
conn->noticeHook=defaultNoticeProcessor;
1808+
conn->noticeHooks.noticeRec=defaultNoticeReceiver;
1809+
conn->noticeHooks.noticeProc=defaultNoticeProcessor;
18081810
conn->status=CONNECTION_BAD;
18091811
conn->asyncStatus=PGASYNC_IDLE;
1812+
conn->xactStatus=PQTRANS_IDLE;
18101813
conn->setenv_state=SETENV_STATE_IDLE;
18111814
conn->client_encoding=PG_SQL_ASCII;
1815+
conn->verbosity=PQERRORS_DEFAULT;
18121816
conn->notifyList=DLNewList();
18131817
conn->sock=-1;
18141818
#ifdefUSE_SSL
@@ -1850,7 +1854,6 @@ makeEmptyPGconn(void)
18501854
/*
18511855
* freePGconn
18521856
* - free the PGconn data structure
1853-
*
18541857
*/
18551858
staticvoid
18561859
freePGconn(PGconn*conn)
@@ -1899,9 +1902,9 @@ freePGconn(PGconn *conn)
18991902
}
19001903

19011904
/*
1902-
closePGconn
1903-
- properly close a connection to the backend
1904-
*/
1905+
* closePGconn
1906+
* - properly close a connection to the backend
1907+
*/
19051908
staticvoid
19061909
closePGconn(PGconn*conn)
19071910
{
@@ -2662,6 +2665,41 @@ PQstatus(const PGconn *conn)
26622665
returnconn->status;
26632666
}
26642667

2668+
PGTransactionStatusType
2669+
PQtransactionStatus(constPGconn*conn)
2670+
{
2671+
if (!conn||conn->status!=CONNECTION_OK)
2672+
returnPQTRANS_UNKNOWN;
2673+
if (conn->asyncStatus!=PGASYNC_IDLE)
2674+
returnPQTRANS_ACTIVE;
2675+
returnconn->xactStatus;
2676+
}
2677+
2678+
constchar*
2679+
PQparameterStatus(constPGconn*conn,constchar*paramName)
2680+
{
2681+
constpgParameterStatus*pstatus;
2682+
2683+
if (!conn|| !paramName)
2684+
returnNULL;
2685+
for (pstatus=conn->pstatus;pstatus!=NULL;pstatus=pstatus->next)
2686+
{
2687+
if (strcmp(pstatus->name,paramName)==0)
2688+
returnpstatus->value;
2689+
}
2690+
returnNULL;
2691+
}
2692+
2693+
int
2694+
PQprotocolVersion(constPGconn*conn)
2695+
{
2696+
if (!conn)
2697+
return0;
2698+
if (conn->status==CONNECTION_BAD)
2699+
return0;
2700+
returnPG_PROTOCOL_MAJOR(conn->pversion);
2701+
}
2702+
26652703
char*
26662704
PQerrorMessage(constPGconn*conn)
26672705
{
@@ -2731,11 +2769,22 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
27312769
return (status);
27322770
}
27332771

2772+
PGVerbosity
2773+
PQsetErrorVerbosity(PGconn*conn,PGVerbosityverbosity)
2774+
{
2775+
PGVerbosityold;
2776+
2777+
if (!conn)
2778+
returnPQERRORS_DEFAULT;
2779+
old=conn->verbosity;
2780+
conn->verbosity=verbosity;
2781+
returnold;
2782+
}
2783+
27342784
void
27352785
PQtrace(PGconn*conn,FILE*debug_port)
27362786
{
2737-
if (conn==NULL||
2738-
conn->status==CONNECTION_BAD)
2787+
if (conn==NULL)
27392788
return;
27402789
PQuntrace(conn);
27412790
conn->Pfdebug=debug_port;
@@ -2744,7 +2793,6 @@ PQtrace(PGconn *conn, FILE *debug_port)
27442793
void
27452794
PQuntrace(PGconn*conn)
27462795
{
2747-
/* note: better allow untrace even when connection bad */
27482796
if (conn==NULL)
27492797
return;
27502798
if (conn->Pfdebug)
@@ -2754,6 +2802,23 @@ PQuntrace(PGconn *conn)
27542802
}
27552803
}
27562804

2805+
PQnoticeReceiver
2806+
PQsetNoticeReceiver(PGconn*conn,PQnoticeReceiverproc,void*arg)
2807+
{
2808+
PQnoticeReceiverold;
2809+
2810+
if (conn==NULL)
2811+
returnNULL;
2812+
2813+
old=conn->noticeHooks.noticeRec;
2814+
if (proc)
2815+
{
2816+
conn->noticeHooks.noticeRec=proc;
2817+
conn->noticeHooks.noticeRecArg=arg;
2818+
}
2819+
returnold;
2820+
}
2821+
27572822
PQnoticeProcessor
27582823
PQsetNoticeProcessor(PGconn*conn,PQnoticeProcessorproc,void*arg)
27592824
{
@@ -2762,22 +2827,35 @@ PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
27622827
if (conn==NULL)
27632828
returnNULL;
27642829

2765-
old=conn->noticeHook;
2830+
old=conn->noticeHooks.noticeProc;
27662831
if (proc)
27672832
{
2768-
conn->noticeHook=proc;
2769-
conn->noticeArg=arg;
2833+
conn->noticeHooks.noticeProc=proc;
2834+
conn->noticeHooks.noticeProcArg=arg;
27702835
}
27712836
returnold;
27722837
}
27732838

27742839
/*
2775-
* The default notice/error message processor just prints the
2840+
* The default notice message receiver just gets the standard notice text
2841+
* and sends it to the notice processor. This two-level setup exists
2842+
* mostly for backwards compatibility; perhaps we should deprecate use of
2843+
* PQsetNoticeProcessor?
2844+
*/
2845+
staticvoid
2846+
defaultNoticeReceiver(void*arg,constPGresult*res)
2847+
{
2848+
(void)arg;/* not used */
2849+
(*res->noticeHooks.noticeProc) (res->noticeHooks.noticeProcArg,
2850+
PQresultErrorMessage(res));
2851+
}
2852+
2853+
/*
2854+
* The default notice message processor just prints the
27762855
* message on stderr. Applications can override this if they
27772856
* want the messages to go elsewhere (a window, for example).
27782857
* Note that simply discarding notices is probably a bad idea.
27792858
*/
2780-
27812859
staticvoid
27822860
defaultNoticeProcessor(void*arg,constchar*message)
27832861
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp