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

Commitde9a4c2

Browse files
committed
Add PQlibVersion() function to libpq
This function is like the PQserverVersion() function exceptit returns the version of libpq, making it possible for a clientprogram or driver to determine which version of libpq is inuse at runtime, and not just at link time.Suggested by Harald Armin Massa and several others.
1 parent32ba2b5 commitde9a4c2

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5359,6 +5359,50 @@ void *PQresultAlloc(PGresult *res, size_t nBytes);
53595359
</listitem>
53605360
</varlistentry>
53615361

5362+
<varlistentry id="libpq-pqlibversion">
5363+
<term>
5364+
<function>PQlibVersion</function>
5365+
<indexterm>
5366+
<primary>PQlibVersion</primary>
5367+
<seealso>PQserverVersion</seealso>
5368+
</indexterm>
5369+
</term>
5370+
5371+
<listitem>
5372+
<para>
5373+
Return the version of <productname>libpq</> that is being used.
5374+
<synopsis>
5375+
int PQlibVersion(void);
5376+
</synopsis>
5377+
</para>
5378+
5379+
<para>
5380+
The result of this function can be used to determine, at
5381+
runtime, if specific functionality is available in the currently
5382+
loaded version of libpq. The function can be used, for example,
5383+
to determine which connection options are available for
5384+
<function>PQconnectdb</> or if the <literal>hex</> <type>bytea</>
5385+
output added in PostgreSQL 9.0 is supported.
5386+
</para>
5387+
5388+
<para>
5389+
The number is formed by converting the major, minor, and revision
5390+
numbers into two-decimal-digit numbers and appending them together.
5391+
For example, version 9.1 will be returned as 90100, and version
5392+
9.1.2 will be returned as 90102 (leading zeroes are not shown).
5393+
</para>
5394+
5395+
<note>
5396+
<para>
5397+
This function appeared in <productname>PostgreSQL</> version 9.1, so
5398+
it cannot be used to detect required functionality in earlier
5399+
versions, since linking to it will create a link dependency
5400+
on version 9.1.
5401+
</para>
5402+
</note>
5403+
</listitem>
5404+
</varlistentry>
5405+
53625406
</variablelist>
53635407

53645408
</sect1>

‎src/interfaces/libpq/exports.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@ PQconnectdbParams 156
159159
PQconnectStartParams 157
160160
PQping 158
161161
PQpingParams 159
162+
PQlibVersion 160

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ static int pqSocketCheck(PGconn *conn, int forRead, int forWrite,
6666
time_tend_time);
6767
staticintpqSocketPoll(intsock,intforRead,intforWrite,time_tend_time);
6868

69+
/*
70+
* PQlibVersion: return the libpq version number
71+
*/
72+
int
73+
PQlibVersion(void)
74+
{
75+
returnPG_VERSION_NUM;
76+
}
6977

7078
/*
7179
* fputnbytes: print exactly N bytes to a file

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ extern intlo_export(PGconn *conn, Oid lobjId, const char *filename);
547547

548548
/* === in fe-misc.c === */
549549

550+
/* Get the version of the libpq library in use */
551+
externintPQlibVersion(void);
552+
550553
/* Determine length of multibyte encoded char at *s */
551554
externintPQmblen(constchar*s,intencoding);
552555

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp