| Bug #114817 | callproc cannot call proc from another database | ||
|---|---|---|---|
| Submitted: | 29 Apr 2024 14:43 | Modified: | 30 Apr 2024 16:57 |
| Reporter: | Guanqun Yang | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / Python | Severity: | S3 (Non-critical) |
| Version: | OS: | Any | |
| Assigned to: | CPU Architecture: | Any | |
[30 Apr 2024 12:59]
MySQL Verification Team
Hello Guanqun Yang,
Thank you for the report and feedback.
I quickly tried to reproduce the issue but not seeing any issues. Am I missing anything here? Thank you.
#### VS 2022 / Python 3.10 / Connector/Python 8.3.0 on Win 11
"""
create database a;
create database b;
use a;
delimiter ;;
CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
BEGIN
SET pProd := pFac1 * pFac2;
END;;
delimiter ;
call multiply(5, 6, 0);
use b;
delimiter ;;
CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
BEGIN
SET pProd := pFac1 * pFac2;
END;;
delimiter ;
"""
import mysql.connector
from mysql.connector import Error
print("Connector/Python version {} ".format(mysql.connector.__version__))
try:
connection = mysql.connector.connect(host='localhost',
database='a',
user='root',
password='mysql123')
args = (5, 6, 0)
cursor = connection.cursor()
result_args = cursor.callproc('b.multiply', args)
print(result_args[2])
except mysql.connector.Error as error:
print("Failed to execute stored procedure: {}".format(error))
finally:
if (connection.is_connected()):
cursor.close()
connection.close()
print("...")
--
Connector/Python version 8.3.0
30
...
Press any key to continue . . .
[30 Apr 2024 15:58]
Guanqun Yang
saw this issue is fixed in later version. Thanks
[30 Apr 2024 15:59]
Guanqun Yang
already fixed
[30 Apr 2024 16:57]
MySQL Verification Team
Thank you for confirming.

Description: callproc in cursor.py cannot call proc from another database using "databasename.procname" because if argnames: # Create names aliases to be compatible with namedtuples args = [ "{} AS {}".format(name, alias) for name, alias in zip(argtypes, [arg.lstrip("@_") for arg in argnames]) ] select = "SELECT {}".format(",".join(args)) self.execute(select) self._stored_results = results return self.fetchone() where "." cannot be used in Aliases How to repeat: try to use callproc to call a function in another database with args Suggested fix: don't using "." to construct alias