diff --git a/ChangeLog b/ChangeLog index 42c4cad4..ff290335 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-04-19 Federico Di Gregorio + * 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. diff --git a/psycopg/connection.h b/psycopg/connection.h index 28fef570..701f46e0 100644 --- a/psycopg/connection.h +++ b/psycopg/connection.h @@ -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 */ diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index f4f72801..8b54badc 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -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); } @@ -249,6 +249,8 @@ conn_connect(connectionObject *self) self->protocol = 2; #endif Dprintf("conn_connect: using protocol %d", self->protocol); + + self->server_version = (int)PQserverVersion(pgconn); self->pgconn = pgconn; return 0; diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 364a13aa..1310fb55 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -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} };