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: explicit txn is not handled properly in mysql handler #15584

Closed
dantengsky opened this issue May 20, 2024 · 0 comments · Fixed by #15583
Closed

bug: explicit txn is not handled properly in mysql handler #15584

dantengsky opened this issue May 20, 2024 · 0 comments · Fixed by #15583

Comments

@dantengsky
Copy link
Member

Summary

explicit txn is not handled properly in mysql handler. (http handler/bendsql work as expected)

how to reproduce:

create or replace database poc2;
use poc2;


create or replace table poc2.t_1 (str varchar);
begin;
insert into poc2.t_1 (str) values ('a'), ('b');
select 1/0;
commit;
select * from poc2.t_1; // <- expects empty resultset

mysql hander fails the above test:

mysql> create or replace database poc2;
Query OK, 0 rows affected (0.20 sec)

mysql> use poc2;
Database changed
mysql>
mysql>
mysql> create or replace table poc2.t_1 (str varchar);
Query OK, 0 rows affected (0.12 sec)

mysql> begin;
Query OK, 0 rows affected (0.03 sec)

mysql> insert into poc2.t_1 (str) values ('a'), ('b');
Query OK, 2 rows affected (0.21 sec)

mysql> select 1/0;
ERROR 1105 (HY000): BadArguments. Code: 1006, Text = error:
  --> SQL:1:9
  |
1 | select 1/0
  |         ^ divided by zero while evaluating function `divide(1, 0)`

.
mysql> commit;
Query OK, 0 rows affected (0.08 sec)

mysql> select * from poc2.t_1;
+------+
| str  |
+------+
| a    |
| b    |
+------+
2 rows in set (0.17 sec)
Read 2 rows, 27.00 B in 0.036 sec., 56.2 rows/sec., 758.76 B/sec.

bendsql(http) ok:

root@localhost:8000/poc2> create or replace database poc2;

CREATE
OR REPLACE DATABASE poc2

root@localhost:8000/poc2> use poc2;


USE poc2

root@localhost:8000/poc2> create or replace table poc2.t_1 (str varchar);


CREATE
OR REPLACE TABLE poc2.t_1 (str varchar)

root@localhost:8000/poc2> begin;

BEGIN

root@localhost:8000/poc2> insert into poc2.t_1 (str) values ('a'), ('b');

INSERT INTO
  poc2.t_1 (str)
VALUES
  ('a'),
  ('b')

root@localhost:8000/poc2> select 1/0;
error: APIError: ResponseError with 1006: divided by zero while evaluating function `divide(1, 0)`
root@localhost:8000/poc2> commit;

COMMIT

root@localhost:8000/poc2> select * from poc2.t_1;

SELECT
  *
FROM
  poc2.t_1

0 row read in 0.073 sec. Processed 0 row, 0 B (0 row/s, 0 B/s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant