Skip to content

SQLite: sqlite3_enable_shared_cache() is deprecated #74831

Description

@vstinner
BPO 30646
Nosy @ronaldoussoren, @ned-deily, @erlend-aasland
Superseder
  • bpo-24464: "sqlite3_enable_shared_cache" deprecation warning when compiling with macOS system SQLite3
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-06-13.11:22:18.408>
    created_at = <Date 2017-06-13.08:34:13.720>
    labels = ['OS-mac', '3.7', 'library']
    title = 'SQLite: sqlite3_enable_shared_cache() is deprecated'
    updated_at = <Date 2020-09-06.10:15:30.728>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-09-06.10:15:30.728>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-06-13.11:22:18.408>
    closer = 'ned.deily'
    components = ['Library (Lib)', 'macOS']
    creation = <Date 2017-06-13.08:34:13.720>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30646
    keywords = []
    message_count = 5.0
    messages = ['295867', '295902', '295954', '376441', '376443']
    nosy_count = 3.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'erlendaasland']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '24464'
    type = None
    url = 'https://bugs.python.org/issue30646'
    versions = ['Python 3.7']

    Activity

    1. vstinner commented on Jun 13, 2017

      @vstinner
      MemberAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 13, 2017
    3. ned-deily commented on Jun 13, 2017

      @ned-deily
      Member

      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.

    4. ronaldoussoren commented on Jun 13, 2017

      @ronaldoussoren
      Contributor

      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.

    5. erlend-aasland commented on Sep 5, 2020

      @erlend-aasland
      Contributor

      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.

    6. erlend-aasland commented on Sep 5, 2020

      @erlend-aasland
      Contributor

      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.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifeOS-macstdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions