Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: add_timestamp_column Query result is incorrect #1327

Closed
2 of 3 tasks
shangyanwen opened this issue Feb 23, 2023 · 1 comment
Closed
2 of 3 tasks

bug: add_timestamp_column Query result is incorrect #1327

shangyanwen opened this issue Feb 23, 2023 · 1 comment
Assignees
Labels
A-bug Something isn't working

Comments

@shangyanwen
Copy link
Contributor

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> select id,name,c1,c2,length(ctm2) from stu;
+----+--------------+------+-------+--------------+
| id | name         | c1   | c2    | length(ctm2) |
+----+--------------+------+-------+--------------+
|  1 | zhang fei    | NULL | NULL  |         NULL |
|  2 | zhao yun     | NULL | NULL  |         NULL |
|  3 | zhen ji      | NULL | NULL  |         NULL |
|  4 | zhou yu      | NULL | NULL  |         NULL |
|  5 | zhu ge liang | NULL | NULL  |         NULL |
|  6 | ma chao      | NULL | NULL  |         NULL |
|  7 | han mei mei  |   18 | NULL  |           19 |
|  8 | li lei       | NULL | a boy |           19 |
+----+--------------+------+-------+--------------+
8 rows in set (0.00 sec)

Expected behavior

mysql> select id,name,c1,c2,length(ctm2) from stu;
+----+--------------+------+-------+--------------+
| id | name         | c1   | c2    | length(ctm2) |
+----+--------------+------+-------+--------------+
|  1 | zhang fei    | NULL | NULL  |           19 |
|  2 | zhao yun     | NULL | NULL  |           19 |
|  3 | zhen ji      | NULL | NULL  |           19 |
|  4 | zhou yu      | NULL | NULL  |           19 |
|  5 | zhu ge liang | NULL | NULL  |           19 |
|  6 | ma chao      | NULL | NULL  |           19 |
|  7 | han mei mei  |   18 | NULL  |           19 |
|  8 | li lei       | NULL | a boy |           19 |
+----+--------------+------+-------+--------------+

How To Reproduce

create table stu(id int primary key, name char(20))engine=tianmu;

insert into stu(id, name) values(1, 'zhang fei');
insert into stu(id, name) values(2, 'zhao yun');
insert into stu(id, name) values(3, 'zhen ji');
insert into stu(id, name) values(4, 'zhou yu');
insert into stu(id, name) values(5, 'zhu ge liang');
insert into stu(id, name) values(6, 'ma chao');


alter table stu add c1 int;
alter table stu add column c2 char(90);
alter table stu add column ctm2 timestamp default current_timestamp();

insert into stu (id, name, c1) values (7, 'han mei mei', 18);
insert into stu (id, name, c2) values (8, 'li lei', 'a boy');
select id,name,c1,c2,length(ctm2) from stu;

Environment

5.7.36-StoneDB-v1.0.2

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

  • Yes, I will!
@shangyanwen shangyanwen added the A-bug Something isn't working label Feb 23, 2023
@shangyanwen shangyanwen added this to the stonedb_5.7_v1.0.3 milestone Feb 23, 2023
@wisehead wisehead self-assigned this Feb 23, 2023
@wisehead
Copy link
Collaborator

mysql> create table stu(id int primary key, name char(20))engine=tianmu;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> insert into stu(id, name) values(1, 'zhang fei');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stu(id, name) values(2, 'zhao yun');
Query OK, 1 row affected (0.01 sec)

mysql> insert into stu(id, name) values(3, 'zhen ji');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stu(id, name) values(4, 'zhou yu');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stu(id, name) values(5, 'zhu ge liang');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stu(id, name) values(6, 'ma chao');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> alter table stu add c1 int;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table stu add column c2 char(90);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table stu add column ctm2 timestamp default current_timestamp();
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> insert into stu (id, name, c1) values (7, 'han mei mei', 18);
Query OK, 1 row affected (0.00 sec)

mysql> insert into stu (id, name, c2) values (8, 'li lei', 'a boy');
Query OK, 1 row affected (0.00 sec)

mysql> select id,name,c1,c2,length(ctm2) from stu;
+----+--------------+------+-------+--------------+
| id | name | c1 | c2 | length(ctm2) |
+----+--------------+------+-------+--------------+
| 1 | zhang fei | NULL | NULL | 19 |
| 2 | zhao yun | NULL | NULL | 19 |
| 3 | zhen ji | NULL | NULL | 19 |
| 4 | zhou yu | NULL | NULL | 19 |
| 5 | zhu ge liang | NULL | NULL | 19 |
| 6 | ma chao | NULL | NULL | 19 |
| 7 | han mei mei | 18 | NULL | 19 |
| 8 | li lei | NULL | a boy | 19 |
+----+--------------+------+-------+--------------+
8 rows in set (0.00 sec)

the latest build has fixed the issue, @shangyanwen please verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants