~ubuntu-branches/ubuntu/maverick/hsqldb/maverick

« back to all changes in this revision

Viewing changes to src/org/hsqldb/TransactionManager.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-09-26 11:47:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060926114749-3jd0utm7w21x1iqt
Tags: 1.8.0.5-2ubuntu1
* Synchronise with Debian unstable; remaining changes:
  - build using java-gcj-compat.
* libhsqldb-java: Add gij as alternative dependency.
* Build a libhsqldb-java-gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2001-2005, The HSQL Development Group
2
 
 * All rights reserved.
3
 
 *
4
 
 * Redistribution and use in source and binary forms, with or without
5
 
 * modification, are permitted provided that the following conditions are met:
6
 
 *
7
 
 * Redistributions of source code must retain the above copyright notice, this
8
 
 * list of conditions and the following disclaimer.
9
 
 *
10
 
 * Redistributions in binary form must reproduce the above copyright notice,
11
 
 * this list of conditions and the following disclaimer in the documentation
12
 
 * and/or other materials provided with the distribution.
13
 
 *
14
 
 * Neither the name of the HSQL Development Group nor the names of its
15
 
 * contributors may be used to endorse or promote products derived from this
16
 
 * software without specific prior written permission.
17
 
 *
18
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 
 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22
 
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 
 */
30
 
 
31
 
 
 
1
/* Copyright (c) 2001-2005, The HSQL Development Group
 
2
 * All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 *
 
7
 * Redistributions of source code must retain the above copyright notice, this
 
8
 * list of conditions and the following disclaimer.
 
9
 *
 
10
 * Redistributions in binary form must reproduce the above copyright notice,
 
11
 * this list of conditions and the following disclaimer in the documentation
 
12
 * and/or other materials provided with the distribution.
 
13
 *
 
14
 * Neither the name of the HSQL Development Group nor the names of its
 
15
 * contributors may be used to endorse or promote products derived from this
 
16
 * software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
21
 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
 
22
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
25
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
26
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
28
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 */
 
30
 
 
31
 
32
32
package org.hsqldb;
33
33
 
34
34
import org.hsqldb.lib.DoubleIntIndex;
102
102
 
103
103
    void commit(Session session) {
104
104
 
105
 
        Object[] list = session.transactionList.getArray();
106
 
        int      size = session.transactionList.size();
 
105
        Object[] list = session.rowActionList.getArray();
 
106
        int      size = session.rowActionList.size();
107
107
 
108
108
        for (int i = 0; i < size; i++) {
109
109
            Transaction tx    = (Transaction) list[i];
113
113
            rowSessionMap.remove(rowid);
114
114
        }
115
115
 
116
 
        session.transactionList.clear();
 
116
        session.rowActionList.clear();
117
117
        session.savepoints.clear();
118
118
    }
119
119
 
127
127
 
128
128
        int index = session.savepoints.getIndex(name);
129
129
 
130
 
        if (index < 1) {
 
130
        if (index < 0) {
131
131
            throw Trace.error(Trace.SAVEPOINT_NOT_FOUND, name);
132
132
        }
133
133
 
143
143
 
144
144
    void rollbackTransactions(Session session, int limit, boolean log) {
145
145
 
146
 
        Object[] list = session.transactionList.getArray();
147
 
        int      size = session.transactionList.size();
 
146
        Object[] list = session.rowActionList.getArray();
 
147
        int      size = session.rowActionList.size();
148
148
 
149
149
        for (int i = size - 1; i >= limit; i--) {
150
150
            Transaction tx = (Transaction) list[i];
151
151
 
152
 
            tx.rollback(session, false);
 
152
            tx.rollback(session, log);
153
153
        }
154
154
 
155
155
        for (int i = limit; i < size; i++) {
159
159
            rowSessionMap.remove(rowid);
160
160
        }
161
161
 
162
 
        session.transactionList.setSize(limit);
 
162
        session.rowActionList.setSize(limit);
163
163
    }
164
164
 
165
165
    void addTransaction(Session session, Transaction transaction) {
169
169
        }
170
170
    }
171
171
 
 
172
    private long globalActionTimestamp = 0;
 
173
 
 
174
    /**
 
175
     * gets the next timestamp for an action
 
176
     */
 
177
    long nextActionTimestamp() {
 
178
 
 
179
        globalActionTimestamp++;
 
180
 
 
181
        return globalActionTimestamp;
 
182
    }
 
183
 
172
184
    /**
173
185
     * Return an array of all transactions sorted by System Change No.
174
186
     */
200
212
 
201
213
                if (tIndex[i] < tSize) {
202
214
                    Transaction current =
203
 
                        (Transaction) sessions[i].transactionList.get(
 
215
                        (Transaction) sessions[i].rowActionList.get(
204
216
                            tIndex[i]);
205
217
 
206
218
                    if (current.SCN < minChangeNo) {
216
228
                break;
217
229
            }
218
230
 
219
 
            HsqlArrayList currentList =
220
 
                sessions[sessionIndex].transactionList;
 
231
            HsqlArrayList currentList = sessions[sessionIndex].rowActionList;
221
232
 
222
233
            for (; tIndex[sessionIndex] < currentList.size(); ) {
223
234
                Transaction current =
252
263
        lookup.setKeysSearchTarget();
253
264
 
254
265
        for (int i = 0; i < sessions.length; i++) {
255
 
            HsqlArrayList tlist = sessions[i].transactionList;
 
266
            HsqlArrayList tlist = sessions[i].rowActionList;
256
267
 
257
268
            for (int j = 0, size = tlist.size(); j < size; j++) {
258
269
                Transaction tx = (Transaction) tlist.get(j);
274
285
        Session[] sessions = database.sessionManager.getAllSessions();
275
286
 
276
287
        for (int i = 0; i < sessions.length; i++) {
277
 
            HsqlArrayList tlist = sessions[i].transactionList;
 
288
            HsqlArrayList tlist = sessions[i].rowActionList;
278
289
 
279
290
            for (int j = 0, size = tlist.size(); j < size; j++) {
280
291
                Transaction tx = (Transaction) tlist.get(j);