Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect ROW_COUNT value after SINGULAR condition [CORE2965] #3347

Closed
firebird-issue-importer opened this issue Apr 12, 2010 · 13 comments
Closed

Comments

@firebird-issue-importer

Submitted by: Alex Kurov (alex.kurov)

Is related to QA437

Test case:

execute block
returns(rcount integer)
as
declare tmpint integer;
begin
select rdb$relation_id from rdb$database into tmpint;
if (SINGULAR(select rdb$relation_id from rdb$database where rdb$relation_id is null)) then begin end
rcount = row_count;
suspend;
end;

returns:
1

should return:
0

Commits: b29556c

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 12, 2010

Commented by: Sean Leyne (seanleyne)

Please explain why you think the current result is incorrect.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 12, 2010

Commented by: Alex Kurov (alex.kurov)

You can try another sql statement

execute block
returns(rcount integer)
as
declare tmpint integer;
begin
select rdb$relation_id from rdb$database into tmpint;
if (SINGULAR(select * from rdb$relation_fields)) then begin end
rcount = row_count;
suspend;
end;

And you'll see it does not return 1 as the example above

So if subselect in singular condition doesn't return any dataset the ROW_COUNT variable stays unaffected.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 12, 2010

Commented by: @dyemanov

ROW_COUNT means the number of records selected or modified by the SELECT, INSERT, UPDATE or DELETE clause. It is not intended to return number of records affected by sub-queries.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 12, 2010

Modified by: Sean Leyne (seanleyne)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 13, 2010

Commented by: Alex Kurov (alex.kurov)

Ok. But as you can see from the second example - it does. It seems like row_count is equal to number of rows fetched from rdb$relation_fields (it is subselect)

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 13, 2010

Commented by: @dyemanov

You're right, we have some inconsistency here. The counter is reset for the every SELECT/UPDATE/etc statement, but incremented per every fetch, including sub-queries. I suggest to fix it by not incrementing the counter for sub-queries.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 13, 2010

Modified by: @dyemanov

status: Resolved [ 5 ] => Reopened [ 4 ]

assignee: Dmitry Yemanov [ dimitr ]

resolution: Won't Fix [ 2 ] =>

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 13, 2010

Modified by: @dyemanov

status: Reopened [ 4 ] => In Progress [ 3 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 16, 2010

Modified by: @dyemanov

status: In Progress [ 3 ] => Open [ 1 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 16, 2010

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC3 [ 10381 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 24, 2011

Modified by: @pcisar

Link: This issue is related to QA437 [ QA437 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jun 15, 2011

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 28, 2015

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants