[CONPY-259] When using callproc() to execute a SELECT statement, the results have different precision compared to directly executing SELECT Created: 2023-04-06 Updated: 2023-04-11 Resolved: 2023-04-11 |
|
| Status: | Closed |
| Project: | MariaDB Connector/Python |
| Component/s: | Generic |
| Affects Version/s: | 1.1.6 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Wenqian Deng | Assignee: | Georg Richter |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MariaDB 10.11 |
||
| Python Version: | 3.9 |
| Description |
|
I create a table with a column type of FLOAT and have a stored procedure that selects all records in the table. When I call this stored procedure using cursor.callproc(), the precision of the returned results is different from the results of direct SELECT. The test case:
|
| Comments |
| Comment by Georg Richter [ 2023-04-11 ] | |||||||||||||||
|
This is something we cannot fix: When converting a float (simple precision) to a string, the result from server is different when converting a double to string:
MariaDB Connector/Python uses binary client/server protocol for callproc() method, which means the value is transferred as a 4 byte floating point value and then converted to double (Python doesn't have float), while cursor's execute() method uses text protocol (unless placeholders are used) which transfers the value as a string. Example:
returns:
I would recommend to use either DOUBLE or DECIMAL instead of simple precision FLOAT. |