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: Have to restore default values after update ON DUPLICATE KEY,Execution result error #508

Closed
1 task
shangyanwen opened this issue Sep 19, 2022 · 1 comment
Assignees
Labels
A-bug Something isn't working

Comments

@shangyanwen
Copy link
Contributor

Describe the problem

create table t1 (f1 int)engine=tianmu;
create table t2 (ff1 int unique, ff2 int default 1)engine=tianmu;
insert into t1 values (1),(1),(2);
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;

select * from t2;
#Incorrect test results
+------+------+
| ff1  | ff2  |
+------+------+
|    1 |    1 |
|    1 |    1 |
|    2 |    1 |
+------+------+

drop table t1, t2;

Expected behavior

# Correct test results(note:Innodb test verification, test results are as follows)
select * from t2;
+------+------+
| ff1  | ff2  |
+------+------+
|    1 |    2 |
|    2 |    1 |
+------+------+

How To Reproduce

create table t1 (f1 int)engine=tianmu;
create table t2 (ff1 int unique, ff2 int default 1)engine=tianmu;
insert into t1 values (1),(1),(2);
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
select * from t2;
drop table t1, t2;

Environment

[root@dev bin]# ./mysqld --version
./mysqld  Ver 5.7.36_v1.0.0_beta-StoneDB for Linux on x86_64 (build-)
build information as follow: 
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7
        Branch name: stonedb-5.7
        Last commit ID: eed32f6
        Last commit time: Date:   Wed Aug 3 11:19:48 2022 +0800
        Build time: Date: Wed Aug  3 13:01:31 CST 2022

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 Sep 19, 2022
@shangyanwen shangyanwen added this to the stonedb_5.7_v1.0.1 milestone Sep 19, 2022
@lylth
Copy link
Contributor

lylth commented Oct 21, 2022

Tianmu engine does not support unique index

mysql> create table t2 (ff1 int unique, ff2 int default 1)engine=tianmu;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1),(1),(2);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> insert into t2(ff1) select f1 from t1
    -> ;
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from t2;
+------+------+
| ff1  | ff2  |
+------+------+
|    1 |    1 |
|    1 |    1 |
|    2 |    1 |
+------+------+
3 rows in set (0.02 sec)

Innodb engine does not support unique index.

mysql> create table t1 (f1 int)engine=innodb;
Query OK, 0 rows affected (0.08 sec)

mysql> create table t2 (ff1 int unique, ff2 int default 1)engine=innodb;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t1 values (1),(1),(2);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> insert into t2(ff1) select f1 from t1;
ERROR 1062 (23000): Duplicate entry '1' for key 'ff1'

@lylth lylth closed this as completed Oct 21, 2022
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