Re: The same result for with SPACE and without SPACE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


> On Jun 14, 2023, at 4:31 PM, M Sarwar <sarwarmd02@xxxxxxxxxxx> wrote:
> I expect this to behave the same way whether it comes from CHAR or VARCHAR.

Why would you expect that??? CHAR explicitly means that:

1) shorter strings will be space-padded to the given length
2) if a string is presented with spaces making it longer, it will be truncated

Putting it all together, it implies:

3) trailing spaces are semantically meaningless

Anyway, the closest I could to finding a reference on comparison behavior for this case states: "The ANSI standard requires padding for the character strings used in comparisons so that their lengths match before comparing them."

And there you go, you used CHAR(10), so all values in the table are space-padded to length 10, so for comparison *any* value will be space-padded to 10.

[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux