pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #17664: The subsctring() function with the char() text type does not work correctly
2+ messages / 2 participants
[nested] [flat]
* BUG #17664: The subsctring() function with the char() text type does not work correctly
@ 2022-10-26 09:00 PG Bug reporting form <noreply@postgresql.org>
2022-10-27 12:31 ` Re: BUG #17664: The subsctring() function with the char() text type does not work correctly David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2022-10-26 09:00 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: snztim@yandex.ru
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-
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #17664: The subsctring() function with the char() text type does not work correctly
2022-10-26 09:00 BUG #17664: The subsctring() function with the char() text type does not work correctly PG Bug reporting form <noreply@postgresql.org>
@ 2022-10-27 12:31 ` David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: David G. Johnston @ 2022-10-27 12:31 UTC (permalink / raw)
To: snztim@yandex.ru; pgsql-bugs@lists.postgresql.org
On Thu, Oct 27, 2022 at 5:02 AM PG Bug reporting form <
noreply@postgresql.org> wrote:
> 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!
>
> 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?
>
Because substring only works for text inputs and produces text output so
your insignificant whitespace is thrown away if you pass data through that
function.
It isn't a bug but a missing feature. Given that the project basically
doesn't recommend people use char this gap in functionality isn't
surprising.
David J.
Note that concat is defined polymorphically.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-10-27 12:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 09:00 BUG #17664: The subsctring() function with the char() text type does not work correctly PG Bug reporting form <noreply@postgresql.org>
2022-10-27 12:31 ` David G. Johnston <david.g.johnston@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox