diff --git a/sql/engines/oracle.py b/sql/engines/oracle.py index 7e23d5184e..7dfad3bbaa 100644 --- a/sql/engines/oracle.py +++ b/sql/engines/oracle.py @@ -1268,19 +1268,19 @@ def backup(self, workflow, cursor, begin_time, end_time): AND b.rn =1 """ # 使用logminer抓取回滚SQL # 12c以下版本用此SQL - logmnr_start_sql_old = f"""begin + logmnr_start_before12c_sql = f"""begin dbms_logmnr.start_logmnr( starttime=>to_date('{begin_time}','yyyy-mm-dd hh24:mi:ss'), endtime=>to_date('{end_time}','yyyy/mm/dd hh24:mi:ss'), options=>dbms_logmnr.dict_from_online_catalog + dbms_logmnr.continuous_mine); end;""" # 12c及以上版本用此SQL - logmnr_start_sql_new = f"""begin + logmnr_start_sql = f"""begin dbms_logmnr.start_logmnr( starttime=>to_date('{begin_time}','yyyy-mm-dd hh24:mi:ss'), endtime=>to_date('{end_time}','yyyy/mm/dd hh24:mi:ss'), options=>dbms_logmnr.dict_from_online_catalog); - end;""" + end;""" undo_sql = f"""select xmlagg(xmlparse(content sql_redo wellformed) order by scn,rs_id,ssn,rownum).getclobval() , xmlagg(xmlparse(content sql_undo wellformed) order by scn,rs_id,ssn,rownum).getclobval() @@ -1295,16 +1295,24 @@ def backup(self, workflow, cursor, begin_time, end_time): # 判断数据库版本,12c及以上版本手动添加redo文件来分析 if int(self.server_version[0]) > 11: cursor.execute(redo_files_sql) - rows=cursor.fetchall() - for index,row in enumerate(rows): + rows = cursor.fetchall() + for index, row in enumerate(rows): if index == 0: - cursor.execute("BEGIN dbms_logmnr.add_logfile('"+ str(row[0]) + "', dbms_logmnr.new); END;") + cursor.execute( + "BEGIN dbms_logmnr.add_logfile('" + + str(row[0]) + + "', dbms_logmnr.new); END;" + ) else: - cursor.execute("BEGIN dbms_logmnr.add_logfile('"+ str(row[0]) + "', dbms_logmnr.addfile); END;") - cursor.execute(logmnr_start_sql_new) + cursor.execute( + "BEGIN dbms_logmnr.add_logfile('" + + str(row[0]) + + "', dbms_logmnr.addfile); END;" + ) + cursor.execute(logmnr_start_sql) # 12c以下版本使用以下logminer else: - cursor.execute(logmnr_start_sql_old) + cursor.execute(logmnr_start_before12c_sql) cursor.execute(undo_sql) rows = cursor.fetchall() cursor.execute(logmnr_end_sql)