Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported flag 128 with Connector/Python and prepared statements #36731

Closed
dveeden opened this issue Jul 29, 2022 · 7 comments · Fixed by #36732
Closed

unsupported flag 128 with Connector/Python and prepared statements #36731

dveeden opened this issue Jul 29, 2022 · 7 comments · Fixed by #36732
Assignees
Labels

Comments

@dveeden
Copy link
Contributor

dveeden commented Jul 29, 2022

Bug Report

1. Minimal reproduce step (Required)

#!/bin/python3
import argparse
import mysql.connector

parser = argparse.ArgumentParser()
parser.add_argument('--host', type=str, default='127.0.0.1')
parser.add_argument('--port', type=int, default=4000)
parser.add_argument('--user', type=str, default='root')
parser.add_argument('--password', type=str, default='')
args = parser.parse_args()
c = mysql.connector.connect(host=args.host, port=args.port, user=args.user, password=args.password)
cur = c.cursor(prepared=True)
cur.execute('DO ?', (1, ))
cur.close()
c.close()
print('OK')

2. What did you expect to see? (Required)

With MySQL 8.0.30:

$ ./prepared.py --port 8030 --user test --password test
OK

3. What did you see instead (Required)

With TiDB:

$ ./prepared.py
Traceback (most recent call last):
  File "/tmp/./prepared.py", line 13, in <module>
    cur.execute('DO ?', (1, ))
  File "/usr/lib/python3.11/site-packages/mysql/connector/cursor.py", line 1213, in execute
    res = self._connection.cmd_stmt_execute(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mysql/connector/connection.py", line 1100, in cmd_stmt_execute
    result = self._handle_binary_result(packet)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mysql/connector/connection.py", line 1025, in _handle_binary_result
    raise errors.get_exception(packet)
mysql.connector.errors.DatabaseError: 1105 (HY000): ERROR 1105 (HY000): unsupported flag 128

And in the logs:

[2022/07/29 16:03:44.416 +02:00] [INFO] [conn.go:1170] ["command dispatched failed"] [conn=2199023255961] [connInfo="id:2199023255961, addr:127.0.0.1:34430 status:0, collation:utf8mb4_general_ci, user:root"] [command=Execute] [status="inTxn:0, autocommit:0"] [sql="DO ?"] [txn_mode=PESSIMISTIC] [timestamp=0] [err="ERROR 1105 (HY000): unsupported flag 128"]

4. What is your TiDB version? (Required)

sql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.2.0-alpha-560-ge5c900c8c
Edition: Community
Git Commit Hash: e5c900c8cd4cea6da2af02768c28cad10a8b1d13
Git Branch: master
UTC Build Time: 2022-07-29 13:51:19
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
1 row in set (0.0001 sec)
@dveeden dveeden added the type/bug The issue is confirmed as a bug. label Jul 29, 2022
@dveeden
Copy link
Contributor Author

dveeden commented Jul 29, 2022

This is coming from this code:

return mysql.NewErrf(mysql.ErrUnknown, "unsupported flag %d", nil, flag)

@dveeden
Copy link
Contributor Author

dveeden commented Jul 29, 2022

https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html says this:
"the type as in enum_field_types
a flag byte which has the highest bit set if the type is unsigned [80]"

Note that 0x80 (hex) == 128 (decimal) == 10000000 (binary) so this has the unsigned bit set, but none of the flags.

@dveeden
Copy link
Contributor Author

dveeden commented Jul 29, 2022

/severity moderate

@dveeden
Copy link
Contributor Author

dveeden commented Jul 31, 2022

/type mysql-protocol

@ti-chi-bot
Copy link
Member

@dveeden: The label(s) type/mysql-protocol cannot be applied, because the repository doesn't have them.

In response to this:

/type mysql-protocol

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@dveeden
Copy link
Contributor Author

dveeden commented Jul 31, 2022

/component mysql-protocol

@dveeden
Copy link
Contributor Author

dveeden commented Aug 4, 2022

This results in flag value of 0x80:

cur.execute('DO ?', (1, ))

This results in a flag value of 0x0:

cur.execute('DO ?', ("1", ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants