Skip to content

bug: length() funciton in tianmu return different results with mysql #1095

@davidshiz

Description

@davidshiz

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

mysql> CREATE TABLE tin3(id int,val TINYINT(10) ZEROFILL);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO tin3 VALUES(1,12),(2,7),(4,101);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM tin3;
+------+------------+
| id   | val        |
+------+------------+
|    1 | 0000000012 |
|    2 | 0000000007 |
|    4 | 0000000101 |
+------+------------+
3 rows in set (0.00 sec)

mysql> SELECT LENGTH(val) FROM tin3 WHERE id=2;
+-------------+
| LENGTH(val) |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)

Expected behavior

mysql> SELECT LENGTH(val) FROM tin3 WHERE id=2;
+-------------+
| LENGTH(val) |
+-------------+
|          10 |
+-------------+
1 row in set (0.00 sec)

How To Reproduce

CREATE TABLE tin3(id int,val TINYINT(10) ZEROFILL);
INSERT INTO tin3 VALUES(1,12),(2,7),(4,101);
SELECT * FROM tin3;
SELECT LENGTH(val) FROM tin3 WHERE id=2;

Environment

root@ub01:/stonedb57/install# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: e395f89e1
        Last commit time: Date:   Tue Dec 6 01:04:24 2022 +0800
        Build time: Date: Tue Dec  6 16:03:58 CST 2022
root@ub01:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!

Metadata

Metadata

Assignees

Labels

A-bugSomething isn't workingB-storagedata type, data storage, insert,update,delete, transactionsprio: normalMedium priority

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions