diff --git a/ChangeLog b/ChangeLog index 7be819a7..f3a1d875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-09-01 Federico Di Gregorio + * psycopg/connection_type.c: added .status attribute to expose + the internal status. + * psycopg/pqpath.c: applied patch from intgr (#117) to fix segfault on null queries. diff --git a/lib/extensions.py b/lib/extensions.py index b4ade2ca..9233d1d7 100644 --- a/lib/extensions.py +++ b/lib/extensions.py @@ -43,14 +43,24 @@ from _psycopg import string_types, binary_types, new_type, register_type from _psycopg import ISQLQuote """Isolation level values.""" -ISOLATION_LEVEL_AUTOCOMMIT = 0 +ISOLATION_LEVEL_AUTOCOMMIT = 0 ISOLATION_LEVEL_READ_COMMITTED = 1 -ISOLATION_LEVEL_SERIALIZABLE = 2 +ISOLATION_LEVEL_SERIALIZABLE = 2 # PostgreSQL maps the the other standard values to already defined levels ISOLATION_LEVEL_REPEATABLE_READ = ISOLATION_LEVEL_SERIALIZABLE ISOLATION_LEVEL_READ_UNCOMMITTED = ISOLATION_LEVEL_READ_COMMITTED +"""Transaction status values.""" +STATUS_SETUP = 0 +STATUS_READY = 1 +STATUS_BEGIN = 2 +STATUS_SYNC = 3 +STATUS_ASYNC = 4 + +# This is a usefull mnemonic to check if the connection is in a transaction +STATUS_IN_TRANSACTION = STATUS_BEGIN + def register_adapter(typ, callable): """Register 'callable' as an ISQLQuote adapter for type 'typ'.""" diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 195e6ec7..f8cbd806 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -260,6 +260,9 @@ static struct PyMemberDef connectionObject_members[] = { {"notifies", T_OBJECT, offsetof(connectionObject, notifies), RO}, {"dsn", T_STRING, offsetof(connectionObject, dsn), RO, "The current connection string."}, + {"status", T_LONG, + offsetof(connectionObject, status), RO, + "The current transaction status."}, #endif {NULL} };