blob: 4493e4d91f3b44290c5b3ec999c9069e8ee1cd36 [file] [log] [blame]
--
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--------------------------------------------------------------------------------
-- Test 0.1: ddl interaction
--------------------------------------------------------------------------------
-- create 1st table. Drop the table, which will get regular X locks on the
-- rows in the system catalogs (which are different than insert locks).
set connection create1;
create table create1 (a int);
drop table create1;
-- create 2nd table
-- The following should not block now that ddl work is done under
-- repeatable read no matter what the user isolation level.
set connection create2;
create table create2 (a int);
set connection create1;
commit;
set connection create2;
commit;
--------------------------------------------------------------------------------
-- Test 0.2: normal user data, previous key must block on serializable read,
-- if create1 session isolation is serializable, otherwise it will
-- not block.
--------------------------------------------------------------------------------
-- get lock on range of keys 0->10, iso level determines if phantoms allowed.
set connection create1;
select * from data where keycol <= 10;
-- the following must block if create1 isolation level disallows phantoms
set connection create2;
insert into data values (5, '50');
commit;
-- now do the select again from session one to see if a phantom showed up.
set connection create1;
select * from data where keycol <= 10;
set connection create1;
commit;
delete from data where keycol = 5;
commit;
set connection create2;
commit;
--------------------------------------------------------------------------------
-- Test 0.3: normal user data, previous key must block on serializable delete,
-- if create1 session isolation is serializable, otherwise it will
-- not block.
--------------------------------------------------------------------------------
-- get lock on range of keys 0->10, iso level determines if phantoms allowed.
set connection create1;
delete from data where keycol <= 10;
-- the following must block if create1 isolation level disallows phantoms
set connection create2;
insert into data values (6, '60');
commit;
-- now do the select again from session one to see if a phantom showed up.
set connection create1;
select * from data where keycol <= 10;
set connection create1;
commit;
delete from data where keycol = 6;
commit;
set connection create2;
commit;