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

Error subquery returns more than 1 row for insert on dup #10151

Closed
jackysp opened this issue Apr 15, 2019 · 4 comments
Closed

Error subquery returns more than 1 row for insert on dup #10151

jackysp opened this issue Apr 15, 2019 · 4 comments
Labels
challenge-program help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@jackysp
Copy link
Member

jackysp commented Apr 15, 2019

Description

Bug Report
Please answer these questions before submitting your issue. Thanks!

What did you do?
If possible, provide a recipe for reproducing the error.
CREATE TABLE t1(a INTEGER);
CREATE TABLE t11(a INTEGER primary key);
CREATE TABLE t2(b INTEGER);
INSERT INTO t2 VALUES (1),(1);

INSERT INTO t1(a) VALUES (1)
ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);

INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);

DROP TABLE t1, t2;
What did you expect to see
MySQL behavior:
for inserting into t1

INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
Query OK, 1 row affected (0.01 sec)
INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
Query OK, 1 row affected (0.01 sec)

for inserting into t11
INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
Query OK, 1 row affected (0.02 sec)

INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row

TiDB behvaior:
for inserting into t1
mysql> INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row
mysql> INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row

for inserting into t11
mysql> INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row
Create issue (#10151) from GitHub user jackysp at 16:26 PM, April 15 2019

SIG slack channel

#sig-planner

Score

  • 300

Mentor

@jackysp jackysp added the type/bug The issue is confirmed as a bug. label Apr 15, 2019
@ghost
Copy link

ghost commented Jul 13, 2020

Confirming this still exists in master:

DROP TABLE IF EXISTS t1, t11, t2;
CREATE TABLE t1(a INTEGER);
CREATE TABLE t11(a INTEGER primary key);
CREATE TABLE t2(b INTEGER);
INSERT INTO t2 VALUES (1),(1);

INSERT INTO t1(a) VALUES (1)
ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);

INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);


..

mysql> INSERT INTO t1(a) VALUES (1)
    -> ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row
mysql> 
mysql> INSERT INTO t11(a) VALUES (1) ON DUPLICATE KEY UPDATE a= (SELECT b FROM t2);
ERROR 1105 (HY000): subquery returns more than 1 row

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-750-g8a661044c
Edition: Community
Git Commit Hash: 8a661044cedf8daad1de4fbf79a390962b6f6c3b
Git Branch: master
UTC Build Time: 2020-07-10 10:52:37
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@zz-jason zz-jason added the sig/planner SIG: Planner label Jul 14, 2020
@lzmhhh123 lzmhhh123 added challenge-program help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Oct 30, 2020
@dyzsr
Copy link
Contributor

dyzsr commented Nov 6, 2020

/assign

@winoros
Copy link
Member

winoros commented Nov 23, 2021

should fixed by #29270

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

7 participants