You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2022/08/16 22:10:17 UTC
svn commit: r1903468 [4/5] - in /db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/sql: compile/ execute/
Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java?rev=1903468&r1=1903467&r2=1903468&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java Tue Aug 16 22:10:16 2022
@@ -58,36 +58,36 @@ import java.util.Properties;
public class InsertConstantAction extends WriteCursorConstantAction
{
- /********************************************************
- **
- ** This class implements Formatable. But it is NOT used
- ** across either major or minor releases. It is only
- ** written persistently in stored prepared statements,
- ** not in the replication stage. SO, IT IS OK TO CHANGE
- ** ITS read/writeExternal.
- **
- ********************************************************/
-
- /* Which (0-based) columns are indexed */
- boolean[] indexedCols;
-
- /* These variables are needed to support Autoincrement-- after an insert
- * we need to remember the last autoincrement value inserted into the
- * table and the user could do a search based on schema,table,columnname
- */
- private String schemaName;
- private String tableName;
- private String columnNames[];
-
- /**
- * An array of row location objects (0 based), one for each
- * column in the table. If the column is an
- * autoincrement table then the array points to
- * the row location of the column in SYSCOLUMNS.
- * if not, then it contains null.
- */
+ /********************************************************
+ **
+ ** This class implements Formatable. But it is NOT used
+ ** across either major or minor releases. It is only
+ ** written persistently in stored prepared statements,
+ ** not in the replication stage. SO, IT IS OK TO CHANGE
+ ** ITS read/writeExternal.
+ **
+ ********************************************************/
+
+ /* Which (0-based) columns are indexed */
+ boolean[] indexedCols;
+
+ /* These variables are needed to support Autoincrement-- after an insert
+ * we need to remember the last autoincrement value inserted into the
+ * table and the user could do a search based on schema,table,columnname
+ */
+ private String schemaName;
+ private String tableName;
+ private String columnNames[];
+
+ /**
+ * An array of row location objects (0 based), one for each
+ * column in the table. If the column is an
+ * autoincrement table then the array points to
+ * the row location of the column in SYSCOLUMNS.
+ * if not, then it contains null.
+ */
RowLocation[] autoincRowLocation;
- private long[] autoincIncrement;
+ private long[] autoincIncrement;
/** Position of autogenerated column */
private transient int firstAutoGenColumn = -1;
@@ -95,156 +95,152 @@ public class InsertConstantAction extend
String identitySequenceUUIDString;
- // CONSTRUCTORS
+ // CONSTRUCTORS
- /**
- * Public niladic constructor. Needed for Formatable interface to work.
- *
- */
+ /**
+ * Public niladic constructor. Needed for Formatable interface to work.
+ *
+ */
public InsertConstantAction() {
super();
hasDeferrableChecks = false;
}
- /**
- * Make the ConstantAction for an INSERT statement.
- *
+ /**
+ * Make the ConstantAction for an INSERT statement.
+ *
* @param tableDescriptor
- * @param conglomId Conglomerate ID.
- * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
- * @param irgs Index descriptors
- * @param indexCIDS Conglomerate IDs of indices
- * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
- * @param indexNames Names of indices on this table for error reporting.
- * @param deferred True means process as a deferred insert.
+ * @param conglomId Conglomerate ID.
+ * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
+ * @param irgs Index descriptors
+ * @param indexCIDS Conglomerate IDs of indices
+ * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
+ * @param indexNames Names of indices on this table for error reporting.
+ * @param deferred True means process as a deferred insert.
* @param hasDeferrableChecks
* The target table has deferrable CHECK constraints
- * @param targetProperties Properties on the target table.
- * @param targetUUID UUID of target table
- * @param lockMode The lockMode to use on the target table
- * @param fkInfo Array of structures containing foreign key info,
- * if any (may be null)
- * @param triggerInfo Array of structures containing trigger info,
- * if any (may be null)
+ * @param targetProperties Properties on the target table.
+ * @param targetUUID UUID of target table
+ * @param lockMode The lockMode to use on the target table
+ * @param fkInfo Array of structures containing foreign key info,
+ * if any (may be null)
+ * @param triggerInfo Array of structures containing trigger info,
+ * if any (may be null)
* @param streamStorableHeapColIds Null for non rep. (0 based)
- * @param indexedCols boolean[] of which (0-based) columns are indexed.
- * @param singleRowSource Whether or not source is a single row source
- * @param autoincRowLocation Array of rowlocations of autoincrement values
- * in SYSCOLUMNS for each ai column.
- * @param underMerge True if this is an action of a MERGE statement.
- * @param identitySequenceUUIDString For 10.11 and higher, the handle on the sequence for the identity column
- */
+ * @param indexedCols boolean[] of which (0-based) columns are indexed.
+ * @param singleRowSource Whether or not source is a single row source
+ * @param autoincRowLocation Array of rowlocations of autoincrement values
+ * in SYSCOLUMNS for each ai column.
+ * @param underMerge True if this is an action of a MERGE statement.
+ * @param identitySequenceUUIDString For 10.11 and higher, the handle on the sequence for the identity column
+ */
InsertConstantAction(TableDescriptor tableDescriptor,
- long conglomId,
- StaticCompiledOpenConglomInfo heapSCOCI,
- IndexRowGenerator[] irgs,
- long[] indexCIDS,
- StaticCompiledOpenConglomInfo[] indexSCOCIs,
- String[] indexNames,
- boolean deferred,
- boolean hasDeferrableChecks,
- Properties targetProperties,
- UUID targetUUID,
- int lockMode,
- FKInfo[] fkInfo,
- TriggerInfo triggerInfo,
- int[] streamStorableHeapColIds,
- boolean[] indexedCols,
- boolean singleRowSource,
- RowLocation[] autoincRowLocation,
- boolean underMerge,
- String identitySequenceUUIDString)
- {
- super(conglomId,
- heapSCOCI,
- irgs,
- indexCIDS,
- indexSCOCIs,
- indexNames,
- deferred,
- targetProperties,
- targetUUID,
- lockMode,
- fkInfo,
- triggerInfo,
- null,
- null,
- streamStorableHeapColIds,
- singleRowSource,
- underMerge
- );
- this.indexedCols = indexedCols;
- this.autoincRowLocation = autoincRowLocation;
- this.schemaName = tableDescriptor.getSchemaName();
- this.tableName = tableDescriptor.getName();
- this.columnNames = tableDescriptor.getColumnNamesArray();
- this.autoincIncrement = tableDescriptor.getAutoincIncrementArray();
- this.indexNames = indexNames;
+ long conglomId,
+ StaticCompiledOpenConglomInfo heapSCOCI,
+ IndexRowGenerator[] irgs,
+ long[] indexCIDS,
+ StaticCompiledOpenConglomInfo[] indexSCOCIs,
+ String[] indexNames,
+ boolean deferred,
+ boolean hasDeferrableChecks,
+ Properties targetProperties,
+ UUID targetUUID,
+ int lockMode,
+ FKInfo[] fkInfo,
+ TriggerInfo triggerInfo,
+ int[] streamStorableHeapColIds,
+ boolean[] indexedCols,
+ boolean singleRowSource,
+ RowLocation[] autoincRowLocation,
+ boolean underMerge,
+ String identitySequenceUUIDString) {
+ super(conglomId,
+ heapSCOCI,
+ irgs,
+ indexCIDS,
+ indexSCOCIs,
+ indexNames,
+ deferred,
+ targetProperties,
+ targetUUID,
+ lockMode,
+ fkInfo,
+ triggerInfo,
+ null,
+ null,
+ streamStorableHeapColIds,
+ singleRowSource,
+ underMerge
+ );
+ this.indexedCols = indexedCols;
+ this.autoincRowLocation = autoincRowLocation;
+ this.schemaName = tableDescriptor.getSchemaName();
+ this.tableName = tableDescriptor.getName();
+ this.columnNames = tableDescriptor.getColumnNamesArray();
+ this.autoincIncrement = tableDescriptor.getAutoincIncrementArray();
+ this.indexNames = indexNames;
this.hasDeferrableChecks = hasDeferrableChecks;
this.identitySequenceUUIDString = identitySequenceUUIDString;
- }
+ }
- // INTERFACE METHODS
+ // INTERFACE METHODS
- // Formatable methods
- public void readExternal (ObjectInput in)
- throws IOException, ClassNotFoundException
- {
- Object[] objectArray = null;
- super.readExternal(in);
- indexedCols = ArrayUtil.readBooleanArray(in);
+ // Formatable methods
+ public void readExternal (ObjectInput in)
+ throws IOException, ClassNotFoundException {
+ Object[] objectArray = null;
+ super.readExternal(in);
+ indexedCols = ArrayUtil.readBooleanArray(in);
- // RESOLVEAUTOINCREMENT: this is the new stuff-- probably version!!
- objectArray = ArrayUtil.readObjectArray(in);
+ // RESOLVEAUTOINCREMENT: this is the new stuff-- probably version!!
+ objectArray = ArrayUtil.readObjectArray(in);
- if (objectArray != null)
- {
- // is there a better way to do cast the whole array?
- autoincRowLocation = new RowLocation[objectArray.length];
- for (int i = 0; i < objectArray.length; i++)
- autoincRowLocation[i] = (RowLocation)objectArray[i];
- }
+ if (objectArray != null)
+ {
+ // is there a better way to do cast the whole array?
+ autoincRowLocation = new RowLocation[objectArray.length];
+ for (int i = 0; i < objectArray.length; i++)
+ autoincRowLocation[i] = (RowLocation)objectArray[i];
+ }
- schemaName = (String)in.readObject();
- tableName = (String)in.readObject();
- objectArray = ArrayUtil.readObjectArray(in);
- if (objectArray != null)
- {
- // is there a better way to do cast the whole array?
- columnNames = new String[objectArray.length];
- for (int i = 0; i < objectArray.length; i++)
- columnNames[i] = (String)objectArray[i];
- }
+ schemaName = (String)in.readObject();
+ tableName = (String)in.readObject();
+ objectArray = ArrayUtil.readObjectArray(in);
+ if (objectArray != null)
+ {
+ // is there a better way to do cast the whole array?
+ columnNames = new String[objectArray.length];
+ for (int i = 0; i < objectArray.length; i++)
+ columnNames[i] = (String)objectArray[i];
+ }
- autoincIncrement = ArrayUtil.readLongArray(in);
+ autoincIncrement = ArrayUtil.readLongArray(in);
identitySequenceUUIDString = (String) in.readObject();
- }
+ }
- /**
- * Write this object to a stream of stored objects.
- *
- * @param out write bytes here.
- *
- * @exception IOException thrown on error
- */
- public void writeExternal( ObjectOutput out )
- throws IOException
- {
- super.writeExternal(out);
- ArrayUtil.writeBooleanArray(out, indexedCols);
- ArrayUtil.writeArray(out, autoincRowLocation);
- out.writeObject(schemaName);
- out.writeObject(tableName);
- ArrayUtil.writeArray(out, columnNames);
- ArrayUtil.writeLongArray(out, autoincIncrement);
+ /**
+ * Write this object to a stream of stored objects.
+ *
+ * @param out write bytes here.
+ *
+ * @exception IOException thrown on error
+ */
+ public void writeExternal( ObjectOutput out )
+ throws IOException {
+ super.writeExternal(out);
+ ArrayUtil.writeBooleanArray(out, indexedCols);
+ ArrayUtil.writeArray(out, autoincRowLocation);
+ out.writeObject(schemaName);
+ out.writeObject(tableName);
+ ArrayUtil.writeArray(out, columnNames);
+ ArrayUtil.writeLongArray(out, autoincIncrement);
out.writeObject( identitySequenceUUIDString );
- }
+ }
/** Get the 0-based position of the autogenerated column */
- public int getAutoGenColumn()
- {
+ public int getAutoGenColumn() {
if ( !hasAutoincrement() ) { return -1; }
if ( firstAutoGenColumn < 0 )
{
@@ -261,65 +257,59 @@ public class InsertConstantAction extend
return firstAutoGenColumn;
}
- /**
- * Gets the name of the schema that the table is in
- *
- * @return schema name
- */
- public String getSchemaName() { return schemaName; }
-
- /**
- * Gets the name of the table being inserted into
- *
- * @return name of table being inserted into
- */
- public String getTableName() { return tableName; }
-
-
- /**
- * gets the name of the desired column in the taget table.
- *
- * @param i the column number
- */
- public String getColumnName(int i) { return columnNames[i]; }
+ /**
+ * Gets the name of the schema that the table is in
+ *
+ * @return schema name
+ */
+ public String getSchemaName() { return schemaName; }
+
+ /**
+ * Gets the name of the table being inserted into
+ *
+ * @return name of table being inserted into
+ */
+ public String getTableName() { return tableName; }
+
+
+ /**
+ * gets the name of the desired column in the taget table.
+ *
+ * @param i the column number
+ */
+ public String getColumnName(int i) { return columnNames[i]; }
- /**
- * get the array of column names in the target table.
- */
+ /**
+ * get the array of column names in the target table.
+ */
String[] getColumnNames() { return columnNames; }
- /**
- * gets the increment value for a column.
- *
- * @param i the column number
- */
- public long getAutoincIncrement(int i) { return autoincIncrement[i]; }
-
- /**
- * Does the target table has autoincrement columns.
- *
- * @return True if the table has ai columns
- */
- public boolean hasAutoincrement()
- {
- return (autoincRowLocation != null);
- }
-
- /**
- * gets the row location
- */
- RowLocation[] getAutoincRowLocation()
- {
- return autoincRowLocation;
- }
+ /**
+ * gets the increment value for a column.
+ *
+ * @param i the column number
+ */
+ public long getAutoincIncrement(int i) { return autoincIncrement[i]; }
+
+ /**
+ * Does the target table has autoincrement columns.
+ *
+ * @return True if the table has ai columns
+ */
+ public boolean hasAutoincrement() { return (autoincRowLocation != null); }
+
+ /**
+ * gets the row location
+ */
+ RowLocation[] getAutoincRowLocation() { return autoincRowLocation; }
- /**
- * Get the formatID which corresponds to this class.
- *
- * @return the formatID of this class
- */
- public int getTypeFormatId() { return StoredFormatIds.INSERT_CONSTANT_ACTION_V01_ID; }
+ /**
+ * Get the formatID which corresponds to this class.
+ *
+ * @return the formatID of this class
+ */
+ public int getTypeFormatId() { return StoredFormatIds.INSERT_CONSTANT_ACTION_V01_ID; }
- // CLASS METHODS
+ // CLASS METHODS
}