Minor bug fix for --search -C so that now if not columns are found (with criteria specified, e.g. -D testdb -T testtable), it won't ask to dump for the entries

This commit is contained in:
Bernardo Damele 2012-03-08 16:57:53 +00:00
parent e678219a8c
commit 7330dff255

View File

@ -1093,7 +1093,7 @@ class Enumeration:
condQuery = " AND (%s)" % " OR ".join(condQueryStr % (condition, unsafeSQLIdentificatorNaming(col)) for col in sorted(colList)) condQuery = " AND (%s)" % " OR ".join(condQueryStr % (condition, unsafeSQLIdentificatorNaming(col)) for col in sorted(colList))
if colConsider == "1": if colConsider == "1":
infoMsg += "LIKE '%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList)) infoMsg += "like '%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList))
else: else:
infoMsg += "'%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList)) infoMsg += "'%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList))
else: else:
@ -1162,7 +1162,7 @@ class Enumeration:
condQuery = " AND (%s)" % " OR ".join(condQueryStr % (condition, unsafeSQLIdentificatorNaming(col)) for col in sorted(colList)) condQuery = " AND (%s)" % " OR ".join(condQueryStr % (condition, unsafeSQLIdentificatorNaming(col)) for col in sorted(colList))
if colConsider == "1": if colConsider == "1":
infoMsg += "LIKE '%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList)) infoMsg += "like '%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList))
else: else:
infoMsg += "'%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList)) infoMsg += "'%s' " % ", ".join(unsafeSQLIdentificatorNaming(col) for col in sorted(colList))
else: else:
@ -2199,13 +2199,6 @@ class Enumeration:
if foundDb is None or foundTbl is None: if foundDb is None or foundTbl is None:
continue continue
if foundDb not in dbs:
dbs[foundDb] = {}
if foundTbl not in dbs[foundDb]:
dbs[foundDb][foundTbl] = {}
if colConsider == "1":
conf.db = foundDb conf.db = foundDb
conf.tbl = foundTbl conf.tbl = foundTbl
conf.col = column conf.col = column
@ -2213,10 +2206,15 @@ class Enumeration:
self.getColumns(onlyColNames=True, colTuple=(colConsider, colCondParam), bruteForce=False) self.getColumns(onlyColNames=True, colTuple=(colConsider, colCondParam), bruteForce=False)
if foundDb in kb.data.cachedColumns and foundTbl in kb.data.cachedColumns[foundDb]: if foundDb in kb.data.cachedColumns and foundTbl in kb.data.cachedColumns[foundDb]:
if foundDb not in dbs:
dbs[foundDb] = {}
if foundTbl not in dbs[foundDb]:
dbs[foundDb][foundTbl] = {}
dbs[foundDb][foundTbl].update(kb.data.cachedColumns[foundDb][foundTbl]) dbs[foundDb][foundTbl].update(kb.data.cachedColumns[foundDb][foundTbl])
kb.data.cachedColumns = {} kb.data.cachedColumns = {}
else:
dbs[foundDb][foundTbl][column] = None
if foundDb in foundCols[column]: if foundDb in foundCols[column]:
foundCols[column][foundDb].append(foundTbl) foundCols[column][foundDb].append(foundTbl)
@ -2263,7 +2261,6 @@ class Enumeration:
foundCols[column][db] = [] foundCols[column][db] = []
else: else:
for db in conf.db.split(","): for db in conf.db.split(","):
dbs[db] = {}
if db not in foundCols[column]: if db not in foundCols[column]:
foundCols[column][db] = [] foundCols[column][db] = []
@ -2307,10 +2304,6 @@ class Enumeration:
tbl = safeSQLIdentificatorNaming(tbl, True) tbl = safeSQLIdentificatorNaming(tbl, True)
if tbl not in dbs[db]:
dbs[db][tbl] = {}
if colConsider == "1":
conf.db = db conf.db = db
conf.tbl = tbl conf.tbl = tbl
conf.col = column conf.col = column
@ -2318,12 +2311,20 @@ class Enumeration:
self.getColumns(onlyColNames=True, colTuple=(colConsider, colCondParam), bruteForce=False) self.getColumns(onlyColNames=True, colTuple=(colConsider, colCondParam), bruteForce=False)
if db in kb.data.cachedColumns and tbl in kb.data.cachedColumns[db]: if db in kb.data.cachedColumns and tbl in kb.data.cachedColumns[db]:
dbs[db][tbl].update(kb.data.cachedColumns[db][tbl]) if db not in dbs:
kb.data.cachedColumns = {} dbs[db] = {}
else:
dbs[db][tbl][column] = None
if tbl not in dbs[db]:
dbs[db][tbl] = {}
dbs[db][tbl].update(kb.data.cachedColumns[db][tbl])
kb.data.cachedColumns = {}
if db in foundCols[column]:
foundCols[column][db].append(tbl) foundCols[column][db].append(tbl)
else:
foundCols[column][db] = [tbl]
self.dumpFoundColumn(dbs, foundCols, colConsider) self.dumpFoundColumn(dbs, foundCols, colConsider)