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

Trailing spaces in varchar in where [CORE6201] #6446

Closed
firebird-automations opened this issue Dec 4, 2019 · 6 comments
Closed

Trailing spaces in varchar in where [CORE6201] #6446

firebird-automations opened this issue Dec 4, 2019 · 6 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Alexander Muylaert (alexander_gonline.be)

Hi

I really was not expecting this statement to be true. As I understand it, trailing spaces are ignored at all levels. But I cannot think of any good reason why this is what it is. I noticed ms-sql has it as well.

select cast('dog ' as varchar(200)) = trim(cast('dog ' as varchar(200)))
from RDB$DATABASE

Thanks for answering

Alexander

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

SQL standard: collations have "PAD" attribute by default.

@firebird-automations
Copy link
Collaborator Author

Commented by: Alexander Muylaert (alexander_gonline.be)

Thanks

For the sake of documentation if somebody pops up on this question

https://crate.io/docs/sql-99/en/latest/chapters/22.html

A Collation's PAD characteristic affects the result when two strings of unequal size are compared. If the Collation in effect for a comparison has the PAD SPACE characteristic, the shorter string is padded with spaces (on the right) until it's the same length as the larger string; then the comparison is done. If the Collation in effect for a comparison has the NO PAD characteristic, the shorter string is padded with some other character before the comparison is done. In this case, the result is that the shorter comparand will evaluate as less than the longer comparand if they contain the same characters for their common length - see our chapter on character strings.

@firebird-automations
Copy link
Collaborator Author

Commented by: Alexander Muylaert (alexander_gonline.be)

Out of curiosity

Isn't a comparison of a string of 3 chars with a string of 6000 chars then a horrible thing?

I don't very often use this kind of string stuff, but most people do have an index on zip or email somewhere in their project...

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

This isn't a suitable topic for the tracker. Please post your question to firebird-support.

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

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

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

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

1 participant