001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.UpdateConstantAction
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute;
023:
024: import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
025:
026: import org.apache.derby.iapi.services.io.ArrayUtil;
027: import org.apache.derby.iapi.services.io.StoredFormatIds;
028: import org.apache.derby.iapi.services.io.FormatIdUtil;
029:
030: import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
031:
032: import org.apache.derby.iapi.sql.execute.ConstantAction;
033: import org.apache.derby.iapi.sql.execute.ExecRow;
034:
035: import org.apache.derby.iapi.sql.Activation;
036:
037: import org.apache.derby.iapi.error.StandardException;
038:
039: import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
040:
041: import org.apache.derby.catalog.UUID;
042:
043: import org.apache.derby.iapi.services.io.FormatableBitSet;
044:
045: import java.io.ObjectOutput;
046: import java.io.ObjectInput;
047: import java.io.IOException;
048:
049: import java.util.Properties;
050:
051: /**
052: * This class describes compiled constants that are passed into
053: * UpdateResultSets.
054: *
055: * @author Rick Hillegas
056: */
057:
058: public class UpdateConstantAction extends WriteCursorConstantAction {
059: /********************************************************
060: **
061: ** This class implements Formatable. But it is NOT used
062: ** across either major or minor releases. It is only
063: ** written persistently in stored prepared statements,
064: ** not in the replication stage. SO, IT IS OK TO CHANGE
065: ** ITS read/writeExternal.
066: **
067: ********************************************************/
068:
069: /*
070: ** Integer array of columns that are being updated.
071: */
072: int[] changedColumnIds;
073:
074: private boolean positionedUpdate;
075:
076: int numColumns;
077:
078: // CONSTRUCTORS
079:
080: /**
081: * Public niladic constructor. Needed for Formatable interface to work.
082: *
083: */
084: public UpdateConstantAction() {
085: super ();
086: }
087:
088: /**
089: * Make the ConstantAction for an UPDATE statement.
090: *
091: * @param conglomId Conglomerate ID.
092: * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
093: * @param irgs Index descriptors
094: * @param indexCIDS Conglomerate IDs of indices
095: * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
096: * @param indexNames Names of indices on this table for error reporting.
097: * @param emptyHeapRow Template for heap row.
098: * @param deferred True means process as a deferred update.
099: * @param targetUUID UUID of target table
100: * @param lockMode The lock mode to use
101: * (row or table, see TransactionController)
102: * @param changedColumnIds Array of ids of changed columns
103: * @param fkInfo Array of structures containing foreign key info,
104: * if any (may be null)
105: * @param triggerInfo Array of structures containing trigger info,
106: * if any (may be null)
107: * @param baseRowReadList Map of columns read in. 1 based.
108: * @param baseRowReadMap BaseRowReadMap[heapColId]->ReadRowColumnId. (0 based)
109: * @param streamStorableHeapColIds Null for non rep. (0 based)
110: * @param numColumns Number of columns being read.
111: * @param positionedUpdate is this a positioned update
112: * @param singleRowSource Whether or not source is a single row source
113: */
114: public UpdateConstantAction(long conglomId,
115: StaticCompiledOpenConglomInfo heapSCOCI,
116: IndexRowGenerator[] irgs, long[] indexCIDS,
117: StaticCompiledOpenConglomInfo[] indexSCOCIs,
118: String[] indexNames, ExecRow emptyHeapRow,
119: boolean deferred, UUID targetUUID, int lockMode,
120: int[] changedColumnIds, FKInfo[] fkInfo,
121: TriggerInfo triggerInfo, FormatableBitSet baseRowReadList,
122: int[] baseRowReadMap, int[] streamStorableHeapColIds,
123: int numColumns, boolean positionedUpdate,
124: boolean singleRowSource) {
125: super (conglomId, heapSCOCI, irgs, indexCIDS, indexSCOCIs,
126: indexNames, deferred, (Properties) null, targetUUID,
127: lockMode, fkInfo, triggerInfo, emptyHeapRow,
128: baseRowReadList, baseRowReadMap,
129: streamStorableHeapColIds, singleRowSource);
130:
131: this .changedColumnIds = changedColumnIds;
132: this .positionedUpdate = positionedUpdate;
133: this .numColumns = numColumns;
134: }
135:
136: // INTERFACE METHODS
137:
138: // Formatable methods
139:
140: /**
141: @see java.io.Externalizable#readExternal
142: @exception IOException thrown on error
143: @exception ClassNotFoundException thrown on error
144: */
145: public void readExternal(ObjectInput in) throws IOException,
146: ClassNotFoundException {
147: super .readExternal(in);
148: changedColumnIds = ArrayUtil.readIntArray(in);
149: positionedUpdate = in.readBoolean();
150: numColumns = in.readInt();
151: }
152:
153: /**
154:
155: @see java.io.Externalizable#writeExternal
156: @exception IOException thrown on error
157: */
158: public void writeExternal(ObjectOutput out) throws IOException {
159: super .writeExternal(out);
160: ArrayUtil.writeIntArray(out, changedColumnIds);
161: out.writeBoolean(positionedUpdate);
162: out.writeInt(numColumns);
163: }
164:
165: /**
166: * Get the formatID which corresponds to this class.
167: *
168: * @return the formatID of this class
169: */
170: public int getTypeFormatId() {
171: return StoredFormatIds.UPDATE_CONSTANT_ACTION_V01_ID;
172: }
173:
174: // CLASS METHODS
175: }
|