1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-29646: sformat('Num [{:20}]', 42) gives incorrect result in view

The problem is that sformat does not assign the enough space for the
result string. The result string is allocated with the max_length of
argument, but the correst max_length should be based on the format
string.

The patch fixes the problem by using MAX_BLOB_WIDTH to assign length
This commit is contained in:
Weijun Huang
2023-03-31 01:18:24 +02:00
committed by Daniel Black
parent 7d967423fe
commit f288d42cdb
3 changed files with 46 additions and 2 deletions

View File

@ -253,3 +253,24 @@ set names latin1;
echo #;
echo # End of 10.7 tests;
echo #;
echo #;
echo # Start of 10.8 tests;
echo #;
echo #;
echo # MDEV-29646 sformat('Num [{:20}]', 42) gives incorrect result in view;
echo #;
create view v1 as select sformat('Num [{:20}]', 42);
select * from v1;
drop view v1;
create view v1 as SELECT sformat('Square root of [{:d}] is [{:.20}]', 2, sqrt(2));
select * from v1;
drop view v1;
create table t1 (a text, b int, c text);
insert t1 values ('[{} -> {}]', 10, '{}'), ('[{:20} <- {}]', 1, '{:30}');
select sformat(a,b,c) from t1;
drop table t1;