From 9a36357c52c9cfded5076513302db9eef4d9e37f Mon Sep 17 00:00:00 2001 From: Karim Kanso Date: Wed, 20 May 2020 14:35:20 +0100 Subject: [PATCH] SQLite table dumping compatibility improvements. (#4205) * Fix sqlite regex for create table to support implicit column types * Fix sqlite when dumping large tables --- lib/core/common.py | 4 ++-- plugins/generic/entries.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index f178a7342..4fd19c43b 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -3287,9 +3287,9 @@ def parseSqliteTableSchema(value): table = {} columns = {} - for match in re.finditer(r"(\w+)[\"'`]?\s+(INT|INTEGER|TINYINT|SMALLINT|MEDIUMINT|BIGINT|UNSIGNED BIG INT|INT2|INT8|INTEGER|CHARACTER|VARCHAR|VARYING CHARACTER|NCHAR|NATIVE CHARACTER|NVARCHAR|TEXT|CLOB|LONGTEXT|BLOB|NONE|REAL|DOUBLE|DOUBLE PRECISION|FLOAT|REAL|NUMERIC|DECIMAL|BOOLEAN|DATE|DATETIME|NUMERIC)\b", decodeStringEscape(value), re.I): + for match in re.finditer(r"[(,]\s*[\"'`]?(\w+)[\"'`]?(?:\s+(INT|INTEGER|TINYINT|SMALLINT|MEDIUMINT|BIGINT|UNSIGNED BIG INT|INT2|INT8|INTEGER|CHARACTER|VARCHAR|VARYING CHARACTER|NCHAR|NATIVE CHARACTER|NVARCHAR|TEXT|CLOB|LONGTEXT|BLOB|NONE|REAL|DOUBLE|DOUBLE PRECISION|FLOAT|REAL|NUMERIC|DECIMAL|BOOLEAN|DATE|DATETIME|NUMERIC)\b)?", decodeStringEscape(value), re.I): retVal = True - columns[match.group(1)] = match.group(2) + columns[match.group(1)] = match.group(2) or "TEXT" table[safeSQLIdentificatorNaming(conf.tbl, True)] = columns kb.data.cachedColumns[conf.db] = table diff --git a/plugins/generic/entries.py b/plugins/generic/entries.py index 204917925..395e50d13 100644 --- a/plugins/generic/entries.py +++ b/plugins/generic/entries.py @@ -131,6 +131,8 @@ class Entries(object): try: if Backend.isDbms(DBMS.INFORMIX): kb.dumpTable = "%s:%s" % (conf.db, tbl) + elif Backend.isDbms(DBMS.SQLITE): + kb.dumpTable = tbl else: kb.dumpTable = "%s.%s" % (conf.db, tbl)