Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Expose prepared statement column and parameter metadata #1743

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

Draft
kyleconroy wants to merge 1 commit into go-sql-driver:master
base: master
Choose a base branch
Loading
from sqlc-dev:expose_query_metadata

Conversation

@kyleconroy
Copy link

@kyleconroy kyleconroy commented Nov 29, 2025

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

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](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /