[MDEV-20292] REPEAT(x,-1) returns a wrong data type Created: 2019-08-08  Updated: 2019-08-09  Resolved: 2019-08-08

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.3.18, 10.4.8

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-20085 Negative count causes SQL repeat() to... Closed
Relates
relates to MDEV-20303 SPACE(-1) returns a wrong data type Closed

 Description   

CREATE OR REPLACE TABLE t1 (i BIGINT);
INSERT INTO t1 VALUES (42);
CREATE OR REPLACE TABLE t2 AS SELECT
  REPEAT(i,0) AS c0,
  REPEAT(i,-1) AS c1
FROM t1;
SHOW CREATE TABLE t2;

+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `c0` char(0) CHARACTER SET utf8 DEFAULT NULL,
  `c1` longtext CHARACTER SET utf8 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+

It's expected that c1 also creates a column of the `char(0)` data type.

This problem causes ColumnStore to crash, see MDEV-20085 for details.


Generated at Thu Feb 08 08:58:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.