Implement query attributes#1784
Conversation
AI usage disclosure: created with GPT 5.6 Sol then reviewed and edited by hand.
ada6949 to
172c81f
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughQuery attributes are introduced for direct and prepared MySQL queries. The driver validates and separates attributes from positional parameters, negotiates server support, serializes attributes in COM_QUERY and execute packets, and adds unit and integration coverage. ChangesQuery Attribute Support
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant mysqlConn
participant mysqlStmt
participant MySQLServer
Client->>mysqlConn: ExecContext or QueryContext with QueryAttribute
mysqlConn->>mysqlStmt: Route prepared execution when applicable
mysqlConn->>MySQLServer: Send COM_QUERY or prepared execute packet with attributes
MySQLServer-->>Client: Return query or execution result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packets.go`:
- Around line 205-211: Update the handshake parsing flow around
parseServerVersion and the subsequent fixed-field reads to validate that data
contains the complete connection ID, auth data, filler, and capability bytes
before any slice access. Return ErrMalformPkt when the remaining packet is too
short, while preserving normal parsing for complete packets.
In `@query_attribute_test.go`:
- Around line 179-218: Update the query-attribute test around the version check
to also verify that the optional query_attributes component or
mysql_query_attribute_string function is available before executing either
query. Skip the test with a clear reason when it is unavailable, while
preserving the existing version gate and test flow for supported servers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4c786d88-fdd9-466e-abad-d2590af0ee76
📒 Files selected for processing (8)
AUTHORSconnection.goconst.gopackets.goquery_attribute.goquery_attribute_test.gostatement.goutils.go
| return mc.query(query, args) | ||
| return mc.queryWithAttributes(query, args, nil) |
There was a problem hiding this comment.
Why not leaving mc.query here?
I don't think you need this change
There was a problem hiding this comment.
Ah, thanks, I'll address these - the agent originally did a much bigger refactor that I tried to back out but evidently I missed spots
| Value any | ||
| } | ||
|
|
||
| func validateQueryAttribute(attr QueryAttribute) error { |
There was a problem hiding this comment.
Maybe a method on the struct instead of this
| func checkNoError(t *testing.T, err error) { | ||
| t.Helper() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
|
|
||
| func checkEqual[T any](t *testing.T, want, got T) { | ||
| t.Helper() | ||
| if !reflect.DeepEqual(want, got) { | ||
| t.Fatalf("want %#v, got %#v", want, got) | ||
| } | ||
| } |
There was a problem hiding this comment.
I find odd you added these as all repository was tested with such an helper until now.
|
I do not intend to merge this PR immediately.
So, please do not expect detailed reviews or merges in the near future. Instead of creating a PR right away, it would be more helpful for me if you could create an issue with links to the information needed to make the technical decisions mentioned above. |
|
Thanks - sorry for dropping this on you. I will follow up with an issue later. |
Description
Add support for passing query attributes via a special bind parameter. The intent is to enable passing through OpenTelemetry traceparents which is now possible with MySQL 9.7 Community.
AI usage disclosure: created with GPT 5.6 Sol then reviewed and edited by hand.
Checklist