mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-105875: Require SQLite 3.15.2 or newer (#105876)
SQLite 3.15.2 was released 2016-11-28.
This commit is contained in:
parent
bc07c8f096
commit
6849acb3fe
13 changed files with 61 additions and 202 deletions
|
|
@ -50,8 +50,6 @@ class BackupTests(unittest.TestCase):
|
|||
bck.executemany('INSERT INTO bar (key) VALUES (?)', [(3,), (4,)])
|
||||
with self.assertRaises(sqlite.OperationalError) as cm:
|
||||
self.cx.backup(bck)
|
||||
if sqlite.sqlite_version_info < (3, 8, 8):
|
||||
self.assertEqual(str(cm.exception), 'target is in transaction')
|
||||
|
||||
def test_keyword_only_args(self):
|
||||
with self.assertRaises(TypeError):
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_INTERNAL",
|
||||
"SQLITE_INTERRUPT",
|
||||
"SQLITE_IOERR",
|
||||
"SQLITE_LIMIT_WORKER_THREADS",
|
||||
"SQLITE_LOCKED",
|
||||
"SQLITE_MISMATCH",
|
||||
"SQLITE_MISUSE",
|
||||
|
|
@ -172,6 +173,7 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_NOMEM",
|
||||
"SQLITE_NOTADB",
|
||||
"SQLITE_NOTFOUND",
|
||||
"SQLITE_NOTICE",
|
||||
"SQLITE_OK",
|
||||
"SQLITE_PERM",
|
||||
"SQLITE_PRAGMA",
|
||||
|
|
@ -179,6 +181,7 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_RANGE",
|
||||
"SQLITE_READ",
|
||||
"SQLITE_READONLY",
|
||||
"SQLITE_RECURSIVE",
|
||||
"SQLITE_REINDEX",
|
||||
"SQLITE_ROW",
|
||||
"SQLITE_SAVEPOINT",
|
||||
|
|
@ -187,6 +190,7 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_TOOBIG",
|
||||
"SQLITE_TRANSACTION",
|
||||
"SQLITE_UPDATE",
|
||||
"SQLITE_WARNING",
|
||||
# Run-time limit categories
|
||||
"SQLITE_LIMIT_LENGTH",
|
||||
"SQLITE_LIMIT_SQL_LENGTH",
|
||||
|
|
@ -200,32 +204,43 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_LIMIT_VARIABLE_NUMBER",
|
||||
"SQLITE_LIMIT_TRIGGER_DEPTH",
|
||||
]
|
||||
if sqlite.sqlite_version_info >= (3, 7, 17):
|
||||
consts += ["SQLITE_NOTICE", "SQLITE_WARNING"]
|
||||
if sqlite.sqlite_version_info >= (3, 8, 3):
|
||||
consts.append("SQLITE_RECURSIVE")
|
||||
if sqlite.sqlite_version_info >= (3, 8, 7):
|
||||
consts.append("SQLITE_LIMIT_WORKER_THREADS")
|
||||
consts += ["PARSE_DECLTYPES", "PARSE_COLNAMES"]
|
||||
# Extended result codes
|
||||
consts += [
|
||||
"SQLITE_ABORT_ROLLBACK",
|
||||
"SQLITE_AUTH_USER",
|
||||
"SQLITE_BUSY_RECOVERY",
|
||||
"SQLITE_BUSY_SNAPSHOT",
|
||||
"SQLITE_CANTOPEN_CONVPATH",
|
||||
"SQLITE_CANTOPEN_FULLPATH",
|
||||
"SQLITE_CANTOPEN_ISDIR",
|
||||
"SQLITE_CANTOPEN_NOTEMPDIR",
|
||||
"SQLITE_CONSTRAINT_CHECK",
|
||||
"SQLITE_CONSTRAINT_COMMITHOOK",
|
||||
"SQLITE_CONSTRAINT_FOREIGNKEY",
|
||||
"SQLITE_CONSTRAINT_FUNCTION",
|
||||
"SQLITE_CONSTRAINT_NOTNULL",
|
||||
"SQLITE_CONSTRAINT_PRIMARYKEY",
|
||||
"SQLITE_CONSTRAINT_ROWID",
|
||||
"SQLITE_CONSTRAINT_TRIGGER",
|
||||
"SQLITE_CONSTRAINT_UNIQUE",
|
||||
"SQLITE_CONSTRAINT_VTAB",
|
||||
"SQLITE_CORRUPT_VTAB",
|
||||
"SQLITE_IOERR_ACCESS",
|
||||
"SQLITE_IOERR_AUTH",
|
||||
"SQLITE_IOERR_BLOCKED",
|
||||
"SQLITE_IOERR_CHECKRESERVEDLOCK",
|
||||
"SQLITE_IOERR_CLOSE",
|
||||
"SQLITE_IOERR_CONVPATH",
|
||||
"SQLITE_IOERR_DELETE",
|
||||
"SQLITE_IOERR_DELETE_NOENT",
|
||||
"SQLITE_IOERR_DIR_CLOSE",
|
||||
"SQLITE_IOERR_DIR_FSYNC",
|
||||
"SQLITE_IOERR_FSTAT",
|
||||
"SQLITE_IOERR_FSYNC",
|
||||
"SQLITE_IOERR_GETTEMPPATH",
|
||||
"SQLITE_IOERR_LOCK",
|
||||
"SQLITE_IOERR_MMAP",
|
||||
"SQLITE_IOERR_NOMEM",
|
||||
"SQLITE_IOERR_RDLOCK",
|
||||
"SQLITE_IOERR_READ",
|
||||
|
|
@ -237,50 +252,18 @@ class ModuleTests(unittest.TestCase):
|
|||
"SQLITE_IOERR_SHORT_READ",
|
||||
"SQLITE_IOERR_TRUNCATE",
|
||||
"SQLITE_IOERR_UNLOCK",
|
||||
"SQLITE_IOERR_VNODE",
|
||||
"SQLITE_IOERR_WRITE",
|
||||
"SQLITE_LOCKED_SHAREDCACHE",
|
||||
"SQLITE_NOTICE_RECOVER_ROLLBACK",
|
||||
"SQLITE_NOTICE_RECOVER_WAL",
|
||||
"SQLITE_OK_LOAD_PERMANENTLY",
|
||||
"SQLITE_READONLY_CANTLOCK",
|
||||
"SQLITE_READONLY_DBMOVED",
|
||||
"SQLITE_READONLY_RECOVERY",
|
||||
"SQLITE_READONLY_ROLLBACK",
|
||||
"SQLITE_WARNING_AUTOINDEX",
|
||||
]
|
||||
if sqlite.sqlite_version_info >= (3, 7, 16):
|
||||
consts += [
|
||||
"SQLITE_CONSTRAINT_CHECK",
|
||||
"SQLITE_CONSTRAINT_COMMITHOOK",
|
||||
"SQLITE_CONSTRAINT_FOREIGNKEY",
|
||||
"SQLITE_CONSTRAINT_FUNCTION",
|
||||
"SQLITE_CONSTRAINT_NOTNULL",
|
||||
"SQLITE_CONSTRAINT_PRIMARYKEY",
|
||||
"SQLITE_CONSTRAINT_TRIGGER",
|
||||
"SQLITE_CONSTRAINT_UNIQUE",
|
||||
"SQLITE_CONSTRAINT_VTAB",
|
||||
"SQLITE_READONLY_ROLLBACK",
|
||||
]
|
||||
if sqlite.sqlite_version_info >= (3, 7, 17):
|
||||
consts += [
|
||||
"SQLITE_IOERR_MMAP",
|
||||
"SQLITE_NOTICE_RECOVER_ROLLBACK",
|
||||
"SQLITE_NOTICE_RECOVER_WAL",
|
||||
]
|
||||
if sqlite.sqlite_version_info >= (3, 8, 0):
|
||||
consts += [
|
||||
"SQLITE_BUSY_SNAPSHOT",
|
||||
"SQLITE_IOERR_GETTEMPPATH",
|
||||
"SQLITE_WARNING_AUTOINDEX",
|
||||
]
|
||||
if sqlite.sqlite_version_info >= (3, 8, 1):
|
||||
consts += ["SQLITE_CANTOPEN_CONVPATH", "SQLITE_IOERR_CONVPATH"]
|
||||
if sqlite.sqlite_version_info >= (3, 8, 2):
|
||||
consts.append("SQLITE_CONSTRAINT_ROWID")
|
||||
if sqlite.sqlite_version_info >= (3, 8, 3):
|
||||
consts.append("SQLITE_READONLY_DBMOVED")
|
||||
if sqlite.sqlite_version_info >= (3, 8, 7):
|
||||
consts.append("SQLITE_AUTH_USER")
|
||||
if sqlite.sqlite_version_info >= (3, 9, 0):
|
||||
consts.append("SQLITE_IOERR_VNODE")
|
||||
if sqlite.sqlite_version_info >= (3, 10, 0):
|
||||
consts.append("SQLITE_IOERR_AUTH")
|
||||
if sqlite.sqlite_version_info >= (3, 14, 1):
|
||||
consts.append("SQLITE_OK_LOAD_PERMANENTLY")
|
||||
if sqlite.sqlite_version_info >= (3, 21, 0):
|
||||
consts += [
|
||||
"SQLITE_IOERR_BEGIN_ATOMIC",
|
||||
|
|
@ -330,8 +313,6 @@ class ModuleTests(unittest.TestCase):
|
|||
self.assertEqual(e.sqlite_errorcode, err_code)
|
||||
self.assertTrue(e.sqlite_errorname.startswith("SQLITE_CANTOPEN"))
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info <= (3, 7, 16),
|
||||
"Requires SQLite 3.7.16 or newer")
|
||||
def test_extended_error_code_on_exception(self):
|
||||
with memory_database() as con:
|
||||
with con:
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ class TraceCallbackTests(unittest.TestCase):
|
|||
)
|
||||
def test_trace_too_much_expanded_sql(self):
|
||||
# If the expanded string is too large, we'll fall back to the
|
||||
# unexpanded SQL statement (for SQLite 3.14.0 and newer).
|
||||
# unexpanded SQL statement.
|
||||
# The resulting string length is limited by the runtime limit
|
||||
# SQLITE_LIMIT_LENGTH.
|
||||
template = "select 1 as a where a="
|
||||
|
|
@ -334,8 +334,6 @@ class TraceCallbackTests(unittest.TestCase):
|
|||
|
||||
unexpanded_query = template + "?"
|
||||
expected = [unexpanded_query]
|
||||
if sqlite.sqlite_version_info < (3, 14, 0):
|
||||
expected = []
|
||||
with self.check_stmt_trace(cx, expected):
|
||||
cx.execute(unexpanded_query, (bad_param,))
|
||||
|
||||
|
|
|
|||
|
|
@ -371,7 +371,6 @@ class ColNamesTests(unittest.TestCase):
|
|||
self.assertIsNone(self.cur.description)
|
||||
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "CTEs not supported")
|
||||
class CommonTableExpressionTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
|
|
@ -381,38 +381,22 @@ class FunctionTests(unittest.TestCase):
|
|||
# Regarding deterministic functions:
|
||||
#
|
||||
# Between 3.8.3 and 3.15.0, deterministic functions were only used to
|
||||
# optimize inner loops, so for those versions we can only test if the
|
||||
# sqlite machinery has factored out a call or not. From 3.15.0 and onward,
|
||||
# deterministic functions were permitted in WHERE clauses of partial
|
||||
# indices, which allows testing based on syntax, iso. the query optimizer.
|
||||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
|
||||
# optimize inner loops. From 3.15.0 and onward, deterministic functions
|
||||
# were permitted in WHERE clauses of partial indices, which allows testing
|
||||
# based on syntax, iso. the query optimizer.
|
||||
def test_func_non_deterministic(self):
|
||||
mock = Mock(return_value=None)
|
||||
self.con.create_function("nondeterministic", 0, mock, deterministic=False)
|
||||
if sqlite.sqlite_version_info < (3, 15, 0):
|
||||
self.con.execute("select nondeterministic() = nondeterministic()")
|
||||
self.assertEqual(mock.call_count, 2)
|
||||
else:
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
self.con.execute("create index t on test(t) where nondeterministic() is not null")
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
self.con.execute("create index t on test(t) where nondeterministic() is not null")
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
|
||||
def test_func_deterministic(self):
|
||||
mock = Mock(return_value=None)
|
||||
self.con.create_function("deterministic", 0, mock, deterministic=True)
|
||||
if sqlite.sqlite_version_info < (3, 15, 0):
|
||||
self.con.execute("select deterministic() = deterministic()")
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
else:
|
||||
try:
|
||||
self.con.execute("create index t on test(t) where deterministic() is not null")
|
||||
except sqlite.OperationalError:
|
||||
self.fail("Unexpected failure while creating partial index")
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info >= (3, 8, 3), "SQLite < 3.8.3 needed")
|
||||
def test_func_deterministic_not_supported(self):
|
||||
with self.assertRaises(sqlite.NotSupportedError):
|
||||
self.con.create_function("deterministic", 0, int, deterministic=True)
|
||||
try:
|
||||
self.con.execute("create index t on test(t) where deterministic() is not null")
|
||||
except sqlite.OperationalError:
|
||||
self.fail("Unexpected failure while creating partial index")
|
||||
|
||||
def test_func_deterministic_keyword_only(self):
|
||||
with self.assertRaises(TypeError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue