connection-holding-fix.patch

patch to fix connection holding issue - Ivan Mincik, 2014-05-02 05:37 AM

Download (1.65 KB)

View differences:

db_plugins/postgis/connector.py
53 53

  
54 54
		try:
55 55
			self.connection = psycopg2.connect( self._connectionInfo().encode('utf-8') )
56
			self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
56 57
		except self.connection_error_types(), e:
57 58
			raise ConnectionError(e)
58 59

  
......
751 752

  
752 753
	def runVacuumAnalyze(self, table):
753 754
		""" 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)
756 755
		sql = u"VACUUM ANALYZE %s" % self.quoteId(table)
757 756
		c = self._execute(None, sql)
758 757
		self._commit()
759
		self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED)
760

  
761 758

  
762 759
	def addTableColumn(self, table, field_def):
763 760
		""" add a column to table """
db_plugins/postgis/data_model.py
43 43
		fields_txt = u", ".join(self.fields)
44 44
		table_txt = self.db.quoteId( (self.table.schemaName(), self.table.name) )
45 45

  
46
		# create named cursor and run query
47
		self.cursor = self.db._get_cursor(self.table.name)
46
		self.cursor = self.db._get_cursor()
48 47
		sql = u"SELECT %s FROM %s" % (fields_txt, table_txt)
49 48
		self.db._execute(self.cursor, sql)
50 49