[MDEV-8049] name_const() is not consistent about its signess Created: 2015-04-24  Updated: 2018-06-22  Resolved: 2018-06-22

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.3.8

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


 Description   

$ mysql-tmp --column-type-info test
...
mysql> SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2;
...
Field   1:  `c1`
Type:       LONGLONG
Flags:      NOT_NULL UNSIGNED BINARY NUM 
...
Field   2:  `c2`
Type:       LONGLONG
Flags:      BINARY NUM
...
+----------------------+----------------------+
| c1                   | c2                   |
+----------------------+----------------------+
| 18446744073709551615 | 18446744073709551615 |
+----------------------+----------------------

Notice, metadata says LONGLONG UNSIGNED for c1 but LONGLONG SIGNED for c2, but return values are both unsigned.

Another example of incorrect behaviour:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 AS SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2;
SHOW WARNINGS;
SHOW CREATE TABLE t1;

The above script returns

+---------+------+---------------------------------------------+
| Level   | Code | Message                                     |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'c2' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)
 
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                               |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` bigint(20) unsigned NOT NULL DEFAULT '0',
  `c2` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+

The expected result is to have unsigned flag in both fields.


Generated at Thu Feb 08 07:24:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.