zzzzwc opened a new issue, #71:
URL: https://github.com/apache/doris-mcp-server/issues/71
首先发现了
db.py
```python
# Check if it's a query statement (statement that returns
result set)
# FIX for Issue #62 Bug 5: Added WITH support for Common
Table Expressions (CTE)
sql_upper = sql.strip().upper()
if (sql_upper.startswith("SELECT") or
sql_upper.startswith("SHOW") or
sql_upper.startswith("DESCRIBE") or
sql_upper.startswith("DESC") or
sql_upper.startswith("EXPLAIN") or
sql_upper.startswith("WITH")): # FIX: Support CTE
queries
data = await cursor.fetchall()
row_count = len(data)
else:
data = []
row_count = cursor.rowcount
```
这里没有考虑到USE开头的语句,但是把这里的判断去掉后,发现仍然没法返回数据。
调研后发现根因是aiomysql和pymysql行为不太一样
aiomysql cursor.execute多条语句之后, cursor状态受首条语句影响
pymysql cursor.execute多条语句之后, cursor状态受最后一条语句影响
这导致了execute USE xxx;SELECT XXX;时cursor fetch的结果集是USE xxxx;的空结果集。
然后我改了prompt让llm尽量不生成USE xxx;
但有时候llm又会生成SELECT xxx;SELECT xxx;只能再调prompt;
再加上看测试和已有代码里,mcp是想要支持多语句execute_sql的;我就把他实现了一下:
https://github.com/apache/doris-mcp-server/pull/70
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]