KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > UpdateConstantAction


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.UpdateConstantAction
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (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.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
25
26 import org.apache.derby.iapi.services.io.ArrayUtil;
27 import org.apache.derby.iapi.services.io.StoredFormatIds;
28 import org.apache.derby.iapi.services.io.FormatIdUtil;
29
30 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
31
32 import org.apache.derby.iapi.sql.execute.ConstantAction;
33 import org.apache.derby.iapi.sql.execute.ExecRow;
34
35 import org.apache.derby.iapi.sql.Activation;
36
37 import org.apache.derby.iapi.error.StandardException;
38
39 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
40
41 import org.apache.derby.catalog.UUID;
42
43 import org.apache.derby.iapi.services.io.FormatableBitSet;
44
45 import java.io.ObjectOutput JavaDoc;
46 import java.io.ObjectInput JavaDoc;
47 import java.io.IOException JavaDoc;
48
49 import java.util.Properties JavaDoc;
50
51 /**
52  * This class describes compiled constants that are passed into
53  * UpdateResultSets.
54  *
55  * @author Rick Hillegas
56  */

57
58 public class UpdateConstantAction extends WriteCursorConstantAction
59 {
60     /********************************************************
61     **
62     ** This class implements Formatable. But it is NOT used
63     ** across either major or minor releases. It is only
64     ** written persistently in stored prepared statements,
65     ** not in the replication stage. SO, IT IS OK TO CHANGE
66     ** ITS read/writeExternal.
67     **
68     ********************************************************/

69     
70     /*
71     ** Integer array of columns that are being updated.
72     */

73     int[] changedColumnIds;
74
75     private boolean positionedUpdate;
76
77     int numColumns;
78
79     // CONSTRUCTORS
80

81     /**
82      * Public niladic constructor. Needed for Formatable interface to work.
83      *
84      */

85     public UpdateConstantAction() { super(); }
86
87     /**
88      * Make the ConstantAction for an UPDATE statement.
89      *
90      * @param conglomId Conglomerate ID.
91      * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
92      * @param irgs Index descriptors
93      * @param indexCIDS Conglomerate IDs of indices
94      * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
95      * @param indexNames Names of indices on this table for error reporting.
96      * @param emptyHeapRow Template for heap row.
97      * @param deferred True means process as a deferred update.
98      * @param targetUUID UUID of target table
99      * @param lockMode The lock mode to use
100      * (row or table, see TransactionController)
101      * @param changedColumnIds Array of ids of changed columns
102      * @param fkInfo Array of structures containing foreign key info,
103      * if any (may be null)
104      * @param triggerInfo Array of structures containing trigger info,
105      * if any (may be null)
106      * @param baseRowReadList Map of columns read in. 1 based.
107      * @param baseRowReadMap BaseRowReadMap[heapColId]->ReadRowColumnId. (0 based)
108      * @param streamStorableHeapColIds Null for non rep. (0 based)
109      * @param numColumns Number of columns being read.
110      * @param positionedUpdate is this a positioned update
111      * @param singleRowSource Whether or not source is a single row source
112      */

113     public UpdateConstantAction(
114                                 long conglomId,
115                                 StaticCompiledOpenConglomInfo heapSCOCI,
116                                 IndexRowGenerator[] irgs,
117                                 long[] indexCIDS,
118                                 StaticCompiledOpenConglomInfo[] indexSCOCIs,
119                                 String JavaDoc[] indexNames,
120                                 ExecRow emptyHeapRow,
121                                 boolean deferred,
122                                 UUID targetUUID,
123                                 int lockMode,
124                                 int[] changedColumnIds,
125                                 FKInfo[] fkInfo,
126                                 TriggerInfo triggerInfo,
127                                 FormatableBitSet baseRowReadList,
128                                 int[] baseRowReadMap,
129                                 int[] streamStorableHeapColIds,
130                                 int numColumns,
131                                 boolean positionedUpdate,
132                                 boolean singleRowSource)
133     {
134         super(
135             conglomId,
136             heapSCOCI,
137             irgs,
138             indexCIDS,
139             indexSCOCIs,
140             indexNames,
141             deferred,
142             (Properties JavaDoc) null,
143             targetUUID,
144             lockMode,
145             fkInfo,
146             triggerInfo,
147             emptyHeapRow,
148             baseRowReadList,
149             baseRowReadMap,
150             streamStorableHeapColIds,
151             singleRowSource
152             );
153
154         this.changedColumnIds = changedColumnIds;
155         this.positionedUpdate = positionedUpdate;
156         this.numColumns = numColumns;
157     }
158
159     // INTERFACE METHODS
160

161
162     // Formatable methods
163

164     /**
165       @see java.io.Externalizable#readExternal
166       @exception IOException thrown on error
167       @exception ClassNotFoundException thrown on error
168       */

169     public void readExternal( ObjectInput JavaDoc in )
170          throws IOException JavaDoc, ClassNotFoundException JavaDoc
171     {
172         super.readExternal(in);
173         changedColumnIds = ArrayUtil.readIntArray(in);
174         positionedUpdate = in.readBoolean();
175         numColumns = in.readInt();
176     }
177
178     /**
179
180       @see java.io.Externalizable#writeExternal
181       @exception IOException thrown on error
182       */

183     public void writeExternal( ObjectOutput JavaDoc out )
184          throws IOException JavaDoc
185     {
186         super.writeExternal(out);
187         ArrayUtil.writeIntArray(out,changedColumnIds);
188         out.writeBoolean(positionedUpdate);
189         out.writeInt(numColumns);
190     }
191
192     /**
193      * Get the formatID which corresponds to this class.
194      *
195      * @return the formatID of this class
196      */

197     public int getTypeFormatId() { return StoredFormatIds.UPDATE_CONSTANT_ACTION_V01_ID; }
198
199     // CLASS METHODS
200
}
201
Popular Tags