BPCHAR description in 8.3. Character Types is misleading and incomplete
| От | PG Doc comments form |
|---|---|
| Тема | BPCHAR description in 8.3. Character Types is misleading and incomplete |
| Дата | |
| Msg-id | 176044409338.770.16064383081308443747@wrigleys.postgresql.org обсуждение исходный текст |
| Ответы |
Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
|
| Список | pgsql-docs |
The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/18/datatype-character.html Description: The description of BPCHAR in section 8.3. Character Types is misleading and incomplete. The first problem is that, contrary to table 8.4, BPCHAR is not actually blank-trimmed. The wording "as-if-blank-trimmed" or "blank-ignoring" may be better suited here. The following query explains the problem: SELECT bpchar_val, length(bpchar_val) as bplen, concat('[', bpchar_val, ']') as bpbrack , varchar_val, length(varchar_val) as vclen, concat('[', varchar_val, ']') as vcbrack FROM (VALUES ('abc '::bpchar, 'abc '::varchar), ('abc '::bpchar, 'abc'::varchar), ('abc'::bpchar, 'abc '::varchar), ('abc'::bpchar, 'abc'::varchar)) AS bpchar_test (bpchar_val, varchar_val) WHERE bpchar_val = varchar_val; As can be seen, it returns four rows (so, it indeed treats values that differ only in number of trailing spaces as equal, regardless of the type on the other side, and the length of bpchar_val is always 3 in all 4 rows - trailing spaces are ignored in comparison. But the bpbrack column shows that actual value is NOT trimmed: two of four rows have '[abc ]' value (with 3 spaces before the closing bracket). The example above also illustrate the need of more detailed explanation of how BPCHAR actually behaves in different situation, particularly, in which contexts trailing blanks are ignored (comparison, length, what else?) and in which they are still significant (displaying, client interfaces, concatenation, what else?). The second problem is that 'Tip' before the example 8.1 mentions only three types, also in a misleading way: 'There is no performance difference among these three types' - as if there were only 3, not 4 distinct types.
В списке pgsql-docs по дате отправления: