Downgrade CREATE_INDEX_EXCLUSIVE to a warning
While it's always a dangerous *pattern* to create an index while a transaction is open & holds an exclusive lock, in practice it's not always a big deal (for example, indexing a table with very few rows can be fast). Accordingly, downgrade to a warning.
This commit is contained in:
1 parent
0c5519d9dc
commit
48fac8856b
4 files changed
+14
-6
No files matched your search
@@ -150,5 +150,6 @@ class PostgresqlBackwardCompatibilityDetectionTestCase(
|
||||
self._test_linter_finds_errors(app)
|
||||
|
||||
def test_create_index_exclusive(self):
|
||||
app = fixtures.CREATE_INDEX_EXCLUSIVE
|
||||
self._test_linter_finds_errors(app)
|
||||
linter = self._launch_linter(fixtures.CREATE_INDEX_EXCLUSIVE)
|
||||
self.assertFalse(linter.has_errors)
|
||||
self.assertTrue(linter.nb_warnings)
|
||||
@@ -36,9 +36,16 @@ class SqlAnalyserTestCase(unittest.TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
def assertWarningSql(self, sql):
|
||||
def assertWarningSql(self, sql, code=None):
|
||||
_, _, warnings = self.analyse_sql(sql)
|
||||
self.assertNotEqual(0, len(warnings), "Found no warnings in sql")
|
||||
if code:
|
||||
self.assertTrue(
|
||||
any(warning.code == code for warning in warnings),
|
||||
"Didn't find error code {} in returned errors ({})".format(
|
||||
code, [warning.code for warning in warnings]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class MySqlAnalyserTestCase(SqlAnalyserTestCase):
|
||||
@@ -322,7 +329,7 @@ class PostgresqlAnalyserTestCase(SqlAnalyserTestCase):
|
||||
'CREATE INDEX "user_email" ON "users" ("email");',
|
||||
"COMMIT;",
|
||||
]
|
||||
self.assertBackwardIncompatibleSql(sql, code="CREATE_INDEX_EXCLUSIVE")
|
||||
self.assertWarningSql(sql, code="CREATE_INDEX_EXCLUSIVE")
|
||||
|
||||
def test_create_index_exclusive_no_lock(self):
|
||||
sql = [
|
||||
|
||||
Reference in new issue
Block a user