File: bug33657235.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (37 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--source include/count_sessions.inc

CREATE TABLE t1 (
  id INT PRIMARY KEY,
  u CHAR(2) NOT NULL,
  v CHAR(2) NOT NULL,
  UNIQUE INDEX by_u_1 (u(1)),
  INDEX by_v_1 (v(1))
);
INSERT INTO t1 VALUES (0,"aa","aa"),(10,"ee","ee"),(20,"oo","oo");

--connect (con1, localhost, root,,)
  BEGIN;
  # This query is supposed to place an S lock on (v="e",id=10) entry in secondary index
  # without placing any lock on the (id=10) entry in the clustered index.
  SELECT COUNT(*) FROM t1 FORCE INDEX ( by_v_1 ) WHERE v>"b" AND id<>10 FOR SHARE;

--connect (con2, localhost, root,,)
  BEGIN;
  # This query should try to insert a record to clustered index, then to by_u_1,
  # notice the conflict there, and perform a partial rollback, in which it should
  # first try to remove the record form by_u_1, realize there's nothing there to
  # remove, then move on to removing a record from by_v_1, notice that the record
  # for (v="e",id=10) already exists, attempt implicit to explicit lock conversion,
  # and realize that it actually doesn't have an implicit lock on this record, as
  # "ef" and "ee" both have the same prefix "e", so no change to by_v_1 was done.
  --error ER_DUP_ENTRY
  UPDATE t1 SET u="oo",v="ef" WHERE id=10;
  ROLLBACK;

--connection default
--disconnect con1
--disconnect con2

DROP TABLE t1;

--source include/wait_until_count_sessions.inc