Repository navigation
Conversation
cincuranet
reviewed
Nov 4, 2026
cincuranet
left a comment
Member
There was a problem hiding this comment.
I think this is not entirely correct. The INSERT ... RETURNING in Firebird is reported as StoredProcedure IIRC and hence now it would become -1.
alaricd
force-pushed
the
fix/records-affected-contract
branch
from
November 4, 2026 13:50
8934d05 to
1a2f507
Compare
Firebird classifies INSERT ... RETURNING and DML inside an execute block as stored procedure execution, so the statement-type switch reported -1 for them and the reader stopped reporting the insert count it used to report. Count stored procedure execution only when the server reports a positive count, so procedures that change no rows keep -1. Also set RecordsAffected to -1 in the FbDataReader constructor instead of the field initializer, as requested in review. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
alaricd
force-pushed
the
fix/records-affected-contract
branch
from
November 5, 2026 12:45
1a2f507 to
e82f3ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1285.
Root cause
RecordsAffectedwas taken from the statement type. Firebird classifiesINSERT ... RETURNINGand DML inside an execute block as stored procedure execution, so the new switch returned -1 for them, although the server reports the correct count. This was a regression for the reader: before this PR it reported the insert count.Change
RecordsAffectedstarts at -1 and is set in theFbDataReaderconstructor (review feedback).INSERT,UPDATE, andDELETEreport the server count. Stored procedure execution reports the server count only when it is positive, so a procedure that changes no rows keeps -1.UPDATE ... RETURNINGandDELETE ... RETURNINGare classified as SELECT by Firebird, so they keep -1, as before this PR. This is unchanged and outside this PR.Measured server counts (Firebird 5.0.2)
insert ... returning: 1insertwithout returning: 1updatewith no matches: 0execute blockwith one insert: 1; with two inserts: 2; empty block: 0update ... returninganddelete ... returning: -1 (SELECT classification)Tests
RecordsAffectedForInsertReturningTest(reader) andExecuteNonQueryForInsertReturningTest: fail without the fix (Expected: 1, But was: -1).ExecuteNonQueryForStatementWithoutRowChangesIsMinusOneTest: pins the -1 for a procedure that changes no rows.RecordsAffectedIsMinusOneForSelectTest: existing SELECT coverage.Verification gaps
AI disclosure
This change was prepared with AI assistance (Claude Code).
🤖 Generated with Claude Code