hhyo / hhyo/Archery

[ bug ]oracle查询SQL文本遇到“#”可能会被截断,导致SQL执行报错

Open
#706 0 comments 0 reactions 0 assignees View on GitHub
area/oracle bug
Dominant language
Python
Stars
7k
Forks
1.9k
Avg merge
2d 11h
Merged PRs (30d)
6

Description

## 重现步骤

查询Oracle数据字典,如果带上“#”号会报错,分析输出日志看是SQL被截断了
select ee.serial# from v$session ee;

报错如下:
[2020-04-12 22:40:17,006][DummyThread-6:139906461217352][task_id:default][oracle.py:276][WARNING]- Oracle 语句执行报错,语句:explain plan for select ee.serial,错误信息Traceback (most recent call last):
File "/opt/archery/sql/engines/oracle.py", line 266, in explain_check
cursor.execute(sql)
cx_Oracle.DatabaseError: ORA-00923: FROM keyword not found where expected

Contributor guide

Open the contributing guide

Research direction

Start in sql/engines/oracle.py at explain_check around line 266, and reproduce the issue with select ee.serial# from v$session ee;. Trace how the SQL text is processed before cursor.execute(sql), then verify that the complete statement reaches Oracle without truncation and that the example executes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.