[MDEV-12546] Wrong metadata or data type for string user variables Created: 2017-04-21  Updated: 2017-05-24  Resolved: 2017-05-24

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.3.1

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

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

DROP TABLE IF EXISTS t1;
SET @a='test';
SELECT @a;

Field   1:  `@a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       MEDIUM_BLOB
Collation:  utf8_general_ci (33)
Length:     50331645
Max_length: 4
Decimals:   31
Flags:      

+------+
| @a   |
+------+
| test |
+------+

Notice, MEDIUM_BLOB is displayed as the data type.

Now I create a table:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 AS SELECT @a;
SHOW CREATE TABLE t1; 

+-------+-----------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                  |
+-------+-----------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `@a` longtext CHARACTER SET utf8
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------+

Notice, a LONGTEXT column was created.

There is a mismatch:

  • Either LONG_BLOB should be reported in the metadata
  • Or a MEDIUMBLOB column should be created
  • Or perhaps a smaller data type could be used, e.g. BLOB or TINYBLOB, with the corresponding data type displayed in metadata.

Update:
The data type should be LONGBLOB/LONGTEXT, because user variables can be modified on the fly. So the metadata should by synchronized with the data type and report LONG_BLOB.

The same problem is repeatable with Item_func_set_user_var:

CREATE OR REPLACE TABLE t1 AS SELECT @a:=1;
DESCRIBE t1;

+-------+--------+------+-----+---------+-------+
| Field | Type   | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------+
| @a:=1 | int(1) | NO   |     | 0       |       |
+-------+--------+------+-----+---------+-------+

But if I start mysql --column-type-info test and do:

SELECT @a:=1;

Field   1:  `@a:=1`
Type:       LONGLONG
Length:     3
Max_length: 1

Notice, result set metadata is wrong. It should report LONG rather than LONGLONG.



 Comments   
Comment by Alexander Barkov [ 2017-05-24 ]

Pushed into bb-10.2-ext

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