(table, colList, count=None, blind=True, alias=None)
| 37 | from thirdparty.six import unichr as _unichr |
| 38 | |
| 39 | def pivotDumpTable(table, colList, count=None, blind=True, alias=None): |
| 40 | lengths = {} |
| 41 | entries = {} |
| 42 | |
| 43 | dumpNode = queries[Backend.getIdentifiedDbms()].dump_table.blind |
| 44 | |
| 45 | validColumnList = False |
| 46 | validPivotValue = False |
| 47 | |
| 48 | if count is None: |
| 49 | query = dumpNode.count % table |
| 50 | query = agent.whereQuery(query) |
| 51 | count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) if blind else inject.getValue(query, blind=False, time=False, expected=EXPECTED.INT) |
| 52 | |
| 53 | if hasattr(count, "isdigit") and count.isdigit(): |
| 54 | count = int(count) |
| 55 | |
| 56 | if count == 0: |
| 57 | infoMsg = "table '%s' appears to be empty" % unsafeSQLIdentificatorNaming(table) |
| 58 | logger.info(infoMsg) |
| 59 | |
| 60 | for column in colList: |
| 61 | lengths[column] = len(column) |
| 62 | entries[column] = [] |
| 63 | |
| 64 | return entries, lengths |
| 65 | |
| 66 | elif not isNumPosStrValue(count): |
| 67 | return None |
| 68 | |
| 69 | for column in colList: |
| 70 | lengths[column] = 0 |
| 71 | entries[column] = BigArray() |
| 72 | |
| 73 | colList = filterNone(sorted(colList, key=lambda x: len(x) if x else MAX_INT)) |
| 74 | |
| 75 | if conf.pivotColumn: |
| 76 | for _ in colList: |
| 77 | if re.search(r"(.+\.)?%s" % re.escape(conf.pivotColumn), _, re.I): |
| 78 | infoMsg = "using column '%s' as a pivot " % conf.pivotColumn |
| 79 | infoMsg += "for retrieving row data" |
| 80 | logger.info(infoMsg) |
| 81 | |
| 82 | colList.remove(_) |
| 83 | colList.insert(0, _) |
| 84 | |
| 85 | validPivotValue = True |
| 86 | break |
| 87 | |
| 88 | if not validPivotValue: |
| 89 | warnMsg = "column '%s' not " % conf.pivotColumn |
| 90 | warnMsg += "found in table '%s'" % table |
| 91 | logger.warning(warnMsg) |
| 92 | |
| 93 | if not validPivotValue: |
| 94 | for column in colList: |
| 95 | infoMsg = "fetching number of distinct " |
| 96 | infoMsg += "values for column '%s'" % column.replace(("%s." % alias) if alias else "", "") |
no test coverage detected
searching dependent graphs…