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

Parameter in offset expression in LAG, LEAD, NTH_VALUE window functions requires explicit cast to BIGINT or INTEGER [CORE6421] #6659

Closed
firebird-issue-importer opened this issue Oct 19, 2020 · 8 comments

Comments

@firebird-issue-importer

Submitted by: @mrotteveel

When using a parameter in LAG, LEAD or NTH_VALUE window functions, Firebird returns the error "Dynamic SQL Error; SQL error code = -804; Data type unknown [SQLState:HY004, ISC error code:335544573]"

For example:
select rdb$relation_name, lag(rdb$relation_name, ?) over (order by rdb$relation_name) from rdb$relations

The workaround is to add an explicit cast:
select rdb$relation_name, lag(rdb$relation_name, cast(? as bigint)) over (order by rdb$relation_name) from rdb$relations

The same applies to LEAD and NTH_VALUE.

Firebird should identify the parameter as BIGINT.

Commits: 7b0a29d e73973a

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 19, 2020

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 20, 2020

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 4.0 RC 1 [ 10930 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 23, 2020

Commented by: @pavel-zotov

Server version:
WI-V4.0.0.2234 Firebird 4.0 Release Candidate 1
WI-V4.0.0.2234 Firebird 4.0 Release Candidate 1/tcp (Image-PC1)/P16:C
WI-V4.0.0.2234 Firebird 4.0 Release Candidate 1/tcp (Image-PC1)/P16:C

select rdb$relation_name, lag(rdb$relation_name, ?) over (order by rdb$relation_name) from rdb$relations;

PLAN SORT (RDB$RELATIONS NATURAL)

--#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠

select rdb$relation_name, lead(rdb$relation_name, ?) over (order by rdb$relation_name) from rdb$relations;
Statement failed, SQLSTATE = HY004
Dynamic SQL Error
-SQL error code = -804
-Data type unknown
After line 4 in file c6421.sql

--#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠

select rdb$relation_name, nth_value(rdb$relation_name, ?) over (order by rdb$relation_name) from rdb$relations;

PLAN SORT (RDB$RELATIONS NATURAL)

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 23, 2020

Modified by: @pavel-zotov

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

QA Status: No test => Deferred

Test Details: See note 23/Oct/20 08:26 PM

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 24, 2020

Commented by: @mrotteveel

Should this be reopened if LEAD is still failing?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 26, 2020

Commented by: @asfernandes

> Should this be reopened if LEAD is still failing?

Fixed now.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 26, 2020

Modified by: @pavel-zotov

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

QA Status: Deferred => Done successfully

Test Details: See note 23/Oct/20 08:26 PM =>

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 26, 2020

Modified by: @pavel-zotov

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment