File: prepare_secondary_index.inc

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 (31 lines) | stat: -rw-r--r-- 1,236 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
# This table scheme is intended to have these properties:
# 1. it has a secondary index on one column
# 2. the secondary index does not depend on one of columns
# In our case unique key on c1 does not depend on c2, and we will use this to
# check for bugs in handling implicit locks on secondary indexes,
# by UPDATEing c2, and checking if the algorithm believes it caused
# change to c1, while it obviously didn't.

CREATE TABLE t1(
  id INT NOT NULL,
  c1 INT NOT NULL,
  c2 INT NOT NULL,
  PRIMARY KEY (id DESC),
  UNIQUE KEY(c1)
) Engine=InnoDB;

INSERT INTO t1 (id,c1,c2) VALUES (0,0,0),(1,1,1),(3,3,3);

# lock_sec_rec_some_has_impl has some heuristics which try to avoid
# invoking costly algorithm, by performing some easy checks first,
# one of which is to compare page_get_max_trx_id(page) with
# trx_rw_min_trx_id(). To help us pass through this check, we keep
# create a rw-transaction from `view_keeper` and keep it open, and then we
# also modify the secondary index page from `default`.
# Keep trx_rw_min_trx_id() low:
--connect (view_keeper, localhost, root,,)
  BEGIN;
  UPDATE t1 SET c2=13 WHERE id = 3;
# Make page_get_max_trx_id(block->frame) updated:
--connection default
  INSERT INTO t1 (id,c1,c2) VALUES (4,4,4);