mysql
mysql copied to clipboard
feat: Expose prepared statement column and parameter metadata
This adds public APIs to access metadata from COM_STMT_PREPARE responses:
- Add FieldMetadata struct to expose column/parameter information
- Add StmtMetadata interface with ColumnMetadata() and ParamMetadata() methods
- Modify Prepare() to read parameter metadata instead of skipping it
- Modify Prepare() to always read column metadata (not just with cache capability)
The FieldMetadata struct exposes:
- TableName, Name, Length, Decimals
- DatabaseTypeName (e.g., "INT", "VARCHAR", "TEXT")
- Nullable and Unsigned flags
This allows tools like sqlc to get type information for query parameters and result columns directly from prepared statements.
🤖 Generated with Claude Code
Description
Please explain the changes you made here.
Checklist
- [ ] Code compiles correctly
- [ ] Created tests which fail without the change (if possible)
- [ ] All tests passing
- [ ] Extended the README / documentation, if necessary
- [ ] Added myself / the copyright holder to the AUTHORS file
Hey there! I maintain github.com/sqlc-dev/sqlc. For some query analysis work I'm doing I need more of the metadata provided by the server.
I'm not sure if this is of any interest. It's not well tested and written by Claude Code, so it already has some strikes against it. If it is interesting, I'm happy to clean it up. Also feel free to just close this.