Skip to content

Commit d522059

Browse files
committed
Merge pull request #1348 from imincik/db_manager_connection_holding
db manager: fix connection holding - idle in transaction (QGIS bug #7162...
2 parents aa70851 + 0d3e5e4 commit d522059

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

python/plugins/db_manager/db_plugins/postgis/connector.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(self, uri):
5353

5454
try:
5555
self.connection = psycopg2.connect( self._connectionInfo().encode('utf-8') )
56+
self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
5657
except self.connection_error_types(), e:
5758
raise ConnectionError(e)
5859

@@ -751,13 +752,9 @@ def runVacuum(self):
751752

752753
def runVacuumAnalyze(self, table):
753754
""" run vacuum analyze on a table """
754-
# vacuum analyze must be run outside transaction block - we have to change isolation level
755-
self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
756755
sql = u"VACUUM ANALYZE %s" % self.quoteId(table)
757756
c = self._execute(None, sql)
758757
self._commit()
759-
self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED)
760-
761758

762759
def addTableColumn(self, table, field_def):
763760
""" add a column to table """

python/plugins/db_manager/db_plugins/postgis/data_model.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def _createCursor(self):
4343
fields_txt = u", ".join(self.fields)
4444
table_txt = self.db.quoteId( (self.table.schemaName(), self.table.name) )
4545

46-
# create named cursor and run query
47-
self.cursor = self.db._get_cursor(self.table.name)
46+
self.cursor = self.db._get_cursor()
4847
sql = u"SELECT %s FROM %s" % (fields_txt, table_txt)
4948
self.db._execute(self.cursor, sql)
5049

0 commit comments

Comments
 (0)