aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/sqlite3/dump.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2023-10-03 23:32:21 +0300
committershadchin <shadchin@yandex-team.com>2023-10-03 23:48:51 +0300
commit01ffd024041ac933854c367fb8d1b5682d19883f (patch)
treeb70aa497ba132a133ccece49f7763427dcd0743f /contrib/tools/python3/src/Lib/sqlite3/dump.py
parenta33fdb9a34581fd124e92535153b1f1fdeca6aaf (diff)
downloadydb-01ffd024041ac933854c367fb8d1b5682d19883f.tar.gz
Update Python 3 to 3.11.6
Diffstat (limited to 'contrib/tools/python3/src/Lib/sqlite3/dump.py')
-rw-r--r--contrib/tools/python3/src/Lib/sqlite3/dump.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/contrib/tools/python3/src/Lib/sqlite3/dump.py b/contrib/tools/python3/src/Lib/sqlite3/dump.py
index 07b9da10b9..1cf8759f89 100644
--- a/contrib/tools/python3/src/Lib/sqlite3/dump.py
+++ b/contrib/tools/python3/src/Lib/sqlite3/dump.py
@@ -16,6 +16,7 @@ def _iterdump(connection):
directly but instead called from the Connection method, iterdump().
"""
+ writeable_schema = False
cu = connection.cursor()
yield('BEGIN TRANSACTION;')
@@ -42,13 +43,15 @@ def _iterdump(connection):
yield('ANALYZE "sqlite_master";')
elif table_name.startswith('sqlite_'):
continue
- # NOTE: Virtual table support not implemented
- #elif sql.startswith('CREATE VIRTUAL TABLE'):
- # qtable = table_name.replace("'", "''")
- # yield("INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"\
- # "VALUES('table','{0}','{0}',0,'{1}');".format(
- # qtable,
- # sql.replace("''")))
+ elif sql.startswith('CREATE VIRTUAL TABLE'):
+ if not writeable_schema:
+ writeable_schema = True
+ yield('PRAGMA writable_schema=ON;')
+ yield("INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
+ "VALUES('table','{0}','{0}',0,'{1}');".format(
+ table_name.replace("'", "''"),
+ sql.replace("'", "''"),
+ ))
else:
yield('{0};'.format(sql))
@@ -74,6 +77,9 @@ def _iterdump(connection):
for name, type, sql in schema_res.fetchall():
yield('{0};'.format(sql))
+ if writeable_schema:
+ yield('PRAGMA writable_schema=OFF;')
+
# gh-79009: Yield statements concerning the sqlite_sequence table at the
# end of the transaction.
for row in sqlite_sequence: