|
| 1 | +--echo # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc |
| 2 | +# |
| 3 | +# An include to print contents of I_S.ROCKSB_LOCKS |
| 4 | +# |
| 5 | +# Implicit "parameters" |
| 6 | +# - Currently it prints locks on t1.PRIMARY |
| 7 | +# |
| 8 | +# Explicit "parameter" variables: |
| 9 | +# - $TRX1_ID - print this transaction as "TRX1" |
| 10 | +# - $TRX2_ID - print this transaction as "TRX2" |
| 11 | +# |
| 12 | +# - $select_from_is_rowlocks_current_trx_only |
| 13 | +# - $order_by_rowkey |
| 14 | + |
| 15 | +--disable_query_log |
| 16 | +set @cf_id=(select column_family from information_schema.rocksdb_ddl |
| 17 | + where table_name='t1' and index_name='PRIMARY'); |
| 18 | +set @rtrx_id=(select transaction_id from information_schema.rocksdb_trx |
| 19 | + where thread_id=connection_id()); |
| 20 | +set @indexnr= (select lower( |
| 21 | + concat( |
| 22 | + lpad(hex(db_number),8,'0'), |
| 23 | + lpad(hex(index_number),8,'0') |
| 24 | + ) |
| 25 | + ) |
| 26 | + from information_schema.rocksdb_ddl |
| 27 | + where table_name='t1' and index_name='PRIMARY'); |
| 28 | + |
| 29 | +set @indexnr_next= (select lower( |
| 30 | + concat( |
| 31 | + lpad(hex(db_number),8,'0'), |
| 32 | + lpad(hex(index_number+1),8,'0') |
| 33 | + ) |
| 34 | + ) |
| 35 | + from information_schema.rocksdb_ddl |
| 36 | + where table_name='t1' and index_name='PRIMARY'); |
| 37 | + |
| 38 | +let $extra_where = where 1; |
| 39 | + |
| 40 | +if ($select_from_is_rowlocks_current_trx_only) |
| 41 | +{ |
| 42 | + let $extra_where = where transaction_id=(select transaction_id from information_schema.rocksdb_trx where connection_id()=thread_id); |
| 43 | +} |
| 44 | + |
| 45 | +# If TRX1_ID is not specified, get the current transaction: |
| 46 | +let $transaction_col= replace(transaction_id, @rtrx_id, "\$trx_id"); |
| 47 | +if ($TRX1_ID) |
| 48 | +{ |
| 49 | + let $transaction_col = replace(transaction_id, '$TRX1_ID', "\$TRX1_ID"); |
| 50 | +} |
| 51 | + |
| 52 | +if ($TRX2_ID) |
| 53 | +{ |
| 54 | + let $transaction_col = replace($transaction_col, '$TRX2_ID', "\$TRX2_ID"); |
| 55 | +} |
| 56 | + |
| 57 | +if ($order_by_rowkey) |
| 58 | +{ |
| 59 | + let $extra_order_by = ORDER BY 3,2; |
| 60 | +} |
| 61 | + |
| 62 | +if (!$order_by_rowkey) |
| 63 | +{ |
| 64 | + --sorted_result |
| 65 | +} |
| 66 | + |
| 67 | +eval select |
| 68 | + replace(column_family_id, @cf_id, "\$cf_id") as COLUMN_FAMILY_ID, |
| 69 | + $transaction_col as TRANSACTION_ID, |
| 70 | + replace( |
| 71 | + replace(`key`, @indexnr, '\${indexnr}'), |
| 72 | + @indexnr_next, '\${indexnr+1}' |
| 73 | + ) as `KEY`, |
| 74 | + mode |
| 75 | +from information_schema.rocksdb_locks $extra_where $extra_order_by; |
| 76 | + |
| 77 | +--enable_query_log |
0 commit comments