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

System function RDB$ROLE_IN_USE cannot take long role names [CORE5593] #5859

Closed
firebird-automations opened this issue Aug 7, 2017 · 7 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @helebor

Function RDB$ROLE_IN_USE takes a varchar(32), which is meant to be a role name. Varchar(32) won't be long enough to take
a longer role name.

Commits: 61b4bf0

====== Test Details ======

We also have to check cases when role contains NON-ASCII characters but currently this is impossible.
Exception like:

  Statement failed, SQLSTATE = 22001
  arithmetic exception, numeric overflow, or string truncation
  \-string right truncation
  \-expected length 63, actual 79

===
- is raised when non-ascii role contains only ~40 *characters* and connection charset = UTF8.
Sent letter to Alex, 23.06.2018 09:21, waiting for reply.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

Version: 4.0 Alpha 1 [ 10731 ]

Version: 4.0 Initial [ 10621 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

I don't see this issue in the code. All built-in functions don't have declared parameter types/lengths, they accept whatever is passed. The problem is whether the argument can be converted to the expected datatype. RDB$ROLE_IN_USE expects a string of arbitrary length, I don't see any limit implied there.

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

When long role name is used RDB$ROLE_IN_USE incorrectly returns false even in a case RDB$ROLE_IN_USE(current_role)

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

There were 2 issues - first, varchar(32) in documentation, which was obviously wrong limit, Dmitry is right, built-in functions accept whatever is passed. But there was one more issue - case sensitivity. I've blindly uppercased role name what is definitely wrong - we may have roles with lower case letters, moreover, we may have SOMEROLE and SomeRole, and that will be 2 different roles.

The small problem with this function is that we can't use double quotes to mark names of case-sensitive roles - we should be able to accept strings returned by CURRENT_ROLE, values in RDB$ROLE_NAME field, and they all do not contain double quotes. Therefore the only working solution is to always enter role name case sensitive.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

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

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 1 [ 10750 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test => Done with caveats

Test Details: We also have to check cases when role contains NON-ASCII characters but currently this is impossible.
Exception like:

  Statement failed, SQLSTATE = 22001
  arithmetic exception, numeric overflow, or string truncation
  \-string right truncation
  \-expected length 63, actual 79

===
- is raised when non-ascii role contains only ~40 *characters* and connection charset = UTF8.
Sent letter to Alex, 23.06.2018 09:21, waiting for reply.

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

No branches or pull requests

2 participants