Skip to content

fix(pgwire): prepared batch with same SQL returns corrupted results#6706

Merged
bluestreak01 merged 4 commits intomasterfrom
victor_pgwire_fix
Jan 26, 2026
Merged

fix(pgwire): prepared batch with same SQL returns corrupted results#6706
bluestreak01 merged 4 commits intomasterfrom
victor_pgwire_fix

Conversation

@kafka1991
Copy link
Copy Markdown
Collaborator

@kafka1991 kafka1991 commented Jan 26, 2026

When executing multiple commands with the same SQL but different parameters caused the second command to return corrupted data.

Root cause: msgBindCopySelectFormatCodes() checked factory != null to determine if format codes should be set. When a prepared statement is reused via copyIfExecuted(), the new entry has factory=null (not copied), causing format codes to be skipped. The client then misinterpreted binary/text format.

Fix: Replace factory != null with hasResultSet() which uses sqlType

Fixes #6703

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kafka1991 kafka1991 changed the title fix(pgwire): fix msgBindSelectFormatCodes fix(pgwire): prepared batch with same SQL returns corrupted results Jan 26, 2026
@kafka1991 kafka1991 requested a review from jerrinot January 26, 2026 10:47
jerrinot
jerrinot previously approved these changes Jan 26, 2026
Copy link
Copy Markdown
Contributor

@jerrinot jerrinot left a comment

Choose a reason for hiding this comment

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

good change!

@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 3 / 3 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/cutlass/pgwire/PGPipelineEntry.java 3 3 100.00%

@bluestreak01 bluestreak01 merged commit 08f39d6 into master Jan 26, 2026
43 checks passed
@bluestreak01 bluestreak01 deleted the victor_pgwire_fix branch January 26, 2026 17:32
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.

Prepared batch statements returns incorrect results

4 participants