@@ -290,6 +290,24 @@ def getTables(self, bruteForce=None):
290290 db = safeSQLIdentificatorNaming (db )
291291 table = safeSQLIdentificatorNaming (unArrayizeValue (table ), True )
292292
293+ if conf .getComments :
294+ _ = queries [Backend .getIdentifiedDbms ()].table_comment
295+ if hasattr (_ , "query" ):
296+ if Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
297+ query = _ .query % (unsafeSQLIdentificatorNaming (db .upper ()), unsafeSQLIdentificatorNaming (table .upper ()))
298+ else :
299+ query = _ .query % (unsafeSQLIdentificatorNaming (db ), unsafeSQLIdentificatorNaming (table ))
300+
301+ comment = unArrayizeValue (inject .getValue (query , blind = False , time = False ))
302+ if not isNoneValue (comment ):
303+ infoMsg = "retrieved comment '%s' for table '%s' " % (comment , unsafeSQLIdentificatorNaming (table ))
304+ infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming (db )
305+ logger .info (infoMsg )
306+ else :
307+ warnMsg = "on %s it is not " % Backend .getIdentifiedDbms ()
308+ warnMsg += "possible to get column comments"
309+ singleTimeWarnMessage (warnMsg )
310+
293311 if db not in kb .data .cachedTables :
294312 kb .data .cachedTables [db ] = [table ]
295313 else :
@@ -353,6 +371,24 @@ def getTables(self, bruteForce=None):
353371 table = safeSQLIdentificatorNaming (table , True )
354372 tables .append (table )
355373
374+ if conf .getComments :
375+ _ = queries [Backend .getIdentifiedDbms ()].table_comment
376+ if hasattr (_ , "query" ):
377+ if Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
378+ query = _ .query % (unsafeSQLIdentificatorNaming (db .upper ()), unsafeSQLIdentificatorNaming (table .upper ()))
379+ else :
380+ query = _ .query % (unsafeSQLIdentificatorNaming (db ), unsafeSQLIdentificatorNaming (table ))
381+
382+ comment = unArrayizeValue (inject .getValue (query , union = False , error = False ))
383+ if not isNoneValue (comment ):
384+ infoMsg = "retrieved comment '%s' for table '%s' " % (comment , unsafeSQLIdentificatorNaming (table ))
385+ infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming (db )
386+ logger .info (infoMsg )
387+ else :
388+ warnMsg = "on %s it is not " % Backend .getIdentifiedDbms ()
389+ warnMsg += "possible to get column comments"
390+ singleTimeWarnMessage (warnMsg )
391+
356392 if tables :
357393 kb .data .cachedTables [db ] = tables
358394 else :
0 commit comments