Skip to content

Conversation

@kyleconroy
Copy link

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>
@kyleconroy
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant