Skip to content

db.mysql: preserve field metadata and add streamed results - #28082

Open
guweigang wants to merge 9 commits into
vlang:masterfrom
guweigang:fix-mysql-stream-results
Open

db.mysql: preserve field metadata and add streamed results#28082
guweigang wants to merge 9 commits into
vlang:masterfrom
guweigang:fix-mysql-stream-results

Conversation

@guweigang

Copy link
Copy Markdown
Contributor

Summary

  • fix Result.fields() so every column reads its own MYSQL_FIELD metadata
  • add unbuffered query_stream() and one-shot prepared prepare_stream() APIs
  • preserve SQL NULL separately from empty strings and read binary values with their exact lengths
  • keep connections reusable after exhaustion, early close, fetch/execute failures, and
    multi-statement queries
  • retain the legacy use_result() signature while safely discarding pending results

Why

Result.fields() indexed only the field name. The remaining properties were read through the
base pointer, so every result column inherited the first column's type, length, flags, and
character set.

The existing materialized query APIs also provided no way to consume large results in bounded
batches. This adds streaming adapters around mysql_use_result() and the prepared statement
fetch APIs without changing the behavior of query() or the existing prepared statement APIs.

Validation

  • ./vnew fmt -verify for all changed V files
  • ./vnew check-md vlib/db/mysql/README.md
  • git diff --check
  • ./vnew -d network -d mysql_test_password=... -silent vlib/db/mysql/result_test.c.v
  • ./vnew -d network -d mysql_test_password=... -silent vlib/db/mysql/stream_test.c.v
  • ./vnew -silent test vlib/db/mysql/ (6 passed)
  • Ubuntu/GCC with VFLAGS='-gc none -cc gcc': compiler build and both network test files compile;
    runtime suite skipped because MySQL is not running in the VM

@guweigang
guweigang marked this pull request as ready for review August 13, 2026 10:15
@medvednikov

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32b8f589ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vlib/db/mysql/stream.c.v Outdated
@medvednikov

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2226b893f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vlib/db/mysql/result.c.v
@medvednikov

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 629a24d0b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vlib/db/mysql/stream.c.v
@guweigang

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

2 participants