BUG #17664: The subsctring() function with the char() text type does not work correctly

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #17664: The subsctring() function with the char() text type does not work correctly
Дата
Msg-id 17664-cdd65e73c6ebcdc4@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #17664: The subsctring() function with the char() text type does not work correctly
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17664
Logged by:          Evgenii Timofeev
Email address:      snztim@yandex.ru
PostgreSQL version: 15.0
Operating system:   ALT Linux 10 (ALT Sisyphus 10.3.1)
Description:

Hi!

PostgreSQL version:
PostgreSQL 15.0 on x86_64-pc-linux-gnu, compiled by x86_64-alt-linux-gcc
(GCC) 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt2), 64-bit

The situation is as follows:
First, we declare a char(10) text variable with the value 'abc' assigned to
it and a varchar(12) text variable within an anonymous block.
Within the body of the anonymous block we saddle a varchar(12) variable with
a char(10) variable and print the result.
The result will be valid data (example 1).

If we do the same, but add the substring() function to concat(), the result
will be incorrect (example 2).
As seen in example 2, the function substring(), which should have printed 4
characters, has printed only 3.

Please tell me why the result is not correct?

Example 1:
do $$
declare
    M1 char(10) := 'abc';
    M2 varchar(12);
begin
    M2 := concat('-',M1,'-');
    raise info '%', M2;
end;
$$;
Execution result:  -abc       -

Example 2:
do $$
declare
    M1 char(10) := 'abc';
    M2 varchar(12);
begin
    M2 := concat('-',substring(M1,1,4),'-');
    raise info '%', M2;
end;
$$;
Execution result:  -abc-


В списке pgsql-bugs по дате отправления:

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17663: Connect to the database through jdbc, call the stored procedure containing the rollback statement,
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17665: pg_stat_statements useless with variable number of parameters in IN close