If the 'sql_stmt' is shorter than MAX_SQL_LOGGING_LENGTH, only wrap sql_stmt with new lines and semicolon. If it is larger than MAX_SQL_LOGGING_LENGTH, truncate it and comment it out. This function returns a unicode string.
(sql_stmt)
| 93 | # the size of the JUnitXML files, causing problems for users of JUnitXML like Jenkins. |
| 94 | # This function limits the size of the returned string if it is larger than 128KB. |
| 95 | def format_sql_for_logging(sql_stmt): |
| 96 | """If the 'sql_stmt' is shorter than MAX_SQL_LOGGING_LENGTH, only wrap sql_stmt with |
| 97 | new lines and semicolon. If it is larger than MAX_SQL_LOGGING_LENGTH, truncate it |
| 98 | and comment it out. This function returns a unicode string.""" |
| 99 | # sql_stmt could contain Unicode characters, so explicitly use unicode literals |
| 100 | # so that Python 2 works. |
| 101 | if (len(sql_stmt) <= MAX_SQL_LOGGING_LENGTH): |
| 102 | return u"\n{0};\n".format(sql_stmt) |
| 103 | else: |
| 104 | # The logging output should be valid SQL, so the truncated SQL is commented out. |
| 105 | truncated_sql = u'\n--'.join( |
| 106 | [line for line in sql_stmt[0:MAX_SQL_LOGGING_LENGTH].split("\n")]) |
| 107 | return (u"\n-- Skip logging full SQL statement of length {0}" |
| 108 | u"\n-- Logging a truncated version, commented out:" |
| 109 | u"\n-- {1}" |
| 110 | u"\n-- [...]\n").format(len(sql_stmt), truncated_sql) |
| 111 | |
| 112 | |
| 113 | def build_summary_table_from_thrift(thrift_exec_summary): |
no test coverage detected