-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
protocol: support query attribute since mysql 8.0.23 #55175
base: master
Are you sure you want to change the base?
Conversation
Welcome @kafka1991! |
Hi @kafka1991. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 kubernetes/test-infra repository. |
Hi @kafka1991. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. 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 kubernetes-sigs/prow repository. |
/ok-to-test |
33a9e2a
to
b42bf38
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55175 +/- ##
=================================================
- Coverage 73.3185% 56.2613% -17.0572%
=================================================
Files 1631 1756 +125
Lines 451092 630095 +179003
=================================================
+ Hits 330734 354500 +23766
- Misses 100031 251488 +151457
- Partials 20327 24107 +3780
Flags with carried forward coverage won't be shown. Click here to find out more.
|
i don't have much background about bazel, can anyone help me with bazel compilation error ? |
For the errors of https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftidb%2Fghpr_check/detail/ghpr_check/14289/pipeline
please check this line and fix it. It means public (exported) variables should have comment which is expected at the place 1 line above the definition. Also, please sign the CLA in the first comment. |
Thanks for your help, I have solved the problem.
The CLA had been signed. |
Maybe your GitHub account email is not the same as the email in this PR's commit? |
Had add the email in this PR's commit to github accounts in setting. |
you can use |
The failed If you need any help to reproduce the test result or debug the protocol related codes, feel free to |
Thanks for your remind, i will try to reproduce it by myself. |
You are right, params protocol implementation for By the way, server has a minor compatibility issue when tested by higher version of
|
MySQL also shows
I think the result of the query |
@lance6716 Can you help me with the failed tests? |
/retest |
@you06 can you take a look at failed UT TestInitStatsSessionBlockGC? |
26c37af
to
ac3e55f
Compare
@hawkingrei Can you take a look at the failed case TestInitStatsSessionBlockGC? |
ac3e55f
to
768dfe0
Compare
/retest |
@hawkingrei @YangKeao @lance6716
|
Sorry for the later reply @kafka1991 , I'll take a look in this week. |
/retest |
Seems it's a flaky test, not the problem of your PR Maybe merging master will eliminate this problem. I can pass this test with your PR in my local environment. Please continue review @YangKeao |
768dfe0
to
6eed1cd
Compare
[FORMAT CHECKER NOTIFICATION] Notice: To remove the For example:
📖 For more info, you can check the "Contribute Code" section in the development guide. |
@kafka1991: The following test failed, say
Full PR test history. Your PR dashboard. 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@kafka1991: The following tests failed, say
Full PR test history. Your PR dashboard. 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 kubernetes/test-infra repository. I understand the commands that are listed here. |
From the CI build job:
Maybe change |
@@ -23,7 +23,7 @@ import ( | |||
var ErrUnknownFieldType = dbterror.ClassServer.NewStd(errno.ErrUnknownFieldType) | |||
|
|||
// BinaryParam stores the information decoded from the binary protocol | |||
// It can be further parsed into `expression.Expression` through the `ExecArgs` function in this package | |||
// It can be further parsed into `expression.Expression` through the expression.ExecBinaryParam function in expression package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// It can be further parsed into `expression.Expression` through the expression.ExecBinaryParam function in expression package | |
// It can be further parsed into `expression.Expression` through the expression.ExecBinaryParam function in the expression package |
@@ -1698,6 +1706,61 @@ func (cc *clientConn) audit(eventType plugin.GeneralEvent) { | |||
} | |||
} | |||
|
|||
// parseQueryAttributes support query attributes since mysql 8.0.23 | |||
// see https://dev.mysql.com/doc/refman/8.0/en/query-attributes.html | |||
// https://archive.fosdem.org/2021/schedule/event/mysql_protocl/attachments/slides/4274/export/events/attachments/mysql_protocl/slides/4274/FOSDEM21_MySQL_Protocols_Query_Attributes.pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// https://archive.fosdem.org/2021/schedule/event/mysql_protocl/attachments/slides/4274/export/events/attachments/mysql_protocl/slides/4274/FOSDEM21_MySQL_Protocols_Query_Attributes.pdf | |
// https://archive.fosdem.org/2021/schedule/event/mysql_protocl/attachments/slides/4274/export/events/attachments/mysql_protocl/slides/4274/FOSDEM21_MySQL_Protocols_Query_Attributes.pdf | |
// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query.html | |
// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html |
@@ -319,6 +319,20 @@ func buildDatetimeParam(year uint16, month uint8, day uint8, hour uint8, minute | |||
return result | |||
} | |||
|
|||
func buildDatetimeParamWithClientQueryAttr(year uint16, month uint8, day uint8, hour uint8, min uint8, sec uint8, msec uint32) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func buildDatetimeParamWithClientQueryAttr(year uint16, month uint8, day uint8, hour uint8, min uint8, sec uint8, msec uint32) []byte { | |
func buildDatetimeParamWithClientQueryAttr(year uint16, month uint8, day uint8, hour uint8, _min uint8, sec uint8, msec uint32) []byte { |
Maybe _min
or minute
because min
is a predeclared identifier
ast.NextVal: &nextValFunctionClass{baseFunctionClass{ast.NextVal, 1, 1}}, | ||
ast.LastVal: &lastValFunctionClass{baseFunctionClass{ast.LastVal, 1, 1}}, | ||
ast.SetVal: &setValFunctionClass{baseFunctionClass{ast.SetVal, 2, 2}}, | ||
ast.QueryAttrString: &getQueryAttrFunctionClass{baseFunctionClass{ast.QueryAttrString, 1, 1}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ast.QueryAttrString: &getQueryAttrFunctionClass{baseFunctionClass{ast.QueryAttrString, 1, 1}}, | |
// Query attributes and ... | |
ast.QueryAttrString: &getQueryAttrFunctionClass{baseFunctionClass{ast.QueryAttrString, 1, 1}}, |
I don't think this belongs under "TiDB Sequence function." Maybe think of a good name or leave it out if it is obvious.
return b.SessionVarsPropReader.RequiredOptionalEvalProps() | ||
} | ||
|
||
func (b *builtinGetQueryAttrStringSig) evalString(ctx EvalContext, row chunk.Row) (string, bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (b *builtinGetQueryAttrStringSig) evalString(ctx EvalContext, row chunk.Row) (string, bool, error) { | |
// This implements `mysql_query_attribute_string(str)` | |
func (b *builtinGetQueryAttrStringSig) evalString(ctx EvalContext, row chunk.Row) (string, bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Often people know the function name and then have to fine the location of the code. This might help to make it easier to find.
Please review the description.
|
When testing MySQL 9.1.0 I noticed that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/python3
import mysql.connector
c = mysql.connector.connect(
host="127.0.0.1", port=4000, user="root", database="test", ssl_disabled=True
)
cur = c.cursor(prepared=True)
cur.add_attribute("testattr", "test value")
cur.execute("SELECT mysql_query_attribute_string(%s)", ("testattr",))
for row in cur:
print(row)
print(cur.get_attributes())
cur.clear_attributes()
print(cur.get_attributes())
cur.close()
c.close()
This script succeeds against MySQL 9.1.0 but fails against TiDB (master_query_attr
branch).
dvaneeden@dve-carbon:~$ ./query_attributes.py
Traceback (most recent call last):
File "/usr/lib64/python3.12/site-packages/mysql/connector/connection_cext.py", line 651, in cmd_stmt_execute
statement_id.stmt_execute(*args, query_attrs=self.query_attrs)
_mysql_connector.MySQLInterfaceError: Error while executing statement: runtime error: index out of range [1] with length 1
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/dvaneeden/./query_attributes.py", line 9, in <module>
cur.execute("SELECT mysql_query_attribute_string(%s)", ('testattr',))
File "/usr/lib64/python3.12/site-packages/mysql/connector/cursor_cext.py", line 1229, in execute
res = self._cnx.cmd_stmt_execute(self._stmt, *params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/mysql/connector/opentelemetry/context_propagation.py", line 102, in wrapper
return method(cnx, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/mysql/connector/connection_cext.py", line 653, in cmd_stmt_execute
raise InterfaceError(str(err)) from err
mysql.connector.errors.InterfaceError: Error while executing statement: runtime error: index out of range [1] with length 1
Wireshark also fails to decode it:
This might be because the flags are set to 0x0 instead of 0x8 (PARAMETER_COUNT_AVAILABLE
). See also https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #55174
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.