daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE example (
  2.   `id` INTEGER NOT NULL PRIMARY KEY,
  3.   `some_val` VARCHAR(36),
  4.   `created_at` datetime
  5. );
  6.  
  7. INSERT INTO example
  8.   (`id`, `some_val`, `created_at`)
  9. VALUES
  10.   ('1', '33aa186d-e2de-4c41-aa50-000000000001', '2019-03-17 15:15:21.130'),
  11.   ('2', '33aa186d-e2de-4c41-aa50-000000000002', '2019-03-17 15:15:31.292'),
  12.   ('3', '33aa186d-e2de-4c41-aa50-000000000003', '2019-03-17 15:16:01.396');
  13.      
  14. BEGIN;
  15.      
  16. SELECT * FROM example WHERE id >= 1 AND id <= 3 FOR UPDATE;
  17.  
  18. | id  | some_val                             | created_at          |
  19. | --- | ------------------------------------ | ------------------- |
  20. | 1   | 33aa186d-e2de-4c41-aa50-000000000001 | 2019-03-17 15:15:21 |
  21. | 2   | 33aa186d-e2de-4c41-aa50-000000000002 | 2019-03-17 15:15:31 |
  22. | 3   | 33aa186d-e2de-4c41-aa50-000000000003 | 2019-03-17 15:16:01 |
  23.      
  24. SELECT * FROM performance_schema.data_locks;
  25.  
  26. | ENGINE | ENGINE_LOCK_ID | ENGINE_TRANSACTION_ID | THREAD_ID | EVENT_ID | OBJECT_SCHEMA | OBJECT_NAME | PARTITION_NAME | SUBPARTITION_NAME | INDEX_NAME | OBJECT_INSTANCE_BEGIN | LOCK_TYPE | LOCK_MODE | LOCK_STATUS | LOCK_DATA              |
  27. | ------ | -------------- | --------------------- | --------- | -------- | ------------- | ----------- | -------------- | ----------------- | ---------- | --------------------- | --------- | --------- | ----------- | ---------------------- |
  28. | INNODB | 2070:1063      | 2070                  | 48        | 4        | test          | example     |                |                   |            | 140108678336728       | TABLE     | IX        | GRANTED     |                        |
  29. | INNODB | 2070:2:4:2     | 2070                  | 48        | 4        | test          | example     |                |                   | PRIMARY    | 140108678333688       | RECORD    | X         | GRANTED     | 1                      |
  30. | INNODB | 2070:2:4:1     | 2070                  | 48        | 4        | test          | example     |                |                   | PRIMARY    | 140108678334032       | RECORD    | X         | GRANTED     | supremum pseudo-record |
  31. | INNODB | 2070:2:4:3     | 2070                  | 48        | 4        | test          | example     |                |                   | PRIMARY    | 140108678334032       | RECORD    | X         | GRANTED     | 2                      |
  32. | INNODB | 2070:2:4:4     | 2070                  | 48        | 4        | test          | example     |                |                   | PRIMARY    | 140108678334032       | RECORD    | X         | GRANTED     | 3                      |
  33.      
  34. ROLLBACK;
  35.      
  36. BEGIN;
  37.      
  38. SELECT * FROM example WHERE id IN (1,2,3) FOR UPDATE;
  39.  
  40. | id  | some_val                             | created_at          |
  41. | --- | ------------------------------------ | ------------------- |
  42. | 1   | 33aa186d-e2de-4c41-aa50-000000000001 | 2019-03-17 15:15:21 |
  43. | 2   | 33aa186d-e2de-4c41-aa50-000000000002 | 2019-03-17 15:15:31 |
  44. | 3   | 33aa186d-e2de-4c41-aa50-000000000003 | 2019-03-17 15:16:01 |
  45.      
  46. SELECT * FROM performance_schema.data_locks;
  47.  
  48. | ENGINE | ENGINE_LOCK_ID | ENGINE_TRANSACTION_ID | THREAD_ID | EVENT_ID | OBJECT_SCHEMA | OBJECT_NAME | PARTITION_NAME | SUBPARTITION_NAME | INDEX_NAME | OBJECT_INSTANCE_BEGIN | LOCK_TYPE | LOCK_MODE | LOCK_STATUS | LOCK_DATA |
  49. | ------ | -------------- | --------------------- | --------- | -------- | ------------- | ----------- | -------------- | ----------------- | ---------- | --------------------- | --------- | --------- | ----------- | --------- |
  50. | INNODB | 2071:1063      | 2071                  | 48        | 9        | test          | example     |                |                   |            | 140108678336728       | TABLE     | IX        | GRANTED     |           |
  51. | INNODB | 2071:2:4:2     | 2071                  | 48        | 9        | test          | example     |                |                   | PRIMARY    | 140108678333688       | RECORD    | X         | GRANTED     | 1         |
  52. | INNODB | 2071:2:4:3     | 2071                  | 48        | 9        | test          | example     |                |                   | PRIMARY    | 140108678333688       | RECORD    | X         | GRANTED     | 2         |
  53. | INNODB | 2071:2:4:4     | 2071                  | 48        | 9        | test          | example     |                |                   | PRIMARY    | 140108678333688       | RECORD    | X         | GRANTED     | 3         |
  54.      
  55. ROLLBACK;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top