Skip to content

Commit

Permalink
调整变量名及Black处理
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuhongLee committed Mar 28, 2024
1 parent 1430728 commit 5e3b021
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 5e3b021

Please sign in to comment.