1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.services.stream.HeaderPrintWriter; 25 26 27 import org.apache.derby.iapi.services.io.ArrayUtil; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 import org.apache.derby.iapi.services.io.FormatIdUtil; 30 31 import org.apache.derby.iapi.services.context.ContextManager; 32 33 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator; 34 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 35 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 36 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 37 import org.apache.derby.iapi.sql.execute.ConstantAction; 38 import org.apache.derby.iapi.sql.execute.ExecRow; 39 40 import org.apache.derby.iapi.error.StandardException; 41 42 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo; 43 import org.apache.derby.iapi.types.RowLocation; 44 45 import org.apache.derby.catalog.UUID; 46 47 import java.io.ObjectOutput ; 48 import java.io.ObjectInput ; 49 import java.io.IOException ; 50 51 import java.util.Properties ; 52 53 59 60 public class InsertConstantAction extends WriteCursorConstantAction 61 { 62 71 72 73 boolean[] indexedCols; 74 75 79 private String schemaName; 80 private String tableName; 81 private String columnNames[]; 82 83 90 protected RowLocation[] autoincRowLocation; 91 private long[] autoincIncrement; 92 93 95 99 public InsertConstantAction() { super(); } 100 101 124 public InsertConstantAction(TableDescriptor tableDescriptor, 125 long conglomId, 126 StaticCompiledOpenConglomInfo heapSCOCI, 127 IndexRowGenerator[] irgs, 128 long[] indexCIDS, 129 StaticCompiledOpenConglomInfo[] indexSCOCIs, 130 String [] indexNames, 131 boolean deferred, 132 Properties targetProperties, 133 UUID targetUUID, 134 int lockMode, 135 FKInfo[] fkInfo, 136 TriggerInfo triggerInfo, 137 int[] streamStorableHeapColIds, 138 boolean[] indexedCols, 139 boolean singleRowSource, 140 RowLocation[] autoincRowLocation) 141 { 142 super(conglomId, 143 heapSCOCI, 144 irgs, 145 indexCIDS, 146 indexSCOCIs, 147 indexNames, 148 deferred, 149 targetProperties, 150 targetUUID, 151 lockMode, 152 fkInfo, 153 triggerInfo, 154 (ExecRow)null, null, 156 null, 157 streamStorableHeapColIds, 158 singleRowSource 159 ); 160 this.indexedCols = indexedCols; 161 this.autoincRowLocation = autoincRowLocation; 162 this.schemaName = tableDescriptor.getSchemaName(); 163 this.tableName = tableDescriptor.getName(); 164 this.columnNames = tableDescriptor.getColumnNamesArray(); 165 this.autoincIncrement = tableDescriptor.getAutoincIncrementArray(); 166 this.indexNames = indexNames; 167 } 168 169 171 public void readExternal (ObjectInput in) 173 throws IOException , ClassNotFoundException 174 { 175 Object [] objectArray = null; 176 super.readExternal(in); 177 indexedCols = ArrayUtil.readBooleanArray(in); 178 179 objectArray = ArrayUtil.readObjectArray(in); 181 182 if (objectArray != null) 183 { 184 autoincRowLocation = new RowLocation[objectArray.length]; 186 for (int i = 0; i < objectArray.length; i++) 187 autoincRowLocation[i] = (RowLocation)objectArray[i]; 188 } 189 190 schemaName = (String )in.readObject(); 191 tableName = (String )in.readObject(); 192 objectArray = ArrayUtil.readObjectArray(in); 193 if (objectArray != null) 194 { 195 columnNames = new String [objectArray.length]; 197 for (int i = 0; i < objectArray.length; i++) 198 columnNames[i] = (String )objectArray[i]; 199 } 200 201 autoincIncrement = ArrayUtil.readLongArray(in); 202 } 203 204 205 206 213 public void writeExternal( ObjectOutput out ) 214 throws IOException 215 { 216 super.writeExternal(out); 217 ArrayUtil.writeBooleanArray(out, indexedCols); 218 ArrayUtil.writeArray(out, autoincRowLocation); 219 out.writeObject(schemaName); 220 out.writeObject(tableName); 221 ArrayUtil.writeArray(out, columnNames); 222 ArrayUtil.writeLongArray(out, autoincIncrement); 223 } 224 225 230 public String getSchemaName() { return schemaName; } 231 232 237 public String getTableName() { return tableName; } 238 239 240 245 public String getColumnName(int i) { return columnNames[i]; } 246 247 252 public long getAutoincIncrement(int i) { return autoincIncrement[i]; } 253 254 259 public boolean hasAutoincrement() 260 { 261 return (autoincRowLocation != null); 262 } 263 264 267 public RowLocation[] getAutoincRowLocation() 268 { 269 return autoincRowLocation; 270 } 271 272 277 public int getTypeFormatId() { return StoredFormatIds.INSERT_CONSTANT_ACTION_V01_ID; } 278 279 281 } 282 | Popular Tags |