Skip to content

sqlite3.Connection.iterdump() produces an unrestorable dump for a populated virtual table #153729

Description

@tonghuaroot

Bug description

sqlite3.Connection.iterdump() emits INSERT statements for a virtual table's
own rows in addition to its schema. Those rows live in the shadow tables (which
are dumped separately), and on restore they run before the virtual table module
is instantiated, so restoring the dump fails:

import sqlite3
src = sqlite3.connect(":memory:")
src.execute("CREATE VIRTUAL TABLE t USING fts4(x)")
src.execute("INSERT INTO t(x) VALUES ('hello world')")
script = "".join(src.iterdump())
dst = sqlite3.connect(":memory:")
dst.executescript(script)
# sqlite3.OperationalError: no such table: t

The SQLite shell's .dump does not emit content rows for virtual tables.

CPython versions tested on

3.14, 3.15, 3.16

Operating systems tested on

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions