This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SQLite: sqlite3_enable_shared_cache() is deprecated
Type: Stage: resolved
Components: Library (Lib), macOS Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: "sqlite3_enable_shared_cache" deprecation warning when compiling with macOS system SQLite3
View: 24464
Assigned To: Nosy List: erlendaasland, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2017-06-13 08:34 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg295867 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-13 08:34
Warning seen on the macOS Travis CI job:
"warning: 'sqlite3_enable_shared_cache' is deprecated: first deprecated in OS X 10.7"


https://travis-ci.org/python/cpython/jobs/242325662

clang -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I./Include -I. -I/usr/local/opt/openssl/include -I/usr/local/include -I/Users/travis/build/python/cpython/Include -I/Users/travis/build/python/cpython -c /Users/travis/build/python/cpython/Modules/_gdbmmodule.c -o build/temp./Users/travis/build/python/cpython/Modules/_sqlite/module.c:136:10: warning: 'sqlite3_enable_shared_cache' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]

    rc = sqlite3_enable_shared_cache(do_enable);

         ^

/usr/include/sqlite3.h:5170:31: note: 'sqlite3_enable_shared_cache' has been explicitly marked deprecated here

SQLITE_API int SQLITE_STDCALLmacosx-10.11-x86_64-3.6-pydebug/Users/travis/build/python/cpython/Modules/_gdbmmodule.o

 sqlite3_enable_shared_cache(int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_2_0, __IPHONE_5_0);

                              ^

1 warning generated.
msg295902 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-06-13 11:22
That's another reason why the python.org macOS installer build and, to the best of my knowledge, most third-party distributors of Python on macOS use their own builds of sqlite3 rather than the Apple-supplied system one.  I don't think there's anything new to be done here.
msg295954 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2017-06-13 19:24
See also <https://sqlite.org/c3ref/enable_shared_cache.html>. Apple basically disabled this function starting at macOS 10.7, that's why there's a warning.

It is possible to suppress the warning, but I don't think its worth the trouble.

BTW. The python documentation for this function claims this changes a thread-local setting, but the SQLite documentation says this is a process global setting in SQLite 3.5.0 and later (released in 2007).  It is possible to make behaviour match the python documentation by making _sqlite3.enable_shared_cache store a flag that's used in the call to sqlite3_open_v2. That would be a backward compatibility concern (there's bound to be users that rely on the current behavior), but would also avoid this warning.
msg376441 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2020-09-05 20:11
From the SQLite docs https://sqlite.org/c3ref/enable_shared_cache.html:

"Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 and will always return SQLITE_MISUSE. On those systems, shared cache mode should be enabled per-database connection via sqlite3_open_v2() with SQLITE_OPEN_SHAREDCACHE."

We should make sure sqlite3_open_v2() calls use SQLITE_OPEN_SHAREDCACHE if we are running on macOS. This should be a pretty straight-forward fix.
msg376443 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2020-09-05 20:37
A little bit too fast with my previous comment; just disregard that suggestion.

Maybe we should just disable the sqlite3.enable_shared_cache() method if we are running on macOS, since it will only result in a misuse error anyway.
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74831
2020-09-06 10:15:30vstinnersetnosy: - vstinner
2020-09-05 20:37:13erlendaaslandsetmessages: + msg376443
2020-09-05 20:11:34erlendaaslandsetnosy: + erlendaasland
messages: + msg376441
2019-09-29 06:41:17ned.deilysetsuperseder: "sqlite3_enable_shared_cache" deprecation warning when compiling with macOS system SQLite3
resolution: third party -> duplicate
2017-06-13 19:24:03ronaldoussorensetmessages: + msg295954
2017-06-13 11:22:18ned.deilysetstatus: open -> closed
resolution: third party
messages: + msg295902

stage: resolved
2017-06-13 08:34:13vstinnercreate