Skip to content

Fix calculation of number of affected rows. - #30

Open
P1cheneG wants to merge 1 commit into
FirebirdSQL:mainfrom
P1cheneG:fix_affected_rows_calculating
Open

P1cheneG wants to merge 1 commit into
FirebirdSQL:mainfrom
P1cheneG:fix_affected_rows_calculating

Conversation

@P1cheneG

@P1cheneG P1cheneG commented Nov 9, 2026

Copy link
Copy Markdown

No description provided.

@P1cheneG
P1cheneG requested a review from MrTeeett November 9, 2026 08:09
@P1cheneG P1cheneG self-assigned this Nov 9, 2026
@P1cheneG P1cheneG added this to the v0.8.0 milestone Nov 9, 2026
Comment thread fbconn/statement.go
if modifiedCount != 0 {
return modifiedCount
}
return sd.StatementInfo.Counts.SelectCount

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There remains the case where there are zero changes within the EXECUTE BLOCK.

The table pr30_live_counts(id integer primary key, val integer) contains a single row: (1, 10). Let's execute the block:

execute block as
  declare v integer;
begin
  select id
    from pr30_live_counts
    where id = 1
    into :v;

  update pr30_live_counts
    set val = val + 1
    where id = -1;
end

The block read one row, but the UPDATE did not change anything. The server returns:

  • StatementType = 8 (isc_info_sql_stmt_exec_procedure);
  • SelectCount = 1;
  • InsertCount = UpdateCount = DeleteCount = 0.

The data in the table remains unchanged. However, RowsAffected() returns 1 instead of the expected 0. This is reproducible via fbconn and database/sql.

The reason is that when modifiedCount == 0, the system switches to SelectCount, even though an anonymous block with zero changes was executed.

@smirnoffjr smirnoffjr added the bug Something isn't working label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants