⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rowlockbasic.out

📁 derby database source code.good for you.
💻 OUT
📖 第 1 页 / 共 2 页
字号:
ij> -- Very basic single user testing of row locking, verify that the right locks-- are obtained for simple operations.  This test only looks at table and-- row logical locks, it does not verify physical latches or lock ordering.-- The basic methodology is:--    start transaction--    simple operation--    print lock table which should match the master--    end transation-- set isolation to RR;0 rows inserted/updated/deletedij> run resource 'createTestProcedures.subsql';ij> CREATE FUNCTION  PADSTRING (DATA VARCHAR(32000), LENGTH INTEGER) RETURNS VARCHAR(32000) EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.Formatters.padString' LANGUAGE JAVA PARAMETER STYLE JAVA;0 rows inserted/updated/deletedij> CREATE PROCEDURE WAIT_FOR_POST_COMMIT() DYNAMIC RESULT SETS 0 LANGUAGE JAVA EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.T_Access.waitForPostCommitToFinish' PARAMETER STYLE JAVA;0 rows inserted/updated/deletedij> run resource 'LockTableQuery.subsql';ij> create view lock_table asselect     cast(username as char(8)) as username,    cast(t.type as char(8)) as trantype,    cast(l.type as char(8)) as type,    cast(lockcount as char(3)) as cnt,    mode,    cast(tablename as char(12)) as tabname,    cast(lockname as char(10)) as lockname,    state,    statusfrom     new org.apache.derby.diag.LockTable() l  right outer join new org.apache.derby.diag.TransactionTable() ton l.xid = t.xid where l.tableType <> 'S' and t.type='UserTransaction';0 rows inserted/updated/deletedij> --on l.xid = t.xid where l.tableType <> 'S' or l.tableType is null-- order by--     tabname, type desc, mode, cnt, lockname-- lock table with system catalog locks included.create view full_lock_table asselect     cast(username as char(8)) as username,    cast(t.type as char(8)) as trantype,    cast(l.type as char(8)) as type,    cast(lockcount as char(3)) as cnt,    mode,    cast(tablename as char(12)) as tabname,    cast(lockname as char(10)) as lockname,    state,    statusfrom     new org.apache.derby.diag.LockTable() l right outer join new org.apache.derby.diag.TransactionTable() ton l.xid = t.xid where l.tableType <> 'S' ;0 rows inserted/updated/deletedij> -- lock table with no join.create view lock_table2 asselect     cast(l.xid as char(8)) as xid,    cast(l.type as char(8)) as type,    cast(lockcount as char(3)) as cnt,    mode,    cast(tablename as char(12)) as tabname,    cast(lockname as char(10)) as lockname,    statefrom     new org.apache.derby.diag.LockTable() l  where l.tableType <> 'S' ;0 rows inserted/updated/deletedij> -- transaction table with no join.create view tran_table asselect     *from     new org.apache.derby.diag.TransactionTable() t ;0 rows inserted/updated/deletedij> call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize', '4096');0 rows inserted/updated/deletedij> autocommit off;ij> create table a (a int);0 rows inserted/updated/deletedij> commit;ij> ---------------------------------------------------------------------------------- Test insert into empty heap, should just get row lock on row being inserted--------------------------------------------------------------------------------insert into a values (1);1 row inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |1   |IX  |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(1,7)     |GRANT|ACTIVE  ij> commit;ij> ---------------------------------------------------------------------------------- Test insert into heap with one row, just get row lock on row being inserted--------------------------------------------------------------------------------insert into a values (2);1 row inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |1   |IX  |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(1,8)     |GRANT|ACTIVE  ij> commit;ij> drop table a;0 rows inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |3   |X   |*** TRANSIEN|Tablelock |GRANT|ACTIVE  ij> commit;ij> create table a (a int, b varchar(1000));0 rows inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |1   |X   |A           |Tablelock |GRANT|ACTIVE  ij> commit;ij> create index a_idx on a (a, b) ;0 rows inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |4   |S   |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|TABLE   |1   |X   |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|TABLE   |1   |X   |A           |Tablelock |GRANT|ACTIVE  ij> commit;ij> ---------------------------------------------------------------------------------- Test insert into empty btree, should just get row lock on row being -- inserted and an instant duration lock on "first key in table" row (id 3).--------------------------------------------------------------------------------insert into a values (1, PADSTRING('a',1000));1 row inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |2   |IX  |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(1,7)     |GRANT|ACTIVE  ij> commit;ij> ---------------------------------------------------------------------------------- Test insert into non-empty btree, should get row lock on row being -- inserted and an instant duration lock on the one before it.--------------------------------------------------------------------------------insert into a values (2, PADSTRING('b',1000));1 row inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |2   |IX  |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(1,8)     |GRANT|ACTIVE  ij> commit;ij> ---------------------------------------------------------------------------------- Cause split and check locks that are obtained as part of inserting after-- the split.  This causes the code to get a previous lock on a previous page.-- -- RESOLVE (mikem) - the row lock on (1,9) is a result of raw store getting-- a lock while it tries to fit the row on the original page record id, but-- there is not enough room, so it eventually allocates a new page/row and -- locks that one - but the old lock is left around.---- btree just before commit:-- leftmost leaf: (1,6), (1,7)-- next leaf:     (1,8), (2,6)--------------------------------------------------------------------------------insert into a values (3, PADSTRING('c',1000));1 row inserted/updated/deletedij> commit;ij> insert into a values (4, PADSTRING('d',1000));1 row inserted/updated/deletedij> select * from lock_table order by tabname, type desc, mode, cnt, lockname;USERNAME|TRANTYPE|TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE|STATUS  ---------------------------------------------------------------------------APP     |UserTran|TABLE   |2   |IX  |A           |Tablelock |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(1,10)    |GRANT|ACTIVE  APP     |UserTran|ROW     |1   |X   |A           |(2,6)     |GRANT|ACTIVE  ij> commit;ij> ---------------------------------------------------------------------------------- Cause an insert on a new page that inserts into the 1st slot on the btree-- page.---- btree just before commit:-- leftmost leaf: (1,6), (1,7)-- next leaf:     (2,7), (2,6)--------------------------------------------------------------------------------drop table a;0 rows inserted/updated/deletedij> create table a (a int, b varchar(1000));0 rows inserted/updated/deletedij> create unique index a_idx on a (a, b) ;0 rows inserted/updated/deletedij> insert into a values (1, PADSTRING('a',1000));1 row inserted/updated/deletedij> insert into a values (2, PADSTRING('b',1000));1 row inserted/updated/deletedij> insert into a values (3, PADSTRING('c',1000));1 row inserted/updated/deletedij> insert into a values (4, PADSTRING('d',1000));1 row inserted/updated/deleted

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -