]> granicus.if.org Git - postgresql/commitdiff
Add PQserverVersion() to libpq to provide more-convenient access to
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Aug 2004 18:06:01 +0000 (18:06 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Aug 2004 18:06:01 +0000 (18:06 +0000)
the server version number.  This commit also removes bogus DOS line
endings from libpqddll.def.

Greg Sabino Mullane

doc/src/sgml/libpq.sgml
src/interfaces/libpq/blibpqdll.def
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpqddll.def
src/interfaces/libpq/libpqdll.def

index 5b94442238ad86f5e78ae4e270a91242ca977149..402f77bd7d41999194d821f5f27fedfb325f9328 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.157 2004/06/08 13:49:22 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.158 2004/08/11 18:06:00 tgl Exp $
 -->
 
  <chapter id="libpq">
@@ -892,6 +892,24 @@ The 3.0 protocol will normally be used when communicating with
 only protocol 2.0.  (Protocol 1.0 is obsolete and not supported by <application>libpq</application>.)
 </para>
 </listitem>
+</varlistentry>
+
+<varlistentry>
+<term><function>PQserverVersion</function><indexterm><primary>PQserverVersion</></></term>
+<listitem>
+<para>
+         Returns an integer representing the backend version.
+<synopsis>
+int PQserverVersion(const PGconn *conn);
+</synopsis>
+Applications may use this to determine the version of the database server they
+are connected to. The number is formed by converting the major, minor, and
+revision numbers into two digit numbers and appending them together. For
+example, version 7.4.2 will be returned as 70402, and version 8.1 will be
+returned as 80100 (leading zeroes are not shown).  Zero is returned if the
+connection is bad.
+</para>
+</listitem>
 </varlistentry>
 
     <varlistentry>
index eb78e770f8aec358f471a06a5a66c284f0c29261..279d958675690ff0952bce4e7ded72b2cfec015e 100644 (file)
@@ -113,6 +113,8 @@ EXPORTS
     _PQfformat               @ 109
     _PQexecPrepared          @ 110
     _PQsendQueryPrepared     @ 111
+    _PQdsplen                @ 112
+    _PQserverVersion         @ 113
 
 ; Aliases for MS compatible names
     PQconnectdb             = _PQconnectdb            
@@ -226,3 +228,5 @@ EXPORTS
     PQfformat               = _PQfformat
     PQexecPrepared          = _PQexecPrepared
     PQsendQueryPrepared     = _PQsendQueryPrepared
+    PQdsplen                = _PQdsplen
+    PQserverVersion         = _PQserverVersion
index ef50381122844112267a28a8427cca2cb50a48b5..e4744854c55558b6b760ff8a9541bed5530ff35c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.278 2004/07/12 14:23:28 momjian Exp $
+ *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.279 2004/08/11 18:06:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2872,6 +2872,16 @@ PQprotocolVersion(const PGconn *conn)
        return PG_PROTOCOL_MAJOR(conn->pversion);
 }
 
+int
+PQserverVersion(const PGconn *conn)
+{
+       if (!conn)
+               return 0;
+       if (conn->status == CONNECTION_BAD)
+               return 0;
+       return conn->sversion;
+}
+
 char *
 PQerrorMessage(const PGconn *conn)
 {
index 7a143888bb4107aebce02c75c5586cca25d5e0f1..fbd31d01bf2f679d3a38e183ccbf367df23d37a9 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.104 2004/03/24 03:44:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.105 2004/08/11 18:06:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -248,6 +248,7 @@ extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
 extern const char *PQparameterStatus(const PGconn *conn,
                                  const char *paramName);
 extern int     PQprotocolVersion(const PGconn *conn);
+extern int  PQserverVersion(const PGconn *conn);
 extern char *PQerrorMessage(const PGconn *conn);
 extern int     PQsocket(const PGconn *conn);
 extern int     PQbackendPID(const PGconn *conn);
index bd2460dffbc37e2b7dc65812d4f13a7235c6dc34..7a05da81171c6bd7086eed7dd67318b4c2e1136e 100644 (file)
-; DEF file for MS VC++\r
-LIBRARY LIBPQD\r
-DESCRIPTION "PostgreSQL Client Library"\r
-EXPORTS\r
-    PQconnectdb             @ 1\r
-    PQsetdbLogin            @ 2\r
-    PQconndefaults          @ 3\r
-    PQfinish                @ 4\r
-    PQreset                 @ 5\r
-    PQrequestCancel         @ 6\r
-    PQdb                    @ 7\r
-    PQuser                  @ 8\r
-    PQpass                  @ 9\r
-    PQhost                  @ 10\r
-    PQport                  @ 11\r
-    PQtty                   @ 12\r
-    PQoptions               @ 13\r
-    PQstatus                @ 14\r
-    PQerrorMessage          @ 15\r
-    PQsocket                @ 16\r
-    PQbackendPID            @ 17\r
-    PQtrace                 @ 18\r
-    PQuntrace               @ 19\r
-    PQsetNoticeProcessor    @ 20\r
-    PQexec                  @ 21\r
-    PQnotifies              @ 22\r
-    PQsendQuery             @ 23\r
-    PQgetResult             @ 24\r
-    PQisBusy                @ 25\r
-    PQconsumeInput          @ 26\r
-    PQgetline               @ 27\r
-    PQputline               @ 28\r
-    PQgetlineAsync          @ 29\r
-    PQputnbytes             @ 30\r
-    PQendcopy               @ 31\r
-    PQfn                    @ 32\r
-    PQresultStatus          @ 33\r
-    PQntuples               @ 34\r
-    PQnfields               @ 35\r
-    PQbinaryTuples          @ 36\r
-    PQfname                 @ 37\r
-    PQfnumber               @ 38\r
-    PQftype                 @ 39\r
-    PQfsize                 @ 40\r
-    PQfmod                  @ 41\r
-    PQcmdStatus             @ 42\r
-    PQoidStatus             @ 43\r
-    PQcmdTuples             @ 44\r
-    PQgetvalue              @ 45\r
-    PQgetlength             @ 46\r
-    PQgetisnull             @ 47\r
-    PQclear                 @ 48\r
-    PQmakeEmptyPGresult     @ 49\r
-    PQprint                 @ 50\r
-    PQdisplayTuples         @ 51\r
-    PQprintTuples           @ 52\r
-    lo_open                 @ 53\r
-    lo_close                @ 54\r
-    lo_read                 @ 55\r
-    lo_write                @ 56\r
-    lo_lseek                @ 57\r
-    lo_creat                @ 58\r
-    lo_tell                 @ 59\r
-    lo_unlink               @ 60\r
-    lo_import               @ 61\r
-    lo_export               @ 62\r
-    pgresStatus             @ 63\r
-    PQmblen                 @ 64\r
-    PQresultErrorMessage    @ 65\r
-    PQresStatus             @ 66\r
-    termPQExpBuffer         @ 67\r
-    appendPQExpBufferChar   @ 68\r
-    initPQExpBuffer         @ 69\r
-    resetPQExpBuffer        @ 70\r
-    PQoidValue              @ 71\r
-    PQclientEncoding        @ 72\r
-    PQenv2encoding          @ 73\r
-    appendBinaryPQExpBuffer @ 74\r
-    appendPQExpBufferStr    @ 75\r
-    destroyPQExpBuffer      @ 76\r
-    createPQExpBuffer       @ 77\r
-    PQconninfoFree          @ 78\r
-    PQconnectPoll           @ 79\r
-    PQconnectStart          @ 80\r
-    PQflush                 @ 81\r
-    PQisnonblocking         @ 82\r
-    PQresetPoll             @ 83\r
-    PQresetStart            @ 84\r
-    PQsetClientEncoding     @ 85\r
-    PQsetnonblocking        @ 86\r
-    PQfreeNotify            @ 87\r
-    PQescapeString          @ 88\r
-    PQescapeBytea           @ 89\r
-    printfPQExpBuffer       @ 90\r
-    appendPQExpBuffer       @ 91\r
-    pg_encoding_to_char     @ 92\r
-    pg_utf_mblen            @ 93\r
-    PQunescapeBytea         @ 94\r
-    PQfreemem               @ 95\r
-    PQtransactionStatus     @ 96\r
-    PQparameterStatus       @ 97\r
-    PQprotocolVersion       @ 98\r
-    PQsetErrorVerbosity     @ 99\r
-    PQsetNoticeReceiver     @ 100\r
-    PQexecParams            @ 101\r
-    PQsendQueryParams       @ 102\r
-    PQputCopyData           @ 103\r
-    PQputCopyEnd            @ 104\r
-    PQgetCopyData           @ 105\r
-    PQresultErrorField      @ 106\r
-    PQftable                @ 107\r
-    PQftablecol             @ 108\r
-    PQfformat               @ 109\r
-    PQexecPrepared          @ 110\r
-    PQsendQueryPrepared     @ 111\r
+; DEF file for MS VC++
+LIBRARY LIBPQD
+DESCRIPTION "PostgreSQL Client Library"
+EXPORTS
+    PQconnectdb             @ 1
+    PQsetdbLogin            @ 2
+    PQconndefaults          @ 3
+    PQfinish                @ 4
+    PQreset                 @ 5
+    PQrequestCancel         @ 6
+    PQdb                    @ 7
+    PQuser                  @ 8
+    PQpass                  @ 9
+    PQhost                  @ 10
+    PQport                  @ 11
+    PQtty                   @ 12
+    PQoptions               @ 13
+    PQstatus                @ 14
+    PQerrorMessage          @ 15
+    PQsocket                @ 16
+    PQbackendPID            @ 17
+    PQtrace                 @ 18
+    PQuntrace               @ 19
+    PQsetNoticeProcessor    @ 20
+    PQexec                  @ 21
+    PQnotifies              @ 22
+    PQsendQuery             @ 23
+    PQgetResult             @ 24
+    PQisBusy                @ 25
+    PQconsumeInput          @ 26
+    PQgetline               @ 27
+    PQputline               @ 28
+    PQgetlineAsync          @ 29
+    PQputnbytes             @ 30
+    PQendcopy               @ 31
+    PQfn                    @ 32
+    PQresultStatus          @ 33
+    PQntuples               @ 34
+    PQnfields               @ 35
+    PQbinaryTuples          @ 36
+    PQfname                 @ 37
+    PQfnumber               @ 38
+    PQftype                 @ 39
+    PQfsize                 @ 40
+    PQfmod                  @ 41
+    PQcmdStatus             @ 42
+    PQoidStatus             @ 43
+    PQcmdTuples             @ 44
+    PQgetvalue              @ 45
+    PQgetlength             @ 46
+    PQgetisnull             @ 47
+    PQclear                 @ 48
+    PQmakeEmptyPGresult     @ 49
+    PQprint                 @ 50
+    PQdisplayTuples         @ 51
+    PQprintTuples           @ 52
+    lo_open                 @ 53
+    lo_close                @ 54
+    lo_read                 @ 55
+    lo_write                @ 56
+    lo_lseek                @ 57
+    lo_creat                @ 58
+    lo_tell                 @ 59
+    lo_unlink               @ 60
+    lo_import               @ 61
+    lo_export               @ 62
+    pgresStatus             @ 63
+    PQmblen                 @ 64
+    PQresultErrorMessage    @ 65
+    PQresStatus             @ 66
+    termPQExpBuffer         @ 67
+    appendPQExpBufferChar   @ 68
+    initPQExpBuffer         @ 69
+    resetPQExpBuffer        @ 70
+    PQoidValue              @ 71
+    PQclientEncoding        @ 72
+    PQenv2encoding          @ 73
+    appendBinaryPQExpBuffer @ 74
+    appendPQExpBufferStr    @ 75
+    destroyPQExpBuffer      @ 76
+    createPQExpBuffer       @ 77
+    PQconninfoFree          @ 78
+    PQconnectPoll           @ 79
+    PQconnectStart          @ 80
+    PQflush                 @ 81
+    PQisnonblocking         @ 82
+    PQresetPoll             @ 83
+    PQresetStart            @ 84
+    PQsetClientEncoding     @ 85
+    PQsetnonblocking        @ 86
+    PQfreeNotify            @ 87
+    PQescapeString          @ 88
+    PQescapeBytea           @ 89
+    printfPQExpBuffer       @ 90
+    appendPQExpBuffer       @ 91
+    pg_encoding_to_char     @ 92
+    pg_utf_mblen            @ 93
+    PQunescapeBytea         @ 94
+    PQfreemem               @ 95
+    PQtransactionStatus     @ 96
+    PQparameterStatus       @ 97
+    PQprotocolVersion       @ 98
+    PQsetErrorVerbosity     @ 99
+    PQsetNoticeReceiver     @ 100
+    PQexecParams            @ 101
+    PQsendQueryParams       @ 102
+    PQputCopyData           @ 103
+    PQputCopyEnd            @ 104
+    PQgetCopyData           @ 105
+    PQresultErrorField      @ 106
+    PQftable                @ 107
+    PQftablecol             @ 108
+    PQfformat               @ 109
+    PQexecPrepared          @ 110
+    PQsendQueryPrepared     @ 111
+    PQdsplen                @ 112
+    PQserverVersion         @ 113
index 302d299266464f5c630b676294e58305e1576622..2a667c84492019c9ebf76c9262c9696e83550afe 100644 (file)
@@ -114,3 +114,4 @@ EXPORTS
     PQexecPrepared          @ 110
     PQsendQueryPrepared     @ 111
     PQdsplen                @ 112
+    PQserverVersion         @ 113