Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent needless allocation of sqlite3 aggregate function context #87424

Closed
erlend-aasland opened this issue Feb 18, 2021 · 3 comments
Closed
Labels
3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@erlend-aasland
Copy link
Contributor

BPO 43258
Nosy @berkerpeksag, @serhiy-storchaka, @erlend-aasland
PRs
  • bpo-43258: Prevent needless allocation of sqlite3 aggregate context for empty queries #24569
  • bpo-43258: Fix sqlite3 UDF callback scoping #24574
  • 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 2021-02-19.11:59:49.384>
    created_at = <Date 2021-02-18.22:21:00.100>
    labels = ['library', '3.10']
    title = 'Prevent needless allocation of sqlite3 aggregate function context'
    updated_at = <Date 2021-02-19.11:59:49.383>
    user = 'https://github.com/erlend-aasland'

    bugs.python.org fields:

    activity = <Date 2021-02-19.11:59:49.383>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-19.11:59:49.384>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2021-02-18.22:21:00.100>
    creator = 'erlendaasland'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43258
    keywords = ['patch']
    message_count = 3.0
    messages = ['387272', '387305', '387309']
    nosy_count = 3.0
    nosy_names = ['berker.peksag', 'serhiy.storchaka', 'erlendaasland']
    pr_nums = ['24569', '24574']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43258'
    versions = ['Python 3.10']

    @erlend-aasland
    Copy link
    Contributor Author

    If no rows match an aggregate query, _pysqlite_step_callback() is never called, and _pysqlite_final_callback() is called once. In order to prevent needless context allocation, we should pass 0 as the second argument to sqlite3_aggregate_context().

    Quoting from https://sqlite.org/c3ref/aggregate_context.html:

    Within the xFinal callback, it is customary to set N=0 in calls to sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur.

    @erlend-aasland erlend-aasland added 3.10 only security fixes stdlib Python modules in the Lib dir labels Feb 18, 2021
    @berkerpeksag
    Copy link
    Member

    New changeset 979b23c by Erlend Egeberg Aasland in branch 'master':
    bpo-43258: Don't allocate sqlite3 aggregate context for empty queries (GH-24569)
    979b23c

    @berkerpeksag
    Copy link
    Member

    New changeset 2bb0bf4 by Erlend Egeberg Aasland in branch 'master':
    bpo-43258: Make sqlite3 callback functions static (GH-24574)
    2bb0bf4

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants