Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c57d11

Browse files
committed
Add C comment about problems with CHAR() space trimming
1 parentb8f00a4 commit9c57d11

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/backend/utils/adt/varchar.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,18 @@ bpcharcmp(PG_FUNCTION_ARGS)
846846
len2;
847847
intcmp;
848848

849+
/*
850+
* Trimming trailing spaces off of both strings can cause a string
851+
* with a character less than a space to compare greater than a
852+
* space-extended string, e.g. this returns false:
853+
*SELECT E'ab\n'::CHAR(10) < E'ab '::CHAR(10);
854+
* even though '\n' is less than the space if CHAR(10) was
855+
* space-extended. The correct solution would be to trim only
856+
* the longer string to be the same length of the shorter, if
857+
* possible, then do the comparison. However, changing this
858+
* might break existing indexes, breaking binary upgrades.
859+
* For details, see http://www.postgresql.org/message-id/CAK+WP1xdmyswEehMuetNztM4H199Z1w9KWRHVMKzyyFM+hV=zA@mail.gmail.com
860+
*/
849861
len1=bcTruelen(arg1);
850862
len2=bcTruelen(arg2);
851863

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp