01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.util.T_Access
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.util;
23:
24: import org.apache.derby.iapi.error.StandardException;
25: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
26: import org.apache.derby.iapi.sql.conn.ConnectionUtil;
27: import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory;
28: import org.apache.derby.iapi.store.access.TransactionController;
29: import org.apache.derby.iapi.store.access.AccessFactory;
30: import org.apache.derby.iapi.error.PublicAPI;
31: import java.sql.SQLException;
32:
33: /**
34: This class provides mechanism to call access Factory methods from sql-j.
35: */
36:
37: public class T_Access {
38:
39: public static AccessFactory getAccessFactory() throws SQLException {
40: LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
41: LanguageConnectionFactory lcf = lcc
42: .getLanguageConnectionFactory();
43: return (AccessFactory) lcf.getAccessFactory();
44: }
45:
46: /*
47: *Followng call waits until post commit thread queue is empty.
48: *This call is useful for tests which checks for the following type
49: *of cases:
50: * 1) Checking for space usage after delete statements
51: * 2) Checking for locks when delete statements are involved,
52: * because post commit thread might be holding locks when
53: * checking for snap shot of locks, so best thing to do
54: * to get consistent results is to call the following function
55: * before checking for locks (eg: store/updatelocks.sql)
56: * 3) Depending on whethere the space is not released yet by the post commit thread
57: * for commited deletes or not can change the order of rows in the heap.
58: * In such cases , it is good idea to call this method before doing
59: * inserts(Even adding/dropping constraints can have effect because they
60: * do inderectly deletes/inserts on system tables.) eg: lang/fk_nonsps.sql
61: */
62: public static void waitForPostCommitToFinish() throws SQLException {
63: AccessFactory af = getAccessFactory();
64: af.waitForPostCommitToFinishWork();
65: }
66: }
|