Bug #68066 callproc function with string parameters
Submitted: 10 Jan 2013 6:52 Modified: 19 Feb 2013 22:47
Reporter: Mustafa YILDIRIM Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:1.0.8 OS:Linux (OpenSuSE 11.4 x64 Python 2.7)
Assigned to: Geert Vanderkelen CPU Architecture:Any
Tags: python, stored procedure, String Parameters
Triage: Triaged: D2 (Serious) / E3 (Medium)

[10 Jan 2013 6:52] Mustafa YILDIRIM
Description:
When stored procedure calling with a string parameter like that

cur = db.cursor()
cur.callproc('android.personelInfo',('MUSTAFA',)) 

callproc function append additional quotes to parameters

(u"'MUSTAFA'",), 

and then stored procedure doesn't work correctly. Because input parameters of procedure is not a same as you want to process.

How to repeat:
cur = db.cursor()
cur.callproc('android.personelInfo',('MUSTAFA',)) 

Suggested fix:
_process_param function of the cursors.py have to modify.
[24 Jan 2013 18:28] Sveta Smirnova
Thank you for the report.

Verified as described.

Test case (I connect to MTR):

$ cat bug68066.py 
import mysql.connector
config = {
  'user':'root',
'password':'',
'host': '127.0.0.1',
'port':13000,
'database':'test',
'ssl_ca':'/home/sveta/src/mysql-trunk/mysql-test/std_data/cacert.pem',
'ssl_cert':'/home/sveta/src/mysql-trunk/mysql-test/std_data/client-cert.pem',
'ssl_key':'/home/sveta/src/mysql-trunk/mysql-test/std_data/client-key.pem',
}
cnx = mysql.connector.connect(**config)
cur = cnx.cursor()
cur.execute('drop table if exists bug68066')
cur.execute('create table bug68066(f1 varchar(255))')
cur.execute('drop procedure if exists bug68066')
cur.execute('create procedure bug68066(v1 varchar(255)) begin insert into bug68066 values(v1); end')
cur.callproc('bug68066', ('mustafa',))
cur.execute('select f1 from bug68066')
for (f1) in cur:
	print("In the table: ", f1)
cur.execute('drop table if exists bug68066')
cur.execute('drop procedure if exists bug68066')
cur.close()
cnx.close()
[10 Feb 2013 23:40] Robert Turer
Same problem exists on the Mac - Python version 3.3. Same use case. Looking forward to fix!
[19 Feb 2013 22:47] John Russell
Added to changelog for 1.0.9: 

Passing string parameters to a stored procedure resulted in extra
quotes being included in the value. This was caused by the conversion
from Python to MySQL data types being applied two times. We now only
convert once, and pass the values correctly. MySQLCursor.callproc()
now also raises a ValueError when the type of an argument is
incorrect.