Skip to content

Commit

Permalink
fix bug 2177 2168
Browse files Browse the repository at this point in the history
  • Loading branch information
taijiyouxia committed Jun 8, 2023
1 parent 4bca447 commit 44c6d97
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False):
conn = self.get_connection()
cursor = conn.cursor()
if db_name:
cursor.execute(
f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ",
{"db_name": db_name},
)
cursor.execute(f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" ')
if re.match(r"^explain", sql, re.I):
sql = sql
else:
Expand All @@ -609,7 +606,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False):
)
rows = cursor.fetchone()
conn.rollback()
if not rows:
if rows[0] is None or not rows:
result["rows"] = 0
else:
result["rows"] = rows[0]
Expand Down Expand Up @@ -672,10 +669,7 @@ def query(
conn = self.get_connection()
cursor = conn.cursor()
if db_name:
cursor.execute(
f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ",
{"db_name": db_name},
)
cursor.execute(f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" ')
sql = sql.rstrip(";")
# 支持oralce查询SQL执行计划语句
if re.match(r"^explain", sql, re.I):
Expand Down

1 comment on commit 44c6d97

@taijiyouxia
Copy link
Author

@taijiyouxia taijiyouxia commented on 44c6d97 Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain plan for create table test (id number);
select CARDINALITY from (select CARDINALITY from PLAN_TABLE t where id = 0 order by t.timestamp desc) where rownum = 1
注意上面的返回是有结果的,一行数据,但是这一行数据值为null。
所以变量rows[0] 为None。
此时会走到
result["rows"] = rows[0];

报错如下:
[2023-05-23 16:44:22,753][Thread-2:139803802728192][task_id:default][oracle.py:1010][WARNING]- Oracle 语句执行报错,第1个SQL:create table test111(id int);,错误信息Traceback (most recent call last):
File "/backup/Archery-1.9.1/sql/engines/oracle.py", line 836, in execute_check
if result_set["rows"] > 1000:
TypeError: '>' not supported between instances of 'NoneType' and 'int'

Please sign in to comment.