Exposed protocol_version and server_version

This commit is contained in:
Federico Di Gregorio 2009-04-19 16:36:10 +02:00
parent e3a5ae8e20
commit 39d6d8ad11
4 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2009-04-19 Federico Di Gregorio <fog@initd.org>
* psycopg/connection.*: exposed protocol_version and
server_version attributes on the connection object.
* lib/extras.py: patch from Marko Kreen to implement missing dict
methods in DictRow.

View File

@ -63,6 +63,7 @@ typedef struct {
long int mark; /* number of commits/rollbacks done so far */
int status; /* status of the connection */
int protocol; /* protocol version */
int server_version; /* server version */
PGconn *pgconn; /* the postgresql connection */

View File

@ -98,7 +98,7 @@ conn_notice_clean(connectionObject *self)
while (notice != NULL) {
tmp = notice;
notice = notice->next;
free(tmp->message);
free((void*)tmp->message);
free(tmp);
}
@ -250,6 +250,8 @@ conn_connect(connectionObject *self)
#endif
Dprintf("conn_connect: using protocol %d", self->protocol);
self->server_version = (int)PQserverVersion(pgconn);
self->pgconn = pgconn;
return 0;
}

View File

@ -383,6 +383,12 @@ static struct PyMemberDef connectionObject_members[] = {
"A set of typecasters to convert textual values."},
{"binary_types", T_OBJECT, offsetof(connectionObject, binary_types), RO,
"A set of typecasters to convert binary values."},
{"protocol_version", T_INT,
offsetof(connectionObject, protocol), RO,
"Protocol version (2 or 3) used for this connection."},
{"server_version", T_INT,
offsetof(connectionObject, server_version), RO,
"Server version."},
#endif
{NULL}
};