[F repo sqlite schema changes] don't rollback on potentially expected schema changes failure
--- a/server/schemahooks.py Sat Aug 01 01:13:39 2009 +0200
+++ b/server/schemahooks.py Sat Aug 01 01:16:19 2009 +0200
@@ -51,7 +51,7 @@
column = SQL_PREFIX + rtype
try:
session.system_sql(str('ALTER TABLE %s ADD COLUMN %s integer'
- % (table, column)))
+ % (table, column)), rollback_on_failure=False)
session.info('added column %s to table %s', column, table)
except:
# silent exception here, if this error has not been raised because the
@@ -128,7 +128,7 @@
session.pool.source('system').drop_index(session, table, column)
try:
session.system_sql('ALTER TABLE %s DROP COLUMN %s'
- % (table, column))
+ % (table, column), rollback_on_failure=False)
self.info('dropped column %s from table %s', column, table)
except Exception, ex:
# not supported by sqlite for instance
@@ -410,7 +410,8 @@
column = SQL_PREFIX + rtype
try:
session.system_sql(str('ALTER TABLE %s ADD COLUMN %s %s'
- % (table, column, attrtype)))
+ % (table, column, attrtype)),
+ rollback_on_failure=False)
self.info('added column %s to table %s', table, column)
except Exception, ex:
# the column probably already exists. this occurs when
@@ -722,7 +723,7 @@
creating=False)
sql = adbh.sql_change_col_type(table, column, coltype, card != '1')
try:
- session.system_sql(sql)
+ session.system_sql(sql, rollback_on_failure=False)
self.info('altered column %s of table %s: now VARCHAR(%s)',
column, table, self._cstr.max)
except Exception, ex:
@@ -761,7 +762,8 @@
if cstrtype == 'SizeConstraint':
try:
self.session.system_sql('ALTER TABLE %s ALTER COLUMN %s TYPE TEXT'
- % (table, column))
+ % (table, column),
+ rollback_on_failure=False)
self.info('altered column %s of table %s: now TEXT',
column, table)
except Exception, ex:
--- a/server/sources/native.py Sat Aug 01 01:13:39 2009 +0200
+++ b/server/sources/native.py Sat Aug 01 01:16:19 2009 +0200
@@ -432,7 +432,7 @@
sql = self.sqlgen.delete('%s_relation' % rtype, attrs)
self.doexec(session, sql, attrs)
- def doexec(self, session, query, args=None):
+ def doexec(self, session, query, args=None, rollback=True):
"""Execute a query.
it's a function just so that it shows up in profiling
"""
@@ -445,11 +445,12 @@
except Exception, ex:
self.critical("sql: %r\n args: %s\ndbms message: %r",
query, args, ex.args[0])
- try:
- session.pool.connection(self.uri).rollback()
- self.critical('transaction has been rollbacked')
- except:
- pass
+ if rollback:
+ try:
+ session.pool.connection(self.uri).rollback()
+ self.critical('transaction has been rollbacked')
+ except:
+ pass
raise
return cursor