GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite dumpiter dumps invalid script when virtual tables are used · Issue #64662 · python/cpython

sqlite dumpiter dumps invalid script when virtual tables are used #64662

New issue
Copy link
New issue
Copy link
Closed
Closed
sqlite dumpiter dumps invalid script when virtual tables are used#64662
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-sqlite3triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

RonnyPfannschmidt
mannequin
opened on Jan 31, 2014
Issue body actions
BPO 20463
Nosy @bitdancer, @RonnyPfannschmidt, @palaviv, @tirkarthi
Files
  • 20463.patch
  • 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 = None
    created_at = <Date 2014-01-31.19:57:36.445>
    labels = ['extension-modules', 'type-bug']
    title = 'sqlite dumpiter dumps invalid script when virtual tables are used'
    updated_at = <Date 2018-09-23.16:16:06.541>
    user = 'https://github.com/RonnyPfannschmidt'

    bugs.python.org fields:

    activity = <Date 2018-09-23.16:16:06.541>
    actor = 'xtreak'
    assignee = 'ghaering'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2014-01-31.19:57:36.445>
    creator = 'Ronny.Pfannschmidt'
    dependencies = []
    files = ['45049']
    hgrepos = []
    issue_num = 20463
    keywords = ['patch']
    message_count = 3.0
    messages = ['209825', '248823', '278437']
    nosy_count = 5.0
    nosy_names = ['ghaering', 'r.david.murray', 'Ronny.Pfannschmidt', 'palaviv', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20463'
    versions = ['Python 2.7']

    Linked PRs

    • gh-64662: Add virtual table support to sqlite3.Connection.iterdump #108340
    • [3.12] gh-64662: Fix virtual table support in sqlite3.Connection.iterdump (#108340) #108563
    • [3.11] gh-64662: Fix virtual table support in sqlite3.Connection.iterdump (#108340) #108564
    • gh-64662: Fix NEWS entry and remove What's New entry #108565

    Activity

    Next
    1. RonnyPfannschmidt commented on Jan 31, 2014

      @RonnyPfannschmidt
      RonnyPfannschmidtmannequin
      on Jan 31, 2014
      MannequinAuthor
      More actions

      when using virtual tables, dumpiter generates a broken db script
      virtual table entries must be created as master table entries
      the sqlite tools dump does that correctly
      however pythons iterdump seems to do that rather different and wrong

      sqlite3 test.db "create virtual table test using fts4(example);"
      -------------------------------
      sqlite dump
      PRAGMA foreign_keys=OFF;
      BEGIN TRANSACTION;
      PRAGMA writable_schema=ON;
      INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)VALUES('table','test','test',0,'CREATE VIRTUAL TABLE test using fts4(example)');
      CREATE TABLE 'test_content'(docid INTEGER PRIMARY KEY, 'c0example');
      CREATE TABLE 'test_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
      CREATE TABLE 'test_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
      CREATE TABLE 'test_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
      CREATE TABLE 'test_stat'(id INTEGER PRIMARY KEY, value BLOB);
      PRAGMA writable_schema=OFF;
      COMMIT;
      ------------------------------
      python iterdump "import sqlite3;
      c=sqlite3.connect("test.db");
      print("\n".join(c.iterdump()))"
      BEGIN TRANSACTION;
      CREATE VIRTUAL TABLE test using fts4(example);
      CREATE TABLE 'test_content'(docid INTEGER PRIMARY KEY, 'c0example');
      CREATE TABLE 'test_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
      CREATE TABLE 'test_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
      CREATE TABLE 'test_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
      CREATE TABLE 'test_stat'(id INTEGER PRIMARY KEY, value BLOB);
      COMMIT;

    2. RonnyPfannschmidt
      added
      extension-modulesC modules in the Modules dirC modules in the Modules dir
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Jan 31, 2014
    3. ghaering
      self-assigned this
      on Jan 11, 2015
    4. ghaering commented on Aug 19, 2015

      @ghaering
      ghaeringmannequin
      on Aug 19, 2015
      Mannequin
      More actions

      apsw contains code that handles the issues with dumping SQLite databases very well. I plan to integrate this code into pysqlite. We can then later port the fix to the sqlite3 module.

      See ghaering/pysqlite#10 for the tasks and
      https://github.com/rogerbinns/apsw/blob/master/tools/shell.py#L1012 for the apsw code.

    5. palaviv commented on Oct 10, 2016

      @palaviv
      palavivmannequin
      on Oct 10, 2016
      Mannequin
      More actions

      Attached is patch with a fix for this issue. This is not as comprehensive as the solution in apsw but I think this should cover most of the cases. The result for Ronny dump after this fix is:

      BEGIN TRANSACTION;
      PRAGMA writable_schema=ON;
      INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)VALUES('table','test','test',0,'CREATE VIRTUAL TABLE test using fts4(example)');
      CREATE TABLE 'test_content'(docid INTEGER PRIMARY KEY, 'c0example');
      CREATE TABLE 'test_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
      CREATE TABLE 'test_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
      CREATE TABLE 'test_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
      CREATE TABLE 'test_stat'(id INTEGER PRIMARY KEY, value BLOB);
      PRAGMA writable_schema=OFF;
      COMMIT;

    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    7. erlend-aasland
      added
      topic-sqlite3
      on May 16, 2022
    8. erlend-aasland
      added this to sqlite3 issueson May 21, 2022
    9. erlend-aasland
      moved this to TODO in sqlite3 issueson May 21, 2022
    10. erlend-aasland
      moved this from TODO: Docs to TODO: Bugs in sqlite3 issueson May 21, 2022
    11. erlend-aasland
      moved this from TODO: Bugs to In Progress in sqlite3 issueson Jun 14, 2022
    12. erlend-aasland
      moved this from In Progress to TODO: Bugs in sqlite3 issueson Jun 14, 2022
    13. erlend-aasland
      added
      triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
      on Jul 25, 2022
    14. erlend-aasland commented on Aug 22, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 22, 2023
      Contributor
      More actions

      My plan for iterdump is to align it with the implementation in the SQLite shell, but I haven't gotten around to it yet. I think @palaviv's patch is a step in the right direction, and I don't think we should block that patch, just because iterdump also has other problems.

    15. 10 remaining items

    16. RonnyPfannschmidt commented on Aug 28, 2023

      @RonnyPfannschmidt
      RonnyPfannschmidt
      on Aug 28, 2023
      Author
      More actions

      I consider it a bug as the output wasn't valid,it should error if it cant make it,

      Reacted by Erlend E. Aasland
    17. erlend-aasland commented on Aug 28, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 28, 2023
      Contributor
      More actions

      I consider it a bug as the output wasn't valid,it should error if it cant make it,

      Hm, yeah, that is a valid point that weighs heavier than the comment.

    18. erlend-aasland
      reopened this on Aug 28, 2023
    19. erlend-aasland commented on Aug 28, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 28, 2023
      Contributor
      More actions

      OTOH, this changes the behaviour, which is an argument not to backport it.

    20. RonnyPfannschmidt commented on Aug 28, 2023

      @RonnyPfannschmidt
      RonnyPfannschmidt
      on Aug 28, 2023
      Author
      More actions

      @erlend-aasland personally i prefer people see a error when they dump rather than when they later load that dump

      this bug in the worst case makes a broken backup silently appear working - not failing early causes more damage

      silent breakage/invalid datagen is imho worse than adding a error where else people have hidden broken data until they test again

      Reacted by Erlend E. Aasland
    21. RonnyPfannschmidt commented on Aug 28, 2023

      @RonnyPfannschmidt
      RonnyPfannschmidt
      on Aug 28, 2023
      Author
      More actions

      ftr - imho its fine to have a backport that just finally raises a NotImplementedError rather than silently dumping broken data

    22. erlend-aasland commented on Aug 28, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 28, 2023
      Contributor
      More actions

      ftr - imho its fine to have a backport that just finally raises a NotImplementedError rather than silently dumping broken data

      I'd rather backport the fix. Anyway, you've convinced me; I agree that this is more a bugfix than a new feature. I'll prepare backports through 3.11.

    23. erlend-aasland
      added 2 commits that reference this issue on Aug 28, 2023

      [3.12] pythongh-64662: Add virtual table support to sqlite3.Connectio…

      d5ad25e

      [3.11] pythongh-64662: Add virtual table support to sqlite3.Connectio…

      cd0cd13
    24. erlend-aasland commented on Aug 28, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 28, 2023
      Contributor
      More actions

      Thanks for you input, @RonnyPfannschmidt.

    25. erlend-aasland
      added 2 commits that reference this issue on Aug 28, 2023

      gh-64662: Fix NEWS entry and remove What's New entry (#108565)

      8db451c

      [3.11] gh-64662: Fix virtual table support in sqlite3.Connection.iter…

      33eee43
    26. erlend-aasland commented on Aug 28, 2023

      @erlend-aasland
      erlend-aasland
      on Aug 28, 2023
      Contributor
      More actions

      Backports are queued; marking this as resolved.

      Reacted by Ronny Pfannschmidt
    27. erlend-aasland
      closed this as completedon Aug 28, 2023
    28. Yhg1s
      added a commit that references this issue on Aug 28, 2023

      [3.12] gh-64662: Fix virtual table support in sqlite3.Connection.iter…

      b451e90
    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.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-sqlite3triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      • sqlite3 issues
        Status
        Done
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.