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 da...@apache.org on 2013/06/21 09:47:52 UTC
svn commit: r1495305 [5/21] - in /db/derby/code/trunk:
java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/
java/engine/org/apache/derby/iapi/services/io/
java/engine/org/apache/derby/iapi/sql/
java/engine/org/apache/derby/iapi/sql...
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateIndexNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateIndexNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateIndexNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateIndexNode.java Fri Jun 21 07:47:47 2013
@@ -24,14 +24,14 @@ package org.apache.derby.impl.sql.compil
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
-
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.Limits;
import org.apache.derby.iapi.reference.Property;
import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.property.PropertyUtil;
import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
@@ -44,21 +44,21 @@ import org.apache.derby.iapi.types.DataT
*
*/
-public class CreateIndexNode extends DDLStatementNode
+class CreateIndexNode extends DDLStatementNode
{
private boolean unique;
private Properties properties;
private String indexType;
private TableName indexName;
private TableName tableName;
- private List columnNameList;
+ private List<String> columnNameList;
private String[] columnNames;
private boolean[] isAscending;
private int[] boundColumnIDs;
private TableDescriptor td;
/**
- * Initializer for a CreateIndexNode
+ * Constructor for a CreateIndexNode
*
* @param unique True means it's a unique index
* @param indexType The type of index
@@ -67,25 +67,26 @@ public class CreateIndexNode extends DDL
* @param columnNameList A list of column names, in the order they
* appear in the index.
* @param properties The optional properties list associated with the index.
+ * @param cm Context manager
*
* @exception StandardException Thrown on error
*/
- public void init(
- Object unique,
- Object indexType,
- Object indexName,
- Object tableName,
- Object columnNameList,
- Object properties)
- throws StandardException
+ CreateIndexNode(boolean unique,
+ String indexType,
+ TableName indexName,
+ TableName tableName,
+ List<String> columnNameList,
+ Properties properties,
+ ContextManager cm) throws StandardException
{
- initAndCheck(indexName);
- this.unique = ((Boolean) unique).booleanValue();
- this.indexType = (String) indexType;
- this.indexName = (TableName) indexName;
- this.tableName = (TableName) tableName;
- this.columnNameList = (List) columnNameList;
- this.properties = (Properties) properties;
+ super(indexName, cm);
+ this.unique = unique;
+ this.indexType = indexType;
+ this.indexName = indexName;
+ this.tableName = tableName;
+ this.columnNameList = columnNameList;
+ this.properties = properties;
+ setNodeType(C_NodeTypes.CREATE_INDEX_NODE);
}
/**
@@ -94,7 +95,7 @@ public class CreateIndexNode extends DDL
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -112,7 +113,7 @@ public class CreateIndexNode extends DDL
}
}
- public String statementToString()
+ String statementToString()
{
return "CREATE INDEX";
}
@@ -127,14 +128,12 @@ public class CreateIndexNode extends DDL
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void bindStatement() throws StandardException
{
- CompilerContext cc = getCompilerContext();
- SchemaDescriptor sd;
int columnCount;
- sd = getSchemaDescriptor();
+ getSchemaDescriptor(); // want checking side-effects only
td = getTableDescriptor(tableName);
@@ -212,6 +211,7 @@ public class CreateIndexNode extends DDL
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -224,7 +224,8 @@ public class CreateIndexNode extends DDL
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction() throws StandardException
+ @Override
+ public ConstantAction makeConstantAction() throws StandardException
{
SchemaDescriptor sd = getSchemaDescriptor();
@@ -303,7 +304,7 @@ public class CreateIndexNode extends DDL
/* Verify that this column's name is unique within the list
* Having a space at the end meaning descending on the column
*/
- columnNames[index] = (String) columnNameList.get(index);
+ columnNames[index] = columnNameList.get(index);
if (columnNames[index].endsWith(" "))
{
columnNames[index] = columnNames[index].substring(0, columnNames[index].length() - 1);
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateRoleNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateRoleNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateRoleNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateRoleNode.java Fri Jun 21 07:47:47 2013
@@ -22,7 +22,9 @@
package org.apache.derby.impl.sql.compile;
import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.execute.ConstantAction;
@@ -33,21 +35,22 @@ import org.apache.derby.iapi.sql.execute
*
*/
-public class CreateRoleNode extends DDLStatementNode
+class CreateRoleNode extends DDLStatementNode
{
private String name;
/**
- * Initializer for a CreateRoleNode
+ * Constructor for a CreateRoleNode
*
* @param roleName The name of the new role
*
* @exception StandardException Thrown on error
*/
- public void init(Object roleName) throws StandardException
+ CreateRoleNode(String roleName, ContextManager cm) throws StandardException
{
- initAndCheck(null);
- this.name = (String)roleName;
+ super(null, cm);
+ this.name = roleName;
+ setNodeType((C_NodeTypes.CREATE_ROLE_NODE));
}
/**
@@ -56,7 +59,7 @@ public class CreateRoleNode extends DDLS
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG) {
@@ -71,6 +74,7 @@ public class CreateRoleNode extends DDLS
* Bind this createRoleNode. Main work is to create a StatementPermission
* object to require CREATE_ROLE_PRIV at execution time.
*/
+ @Override
public void bindStatement() throws StandardException
{
CompilerContext cc = getCompilerContext();
@@ -91,6 +95,7 @@ public class CreateRoleNode extends DDLS
*
* @exception StandardException Thrown on failure
*/
+ @Override
public ConstantAction makeConstantAction()
{
return getGenericConstantActionFactory().
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSchemaNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSchemaNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSchemaNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSchemaNode.java Fri Jun 21 07:47:47 2013
@@ -22,7 +22,9 @@
package org.apache.derby.impl.sql.compile;
import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.execute.ConstantAction;
@@ -33,33 +35,34 @@ import org.apache.derby.iapi.sql.execute
*
*/
-public class CreateSchemaNode extends DDLStatementNode
+class CreateSchemaNode extends DDLStatementNode
{
private String name;
private String aid;
/**
- * Initializer for a CreateSchemaNode
+ * Constructor for a CreateSchemaNode
*
* @param schemaName The name of the new schema
* @param aid The authorization id
+ * @param cm The context manager
*
* @exception StandardException Thrown on error
*/
- public void init(
- Object schemaName,
- Object aid)
- throws StandardException
+ CreateSchemaNode(
+ String schemaName,
+ String aid,
+ ContextManager cm) throws StandardException
{
/*
** DDLStatementNode expects tables, null out
** objectName explicitly to clarify that we
** can't hang with schema.object specifiers.
*/
- initAndCheck(null);
-
- this.name = (String) schemaName;
- this.aid = (String) aid;
+ super(null, cm);
+ this.name = schemaName;
+ this.aid = aid;
+ setNodeType(C_NodeTypes.CREATE_SCHEMA_NODE);
}
/**
@@ -68,7 +71,7 @@ public class CreateSchemaNode extends DD
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -87,6 +90,7 @@ public class CreateSchemaNode extends DD
* Bind this createSchemaNode. Main work is to create a StatementPermission
* object to require CREATE_SCHEMA_PRIV at execution time.
*/
+ @Override
public void bindStatement() throws StandardException
{
CompilerContext cc = getCompilerContext();
@@ -95,7 +99,7 @@ public class CreateSchemaNode extends DD
}
- public String statementToString()
+ String statementToString()
{
return "CREATE SCHEMA";
}
@@ -107,7 +111,8 @@ public class CreateSchemaNode extends DD
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction()
+ @Override
+ public ConstantAction makeConstantAction()
{
return getGenericConstantActionFactory().getCreateSchemaConstantAction(name, aid);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java Fri Jun 21 07:47:47 2013
@@ -23,11 +23,12 @@ package org.apache.derby.impl.sql.compil
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.execute.ConstantAction;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.types.TypeId;
@@ -36,7 +37,7 @@ import org.apache.derby.iapi.types.TypeI
* represents a CREATE SEQUENCE statement.
*/
-public class CreateSequenceNode extends DDLStatementNode
+class CreateSequenceNode extends DDLStatementNode
{
private TableName _sequenceName;
private DataTypeDescriptor _dataType;
@@ -44,12 +45,12 @@ public class CreateSequenceNode extends
private Long _stepValue;
private Long _maxValue;
private Long _minValue;
- private Boolean _cycle;
+ private boolean _cycle;
public static final int SEQUENCE_ELEMENT_COUNT = 1;
/**
- * Initializer for a CreateSequenceNode
+ * Constructor for a CreateSequenceNode
*
* @param sequenceName The name of the new sequence
* @param dataType Exact numeric type of the new sequence
@@ -58,45 +59,51 @@ public class CreateSequenceNode extends
* @param maxValue Largest value returned by the sequence generator
* @param minValue Smallest value returned by the sequence generator
* @param cycle True if the generator should wrap around, false otherwise
- *
+ * @param cm Context manager
* @throws org.apache.derby.iapi.error.StandardException on error
*/
- public void init
+ CreateSequenceNode
(
- Object sequenceName,
- Object dataType,
- Object initialValue,
- Object stepValue,
- Object maxValue,
- Object minValue,
- Object cycle
+ TableName sequenceName,
+ DataTypeDescriptor dataType,
+ Long initialValue,
+ Long stepValue,
+ Long maxValue,
+ Long minValue,
+ boolean cycle,
+ ContextManager cm
) throws StandardException {
- _sequenceName = (TableName) sequenceName;
- initAndCheck(_sequenceName);
+ super(sequenceName, cm);
+ setNodeType(C_NodeTypes.CREATE_SEQUENCE_NODE);
+ this._sequenceName = sequenceName;
if (dataType != null) {
- _dataType = (DataTypeDescriptor) dataType;
+ _dataType = dataType;
} else {
_dataType = DataTypeDescriptor.INTEGER;
}
- _stepValue = (stepValue != null ? (Long) stepValue : new Long(1));
+ _stepValue = (stepValue != null ? stepValue : Long.valueOf(1));
if (_dataType.getTypeId().equals(TypeId.SMALLINT_ID)) {
- _minValue = (minValue != null ? (Long) minValue : new Long(Short.MIN_VALUE));
- _maxValue = (maxValue != null ? (Long) maxValue : new Long(Short.MAX_VALUE));
+ _minValue =
+ (minValue != null ? minValue : Long.valueOf(Short.MIN_VALUE));
+ _maxValue =
+ (maxValue != null ? maxValue : Long.valueOf(Short.MAX_VALUE));
} else if (_dataType.getTypeId().equals(TypeId.INTEGER_ID)) {
- _minValue = (minValue != null ? (Long) minValue : new Long(Integer.MIN_VALUE));
- _maxValue = (maxValue != null ? (Long) maxValue : new Long(Integer.MAX_VALUE));
+ _minValue =
+ (minValue != null ? minValue : Long.valueOf(Integer.MIN_VALUE));
+ _maxValue =
+ (maxValue != null ? maxValue : Long.valueOf(Integer.MAX_VALUE));
} else {
// Could only be BIGINT
- _minValue = (minValue != null ? (Long) minValue : new Long(Long.MIN_VALUE));
- _maxValue = (maxValue != null ? (Long) maxValue : new Long(Long.MAX_VALUE));
+ _minValue = (minValue != null ? minValue : Long.MIN_VALUE);
+ _maxValue = (maxValue != null ? maxValue : Long.MAX_VALUE);
}
if (initialValue != null) {
- _initialValue = (Long) initialValue;
+ _initialValue = initialValue;
} else {
if (_stepValue.longValue() > 0L) {
_initialValue = _minValue;
@@ -104,7 +111,7 @@ public class CreateSequenceNode extends
_initialValue = _maxValue;
}
}
- _cycle = (cycle != null ? (Boolean) cycle : Boolean.FALSE);
+ _cycle = cycle;
// automatically create the schema if it doesn't exist
implicitCreateSchema = true;
@@ -116,7 +123,7 @@ public class CreateSequenceNode extends
*
* @return This object as a String
*/
-
+ @Override
public String toString() {
if (SanityManager.DEBUG) {
return super.toString() +
@@ -131,9 +138,8 @@ public class CreateSequenceNode extends
* The main objectives of this method are to resolve the schema name, determine privilege checks,
* and vet the variables in the CREATE SEQUENCE statement.
*/
+ @Override
public void bindStatement() throws StandardException {
- CompilerContext cc = getCompilerContext();
-
// implicitly create the schema if it does not exist.
// this method also compiles permissions checks
SchemaDescriptor sd = getSchemaDescriptor();
@@ -231,6 +237,7 @@ public class CreateSequenceNode extends
* @throws org.apache.derby.iapi.error.StandardException
* Thrown on failure
*/
+ @Override
public ConstantAction makeConstantAction() {
return getGenericConstantActionFactory().
getCreateSequenceConstantAction(
@@ -240,7 +247,7 @@ public class CreateSequenceNode extends
_stepValue.longValue(),
_maxValue.longValue(),
_minValue.longValue(),
- _cycle.booleanValue());
+ _cycle);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java Fri Jun 21 07:47:47 2013
@@ -21,34 +21,27 @@
package org.apache.derby.impl.sql.compile;
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.Limits;
import org.apache.derby.iapi.reference.Property;
import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.Limits;
-
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.io.FormatableBitSet;
import org.apache.derby.iapi.services.property.PropertyUtil;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.sql.execute.ConstantAction;
-
-import org.apache.derby.iapi.sql.depend.ProviderList;
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.Visitable;
import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.sql.conn.Authorizer;
-
-import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.sql.depend.ProviderList;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
+import org.apache.derby.iapi.sql.execute.ConstantAction;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.impl.sql.execute.ColumnInfo;
import org.apache.derby.impl.sql.execute.CreateConstraintConstantAction;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.StringDataValue;
-import java.util.Properties;
/**
* A CreateTableNode is the root of a QueryTree that represents a CREATE TABLE or DECLARE GLOBAL TEMPORARY TABLE
@@ -56,7 +49,7 @@ import java.util.Properties;
*
*/
-public class CreateTableNode extends DDLStatementNode
+class CreateTableNode extends DDLStatementNode
{
private char lockGranularity;
private boolean onCommitDeleteRows; //If true, on commit delete rows else on commit preserve rows of temporary table.
@@ -68,28 +61,30 @@ public class CreateTableNode extends DDL
private ResultSetNode queryExpression;
/**
- * Initializer for a CreateTableNode for a base table
+ * Constructor for a CreateTableNode for a base table
*
- * @param newObjectName The name of the new object being created (ie base table)
+ * @param tableName The name of the new object being created (ie base table)
* @param tableElementList The elements of the table: columns,
* constraints, etc.
* @param properties The optional list of properties associated with
* the table.
* @param lockGranularity The lock granularity.
+ * @param cm The context manager
*
* @exception StandardException Thrown on error
*/
-
- public void init(
- Object newObjectName,
- Object tableElementList,
- Object properties,
- Object lockGranularity)
- throws StandardException
+ CreateTableNode(
+ TableName tableName,
+ TableElementList tableElementList,
+ Properties properties,
+ char lockGranularity,
+ ContextManager cm) throws StandardException
{
- tableType = TableDescriptor.BASE_TABLE_TYPE;
- this.lockGranularity = ((Character) lockGranularity).charValue();
- implicitCreateSchema = true;
+ super(tableName, cm);
+ setNodeType(C_NodeTypes.CREATE_TABLE_NODE);
+ this.tableType = TableDescriptor.BASE_TABLE_TYPE;
+ this.lockGranularity = lockGranularity;
+ this.implicitCreateSchema = true;
if (SanityManager.DEBUG)
{
@@ -101,17 +96,17 @@ public class CreateTableNode extends DDL
}
}
- initAndCheck(newObjectName);
- this.tableElementList = (TableElementList) tableElementList;
- this.properties = (Properties) properties;
+ this.tableElementList = tableElementList;
+ this.properties = properties;
}
/**
- * Initializer for a CreateTableNode for a global temporary table
+ * Constructor for a CreateTableNode for a global temporary table
*
- * @param newObjectName The name of the new object being declared (ie temporary table)
- * @param tableElementList The elements of the table: columns,
- * constraints, etc.
+ * @param tableName The name of the new object being declared (ie
+ * temporary table)
+ * @param tableElementList The elements of the table: columns,
+ * constraints, etc.
* @param properties The optional list of properties associated with
* the table.
* @param onCommitDeleteRows If true, on commit delete rows else on commit preserve rows of temporary table.
@@ -119,22 +114,23 @@ public class CreateTableNode extends DDL
*
* @exception StandardException Thrown on error
*/
-
- public void init(
- Object newObjectName,
- Object tableElementList,
- Object properties,
- Object onCommitDeleteRows,
- Object onRollbackDeleteRows)
+ CreateTableNode(
+ TableName tableName,
+ TableElementList tableElementList,
+ Properties properties,
+ boolean onCommitDeleteRows,
+ boolean onRollbackDeleteRows,
+ ContextManager cm)
throws StandardException
{
- tableType = TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE;
- newObjectName = tempTableSchemaNameCheck(newObjectName);
- this.onCommitDeleteRows = ((Boolean) onCommitDeleteRows).booleanValue();
- this.onRollbackDeleteRows = ((Boolean) onRollbackDeleteRows).booleanValue();
- initAndCheck(newObjectName);
- this.tableElementList = (TableElementList) tableElementList;
- this.properties = (Properties) properties;
+ super(tempTableSchemaNameCheck(tableName), cm);
+ setNodeType(C_NodeTypes.CREATE_TABLE_NODE);
+
+ this.tableType = TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE;
+ this.onCommitDeleteRows = onCommitDeleteRows;
+ this.onRollbackDeleteRows = onRollbackDeleteRows;
+ this.tableElementList = tableElementList;
+ this.properties = properties;
if (SanityManager.DEBUG)
{
@@ -147,43 +143,51 @@ public class CreateTableNode extends DDL
}
/**
- * Initializer for a CreateTableNode for a base table create from a query
+ * Constructor for a CreateTableNode for a base table create from a query
*
- * @param newObjectName The name of the new object being created
+ * @param tableName The name of the new object being created
* (ie base table).
* @param resultColumns The optional column list.
* @param queryExpression The query expression for the table.
+ * @param cm The context manager
*/
- public void init(
- Object newObjectName,
- Object resultColumns,
- Object queryExpression)
- throws StandardException
+ CreateTableNode(
+ TableName tableName,
+ ResultColumnList resultColumns,
+ ResultSetNode queryExpression,
+ ContextManager cm) throws StandardException
{
- tableType = TableDescriptor.BASE_TABLE_TYPE;
- lockGranularity = TableDescriptor.DEFAULT_LOCK_GRANULARITY;
- implicitCreateSchema = true;
- initAndCheck(newObjectName);
- this.resultColumns = (ResultColumnList) resultColumns;
- this.queryExpression = (ResultSetNode) queryExpression;
+ super(tableName, cm);
+ setNodeType(C_NodeTypes.CREATE_TABLE_NODE);
+ this.tableType = TableDescriptor.BASE_TABLE_TYPE;
+ this.lockGranularity = TableDescriptor.DEFAULT_LOCK_GRANULARITY;
+ this.implicitCreateSchema = true;
+ this.resultColumns = resultColumns;
+ this.queryExpression = queryExpression;
}
/**
* If no schema name specified for global temporary table, SESSION is the implicit schema.
* Otherwise, make sure the specified schema name for global temporary table is SESSION.
- * @param objectName The name of the new object being declared (ie temporary table)
- */
- private Object tempTableSchemaNameCheck(Object objectName)
+ *
+ * @param tableName The name of the new object being declared (ie
+ * temporary table)
+ */
+ private static TableName tempTableSchemaNameCheck(TableName tableName)
throws StandardException {
- TableName tempTableName = (TableName) objectName;
- if (tempTableName != null)
+ if (tableName != null)
{
- if (tempTableName.getSchemaName() == null)
- tempTableName.setSchemaName(SchemaDescriptor.STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME); //If no schema specified, SESSION is the implicit schema.
- else if (!(isSessionSchema(tempTableName.getSchemaName())))
- throw StandardException.newException(SQLState.LANG_DECLARED_GLOBAL_TEMP_TABLE_ONLY_IN_SESSION_SCHEMA);
+ if (tableName.getSchemaName() == null) {
+ // If no schema specified, SESSION is the implicit schema.
+ tableName.setSchemaName(SchemaDescriptor.
+ STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME);
+
+ } else if (!(isSessionSchema(tableName.getSchemaName()))) {
+ throw StandardException.newException(SQLState.
+ LANG_DECLARED_GLOBAL_TEMP_TABLE_ONLY_IN_SESSION_SCHEMA);
+ }
}
- return(tempTableName);
+ return tableName;
}
/**
@@ -192,7 +196,7 @@ public class CreateTableNode extends DDL
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -221,7 +225,8 @@ public class CreateTableNode extends DDL
* how tree printing is supposed to work.
* @param depth The depth to indent the sub-nodes
*/
- public void printSubNodes(int depth) {
+ @Override
+ void printSubNodes(int depth) {
if (SanityManager.DEBUG) {
printLabel(depth, "tableElementList: ");
tableElementList.treePrint(depth + 1);
@@ -229,7 +234,7 @@ public class CreateTableNode extends DDL
}
- public String statementToString()
+ String statementToString()
{
if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)
return "DECLARE GLOBAL TEMPORARY TABLE";
@@ -247,24 +252,23 @@ public class CreateTableNode extends DDL
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void bindStatement() throws StandardException
{
DataDictionary dataDictionary = getDataDictionary();
- int numPrimaryKeys = 0;
- int numCheckConstraints = 0;
- int numReferenceConstraints = 0;
- int numUniqueConstraints = 0;
- int numGenerationClauses = 0;
+ int numPrimaryKeys;
+ int numCheckConstraints;
+ int numReferenceConstraints;
+ int numUniqueConstraints;
+ int numGenerationClauses;
SchemaDescriptor sd = getSchemaDescriptor
( tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE, true);
if (queryExpression != null)
{
- FromList fromList = (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
+ FromList fromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
getContextManager());
CompilerContext cc = getCompilerContext();
@@ -317,7 +321,7 @@ public class CreateTableNode extends DDL
int schemaCollationType = sd.getCollationType();
/* Create table element list from columns in query expression */
- tableElementList = new TableElementList();
+ tableElementList = new TableElementList(getContextManager());
for (int index = 0; index < qeRCL.size(); index++)
{
@@ -362,8 +366,12 @@ public class CreateTableNode extends DDL
DataTypeDescriptor.getCollationName(schemaCollationType));
}
- ColumnDefinitionNode column = (ColumnDefinitionNode) getNodeFactory().getNode
- ( C_NodeTypes.COLUMN_DEFINITION_NODE, rc.getName(), null, rc.getType(), null, getContextManager() );
+ ColumnDefinitionNode column = new ColumnDefinitionNode(
+ rc.getName(),
+ null,
+ rc.getType(),
+ null,
+ getContextManager() );
tableElementList.addTableElement(column);
}
} else {
@@ -467,6 +475,7 @@ public class CreateTableNode extends DDL
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -482,7 +491,8 @@ public class CreateTableNode extends DDL
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction() throws StandardException
+ @Override
+ public ConstantAction makeConstantAction() throws StandardException
{
TableElementList coldefs = tableElementList;
@@ -568,6 +578,7 @@ public class CreateTableNode extends DDL
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java Fri Jun 21 07:47:47 2013
@@ -27,11 +27,12 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-
import org.apache.derby.catalog.UUID;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
@@ -50,7 +51,7 @@ import org.apache.derby.iapi.sql.execute
*
*/
-public class CreateTriggerNode extends DDLStatementNode
+class CreateTriggerNode extends DDLStatementNode
{
private TableName triggerName;
private TableName tableName;
@@ -59,10 +60,9 @@ public class CreateTriggerNode extends D
private boolean isBefore;
private boolean isRow;
private boolean isEnabled;
- private List refClause;
+ private List<TriggerReferencingStruct> refClause;
private ValueNode whenClause;
private String whenText;
- private int whenOffset;
private StatementNode actionNode;
private String actionText;
private String originalActionText; // text w/o trim of spaces
@@ -197,7 +197,6 @@ public class CreateTriggerNode extends D
*/
private int[] referencedColsInTriggerAction;
private TableDescriptor triggerTableDescriptor;
- private UUID actionCompSchemaId;
/*
** Names of old and new table. By default we have
@@ -217,7 +216,7 @@ public class CreateTriggerNode extends D
/**
- * Initializer for a CreateTriggerNode
+ * Constructor for a CreateTriggerNode
*
* @param triggerName name of the trigger
* @param tableName name of the table which the trigger is declared upon
@@ -234,49 +233,49 @@ public class CreateTriggerNode extends D
* @param actionNode the trigger action tree
* @param actionText the text of the trigger action
* @param actionOffset offset of start of action clause
+ * @param cm context manager
*
* @exception StandardException Thrown on error
*/
- public void init
+ CreateTriggerNode
(
- Object triggerName,
- Object tableName,
- Object triggerEventMask,
- Object triggerCols,
- Object isBefore,
- Object isRow,
- Object isEnabled,
- Object refClause,
- Object whenClause,
- Object whenText,
- Object whenOffset,
- Object actionNode,
- Object actionText,
- Object actionOffset
+ TableName triggerName,
+ TableName tableName,
+ int triggerEventMask,
+ ResultColumnList triggerCols,
+ boolean isBefore,
+ boolean isRow,
+ boolean isEnabled,
+ List<TriggerReferencingStruct> refClause,
+ ValueNode whenClause,
+ String whenText,
+ int whenOffset,
+ StatementNode actionNode,
+ String actionText,
+ int actionOffset,
+ ContextManager cm
) throws StandardException
{
- initAndCheck(triggerName);
- this.triggerName = (TableName) triggerName;
- this.tableName = (TableName) tableName;
- this.triggerEventMask = ((Integer) triggerEventMask).intValue();
- this.triggerCols = (ResultColumnList) triggerCols;
- this.isBefore = ((Boolean) isBefore).booleanValue();
- this.isRow = ((Boolean) isRow).booleanValue();
- this.isEnabled = ((Boolean) isEnabled).booleanValue();
- this.refClause = (List) refClause;
- this.whenClause = (ValueNode) whenClause;
- this.whenText = (whenText == null) ? null : ((String) whenText).trim();
- this.whenOffset = ((Integer) whenOffset).intValue();
- this.actionNode = (StatementNode) actionNode;
- this.originalActionText = (String) actionText;
- this.actionText =
- (actionText == null) ? null : ((String) actionText).trim();
- this.actionOffset = ((Integer) actionOffset).intValue();
-
- implicitCreateSchema = true;
+ super(triggerName, cm);
+ setNodeType(C_NodeTypes.CREATE_TRIGGER_NODE);
+ this.triggerName = triggerName;
+ this.tableName = tableName;
+ this.triggerEventMask = triggerEventMask;
+ this.triggerCols = triggerCols;
+ this.isBefore = isBefore;
+ this.isRow = isRow;
+ this.isEnabled = isEnabled;
+ this.refClause = refClause;
+ this.whenClause = whenClause;
+ this.whenText = (whenText == null) ? null : whenText.trim();
+ this.actionNode = actionNode;
+ this.originalActionText = actionText;
+ this.actionText = (actionText == null) ? null : actionText.trim();
+ this.actionOffset = actionOffset;
+ this.implicitCreateSchema = true;
}
- public String statementToString()
+ String statementToString()
{
return "CREATE TRIGGER";
}
@@ -287,8 +286,8 @@ public class CreateTriggerNode extends D
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -325,6 +324,7 @@ public class CreateTriggerNode extends D
*
* @exception StandardException Thrown on error
*/
+ @Override
public void bindStatement() throws StandardException
{
CompilerContext compilerContext = getCompilerContext();
@@ -446,6 +446,7 @@ public class CreateTriggerNode extends D
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -593,7 +594,7 @@ public class CreateTriggerNode extends D
//This is a table level trigger
//Total Number of columns in the trigger table
int numberOfColsInTriggerTable = triggerTableDescriptor.getNumberOfColumns();
- StringBuffer newText = new StringBuffer();
+ StringBuilder newText = new StringBuilder();
/*
** For a statement trigger, we find all FromBaseTable nodes. If
** the from table is NEW or OLD (or user designated alternates
@@ -783,10 +784,8 @@ public class CreateTriggerNode extends D
return;
}
- for (Iterator it = refClause.iterator(); it.hasNext(); )
+ for (TriggerReferencingStruct trn : refClause)
{
- TriggerReferencingStruct trn = (TriggerReferencingStruct) it.next();
-
/*
** 1) Make sure that we don't try to refer
** to a table for a row trigger or a row for
@@ -857,6 +856,7 @@ public class CreateTriggerNode extends D
*
* @exception StandardException Thrown on failure
*/
+ @Override
public ConstantAction makeConstantAction() throws StandardException
{
String oldReferencingName = (oldTableInReferencingClause) ? oldTableName : null;
@@ -874,9 +874,7 @@ public class CreateTriggerNode extends D
whenText,
(UUID)null, // action SPSid
actionText,
- (actionCompSchemaId == null) ?
- compSchemaDescriptor.getUUID() :
- actionCompSchemaId,
+ compSchemaDescriptor.getUUID(),
(Timestamp)null, // creation time
referencedColInts,
referencedColsInTriggerAction,
@@ -895,6 +893,7 @@ public class CreateTriggerNode extends D
*
* @return This object as a String
*/
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -902,12 +901,10 @@ public class CreateTriggerNode extends D
String refString = "null";
if (refClause != null)
{
- StringBuffer buf = new StringBuffer();
- for (Iterator it = refClause.iterator(); it.hasNext(); )
+ StringBuilder buf = new StringBuilder();
+ for (TriggerReferencingStruct trn : refClause)
{
buf.append("\t");
- TriggerReferencingStruct trn =
- (TriggerReferencingStruct) it.next();
buf.append(trn.toString());
buf.append("\n");
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java Fri Jun 21 07:47:47 2013
@@ -21,35 +21,25 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.sql.compile.Visitor;
-
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.Limits;
+import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.compile.NodeFactory;
-
+import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.compile.OptimizerFactory;
+import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
import org.apache.derby.iapi.sql.depend.DependencyManager;
import org.apache.derby.iapi.sql.depend.ProviderInfo;
import org.apache.derby.iapi.sql.depend.ProviderList;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.Limits;
-
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.execute.ConstantAction;
-
import org.apache.derby.impl.sql.execute.ColumnInfo;
-import org.apache.derby.catalog.UUID;
/**
* A CreateViewNode is the root of a QueryTree that represents a CREATE VIEW
@@ -57,7 +47,7 @@ import org.apache.derby.catalog.UUID;
*
*/
-public class CreateViewNode extends DDLStatementNode
+class CreateViewNode extends DDLStatementNode
{
private ResultColumnList resultColumns;
private ResultSetNode queryExpression;
@@ -71,9 +61,9 @@ public class CreateViewNode extends DDLS
private boolean hasJDBClimitClause; // true if using JDBC limit/offset escape syntax
/**
- * Initializer for a CreateViewNode
+ * Constructor for a CreateViewNode
*
- * @param newObjectName The name of the table to be created
+ * @param viewName The name of the table to be created
* @param resultColumns The column list from the view definition,
* if specified
* @param queryExpression The query expression for the view
@@ -84,32 +74,32 @@ public class CreateViewNode extends DDLS
* @param offset OFFSET if any, or null
* @param fetchFirst FETCH FIRST if any, or null
* @param hasJDBClimitClause True if the offset/fetchFirst clauses come from JDBC limit/offset escape syntax
- *
+ * @param cm Context manager
* @exception StandardException Thrown on error
*/
-
- public void init(Object newObjectName,
- Object resultColumns,
- Object queryExpression,
- Object checkOption,
- Object qeText,
- Object orderCols,
- Object offset,
- Object fetchFirst,
- Object hasJDBClimitClause)
+ CreateViewNode(TableName viewName,
+ ResultColumnList resultColumns,
+ ResultSetNode queryExpression,
+ int checkOption,
+ String qeText,
+ OrderByList orderCols,
+ ValueNode offset,
+ ValueNode fetchFirst,
+ boolean hasJDBClimitClause,
+ ContextManager cm)
throws StandardException
{
- initAndCheck(newObjectName);
- this.resultColumns = (ResultColumnList) resultColumns;
- this.queryExpression = (ResultSetNode) queryExpression;
- this.checkOption = ((Integer) checkOption).intValue();
- this.qeText = ((String) qeText).trim();
- this.orderByList = (OrderByList)orderCols;
- this.offset = (ValueNode)offset;
- this.fetchFirst = (ValueNode)fetchFirst;
- this.hasJDBClimitClause = (hasJDBClimitClause == null) ? false : ((Boolean) hasJDBClimitClause).booleanValue();
-
- implicitCreateSchema = true;
+ super(viewName, cm);
+ setNodeType(C_NodeTypes.CREATE_VIEW_NODE);
+ this.resultColumns = resultColumns;
+ this.queryExpression = queryExpression;
+ this.checkOption = checkOption;
+ this.qeText = qeText.trim();
+ this.orderByList = orderCols;
+ this.offset = offset;
+ this.fetchFirst = fetchFirst;
+ this.hasJDBClimitClause = hasJDBClimitClause;
+ this.implicitCreateSchema = true;
}
/**
@@ -118,7 +108,7 @@ public class CreateViewNode extends DDLS
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -133,7 +123,7 @@ public class CreateViewNode extends DDLS
}
}
- public String statementToString()
+ String statementToString()
{
return "CREATE VIEW";
}
@@ -144,8 +134,8 @@ public class CreateViewNode extends DDLS
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -173,6 +163,7 @@ public class CreateViewNode extends DDLS
*
* @exception StandardException Thrown on error
*/
+ @Override
public void bindStatement() throws StandardException
{
CompilerContext cc = getCompilerContext();
@@ -184,7 +175,7 @@ public class CreateViewNode extends DDLS
providerInfos = bindViewDefinition
( dataDictionary, cc, getLanguageConnectionContext(),
- getNodeFactory(),
+ getOptimizerFactory(),
queryExpression,
getContextManager()
);
@@ -240,18 +231,16 @@ public class CreateViewNode extends DDLS
* @exception StandardException Thrown on error
*/
- private ProviderInfo[] bindViewDefinition( DataDictionary dataDictionary,
- CompilerContext compilerContext,
- LanguageConnectionContext lcc,
- NodeFactory nodeFactory,
- ResultSetNode queryExpr,
- ContextManager cm)
- throws StandardException
+ private ProviderInfo[] bindViewDefinition(
+ DataDictionary dataDictionary,
+ CompilerContext compilerContext,
+ LanguageConnectionContext lcc,
+ OptimizerFactory optimizerFactory,
+ ResultSetNode queryExpr,
+ ContextManager cm) throws StandardException
{
- FromList fromList = (FromList) nodeFactory.getNode(
- C_NodeTypes.FROM_LIST,
- nodeFactory.doJoinOrderOptimization(),
- cm);
+ FromList fromList =
+ new FromList(optimizerFactory.doJoinOrderOptimization(), cm);
ProviderList prevAPL = compilerContext.getCurrentAuxiliaryProviderList();
ProviderList apl = new ProviderList();
@@ -312,6 +301,7 @@ public class CreateViewNode extends DDLS
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -325,7 +315,8 @@ public class CreateViewNode extends DDLS
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction() throws StandardException
+ @Override
+ public ConstantAction makeConstantAction() throws StandardException
{
/* RESOLVE - need to build up dependendencies and store them away through
* the constant action.
@@ -401,6 +392,7 @@ public class CreateViewNode extends DDLS
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,34 +21,28 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.sql.compile.CompilerContext;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import java.sql.Types;
+import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.store.access.Qualifier;
-
-
-import org.apache.derby.iapi.error.StandardException;
-
-import java.sql.Types;
-
-import java.util.List;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
/**
* The CurrentDatetimeOperator operator is for the builtin CURRENT_DATE,
* CURRENT_TIME, and CURRENT_TIMESTAMP operations.
*
*/
-public class CurrentDatetimeOperatorNode extends ValueNode {
+class CurrentDatetimeOperatorNode extends ValueNode {
- public static final int CURRENT_DATE = 0;
- public static final int CURRENT_TIME = 1;
- public static final int CURRENT_TIMESTAMP = 2;
+ static final int CURRENT_DATE = 0;
+ static final int CURRENT_TIME = 1;
+ static final int CURRENT_TIMESTAMP = 2;
static private final int jdbcTypeId[] = {
Types.DATE,
@@ -63,11 +57,14 @@ public class CurrentDatetimeOperatorNode
private int whichType;
- public void init(Object whichType) {
- this.whichType = ((Integer) whichType).intValue();
+ CurrentDatetimeOperatorNode(int whichType, ContextManager cm) {
+ super(cm);
+ setNodeType(C_NodeTypes.CURRENT_DATETIME_OPERATOR_NODE);
+ this.whichType = whichType;
- if (SanityManager.DEBUG)
+ if (SanityManager.DEBUG) {
SanityManager.ASSERT(this.whichType >= 0 && this.whichType <= 2);
+ }
}
//
@@ -89,8 +86,11 @@ public class CurrentDatetimeOperatorNode
*
* @exception StandardException Thrown on error
*/
- ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List aggregates)
- throws StandardException
+ @Override
+ ValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates)
+ throws StandardException
{
checkReliability( methodName[whichType], CompilerContext.DATETIME_ILLEGAL );
@@ -114,6 +114,7 @@ public class CurrentDatetimeOperatorNode
*
* @return The variant type for the underlying expression.
*/
+ @Override
protected int getOrderableVariantType()
{
// CurrentDate, Time, Timestamp are invariant for the life of the query
@@ -133,6 +134,7 @@ public class CurrentDatetimeOperatorNode
*
* @exception StandardException Thrown on error
*/
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -159,6 +161,7 @@ public class CurrentDatetimeOperatorNode
/*
print the non-node subfields
*/
+ @Override
public String toString() {
if (SanityManager.DEBUG)
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java Fri Jun 21 07:47:47 2013
@@ -21,40 +21,32 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
-import org.apache.derby.iapi.sql.compile.Optimizer;
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.Activation;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
+import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
+import org.apache.derby.iapi.sql.compile.Optimizer;
import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
import org.apache.derby.iapi.sql.compile.RowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList;
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;
import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
-
-import org.apache.derby.iapi.sql.Activation;
-
-import org.apache.derby.iapi.reference.SQLState;
-
import org.apache.derby.iapi.store.access.TransactionController;
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
/**
* The CurrentOf operator is used by positioned DELETE
@@ -81,10 +73,14 @@ public final class CurrentOfNode extends
//
// initializers
//
- public void init( Object correlationName, Object cursor, Object tableProperties)
+ CurrentOfNode(String correlationName,
+ String cursor,
+ Properties tableProperties,
+ ContextManager cm)
{
- super.init(correlationName, tableProperties);
- cursorName = (String) cursor;
+ super(correlationName, tableProperties, cm);
+ setNodeType(C_NodeTypes.CURRENT_OF_NODE);
+ cursorName = cursor;
}
/*
@@ -96,6 +92,7 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
+ @Override
public CostEstimate estimateCost(OptimizablePredicateList predList,
ConglomerateDescriptor cd,
CostEstimate outerCost,
@@ -143,7 +140,8 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode bindNonVTITables(DataDictionary dataDictionary,
+ @Override
+ ResultSetNode bindNonVTITables(DataDictionary dataDictionary,
FromList fromListParam)
throws StandardException {
@@ -171,8 +169,8 @@ public final class CurrentOfNode extends
exposedTableName = makeTableName(null, refTab.getExposedName());
baseTableName = makeTableName(schemaName,
refTab.getBaseName());
- SchemaDescriptor tableSchema = null;
- tableSchema = getSchemaDescriptor(refTab.getSchemaName());
+ SchemaDescriptor tableSchema =
+ getSchemaDescriptor(refTab.getSchemaName());
/*
** This will only happen when we are binding against a publication
@@ -207,28 +205,22 @@ public final class CurrentOfNode extends
** the result columns from preparedStatement and
** turn them into an RCL that we can run with.
*/
- resultColumns = (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ resultColumns = new ResultColumnList(getContextManager());
ColumnDescriptorList cdl = td.getColumnDescriptorList();
int cdlSize = cdl.size();
for (int index = 0; index < cdlSize; index++)
{
/* Build a ResultColumn/BaseColumnNode pair for the column */
- ColumnDescriptor colDesc = (ColumnDescriptor) cdl.elementAt(index);
+ ColumnDescriptor colDesc = cdl.elementAt(index);
- BaseColumnNode bcn = (BaseColumnNode) getNodeFactory().getNode(
- C_NodeTypes.BASE_COLUMN_NODE,
- colDesc.getColumnName(),
+ BaseColumnNode bcn = new BaseColumnNode(
+ colDesc.getColumnName(),
exposedTableName,
colDesc.getType(),
getContextManager());
- ResultColumn rc = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- colDesc,
- bcn,
- getContextManager());
+ ResultColumn rc = new ResultColumn(
+ colDesc, bcn, getContextManager());
/* Build the ResultColumnList to return */
resultColumns.addResultColumn(rc);
@@ -248,7 +240,8 @@ public final class CurrentOfNode extends
*
* @param fromListParam FromList to use/append to.
*/
- public void bindExpressions(FromList fromListParam)
+ @Override
+ void bindExpressions(FromList fromListParam)
{
/* No expressions to bind for a CurrentOfNode.
* NOTE - too involved to optimize so that this method
@@ -269,8 +262,8 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
-
- public ResultColumn getMatchingColumn(ColumnReference columnReference)
+ @Override
+ ResultColumn getMatchingColumn(ColumnReference columnReference)
throws StandardException {
ResultColumn resultColumn = null;
@@ -316,7 +309,7 @@ public final class CurrentOfNode extends
((correlationName != null) && correlationName.equals( columnsTableName.getTableName()))
)
{
- boolean notfound = false;
+ boolean notfound;
resultColumn =
resultColumns.getResultColumn(columnReference.getColumnName());
@@ -370,8 +363,8 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
-
- public ResultSetNode preprocess(int numTables,
+ @Override
+ ResultSetNode preprocess(int numTables,
GroupByList gbl,
FromList fromList)
throws StandardException
@@ -394,23 +387,23 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode optimize(DataDictionary dataDictionary,
+ @Override
+ ResultSetNode optimize(DataDictionary dataDictionary,
PredicateList predicateList,
double outerRows)
throws StandardException {
/* Get an optimizer so we can get a cost */
- Optimizer optimizer = getOptimizer(
- (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- this,
- getContextManager()),
- predicateList,
- dataDictionary,
- (RequiredRowOrdering) null);
+ Optimizer opt =
+ getOptimizer(new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ this,
+ getContextManager()),
+ predicateList,
+ dataDictionary,
+ (RequiredRowOrdering) null);
/* Assume there is no cost associated with fetching the current row */
- bestCostEstimate = optimizer.newCostEstimate();
+ bestCostEstimate = opt.newCostEstimate();
bestCostEstimate.setCost(0.0d, outerRows, outerRows);
return this;
@@ -430,6 +423,7 @@ public final class CurrentOfNode extends
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException {
@@ -497,7 +491,8 @@ public final class CurrentOfNode extends
*
* @param depth The depth of this node in the tree
*/
- public void printSubNodes(int depth) {
+ @Override
+ void printSubNodes(int depth) {
if (SanityManager.DEBUG) {
super.printSubNodes(depth);
@@ -511,6 +506,7 @@ public final class CurrentOfNode extends
*
* @return This object as a String
*/
+ @Override
public String toString() {
if (SanityManager.DEBUG) {
return "preparedStatement: " +
@@ -523,25 +519,42 @@ public final class CurrentOfNode extends
}
}
- //
- // class interface
- //
-
- public String getExposedName()
+ @Override
+ String getExposedName()
{
return exposedTableName.getFullTableName();
}
- public TableName getExposedTableName()
+
+ /**
+ * Get the lock mode for this table as the target of an update statement
+ * (a delete or update). This is implemented only for base tables and
+ * CurrentOfNodes.
+ *
+ * @see TransactionController
+ *
+ * @return The lock mode
+ */
+ @Override
+ public int updateTargetLockMode()
+ {
+ /* Do row locking for positioned update/delete */
+ return TransactionController.MODE_RECORD;
+ }
+
+ //
+ // class interface
+ //
+ TableName getExposedTableName()
{
return exposedTableName;
}
- public TableName getBaseCursorTargetTableName()
+ TableName getBaseCursorTargetTableName()
{
return baseTableName;
}
- public String getCursorName()
+ String getCursorName()
{
return cursorName;
}
@@ -561,19 +574,4 @@ public final class CurrentOfNode extends
return activation.getPreparedStatement();
}
-
- /**
- * Get the lock mode for this table as the target of an update statement
- * (a delete or update). This is implemented only for base tables and
- * CurrentOfNodes.
- *
- * @see TransactionController
- *
- * @return The lock mode
- */
- public int updateTargetLockMode()
- {
- /* Do row locking for positioned update/delete */
- return TransactionController.MODE_RECORD;
- }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentRowLocationNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentRowLocationNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentRowLocationNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentRowLocationNode.java Fri Jun 21 07:47:47 2013
@@ -21,21 +21,17 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
-
-
import java.lang.reflect.Modifier;
import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.ClassName;
-
import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
/**
* The CurrentRowLocation operator is used by DELETE and UPDATE to get the
@@ -44,8 +40,14 @@ import org.apache.derby.iapi.error.Stand
* that represents the ResultSet to be deleted or updated.
*/
-public class CurrentRowLocationNode extends ValueNode
+class CurrentRowLocationNode extends ValueNode
{
+
+ CurrentRowLocationNode(ContextManager cm) {
+ super(cm);
+ setNodeType(C_NodeTypes.CURRENT_ROW_LOCATION_NODE);
+ }
+
/**
* Binding this expression means setting the result DataTypeServices.
* In this case, the result type is always the same.
@@ -59,9 +61,11 @@ public class CurrentRowLocationNode exte
*
* @exception StandardException Thrown on error
*/
-
- ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List aggregates)
- throws StandardException
+ @Override
+ ValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates)
+ throws StandardException
{
setType(new DataTypeDescriptor(TypeId.getBuiltInTypeId(TypeId.REF_NAME),
false /* Not nullable */
@@ -82,7 +86,7 @@ public class CurrentRowLocationNode exte
*
* ...
*
- * public DataValueDescriptor exprx()
+ * DataValueDescriptor exprx()
* throws StandardException
* {
* return fieldx = <SQLRefConstructor>(
@@ -107,6 +111,7 @@ public class CurrentRowLocationNode exte
*
* @exception StandardException Thrown on error
*/
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mbex)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Fri Jun 21 07:47:47 2013
@@ -24,10 +24,10 @@ package org.apache.derby.impl.sql.compil
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.Visitor;
@@ -48,9 +48,9 @@ import org.apache.derby.impl.sql.CursorT
public class CursorNode extends DMLStatementNode
{
- public final static int UNSPECIFIED = 0;
+ final static int UNSPECIFIED = 0;
public final static int READ_ONLY = 1;
- public final static int UPDATE = 2;
+ final static int UPDATE = 2;
private String name;
private OrderByList orderByList;
@@ -80,57 +80,64 @@ public class CursorNode extends DMLState
private int indexOfSessionTableNamesInSavedObjects = -1;
/**
- * Initializer for a CursorNode
+ * Constructor for a CursorNode
*
- * @param statementType Type of statement (SELECT, UPDATE, INSERT)
- * @param resultSet A ResultSetNode specifying the result set for
- * the cursor
- * @param name The name of the cursor, null if no name
- * @param orderByList The order by list for the cursor, null if no
- * order by list
- * @param offset The value of a <result offset clause> if present
- * @param fetchFirst The value of a <fetch first clause> if present
- * @param hasJDBClimitClause True if the offset/fetchFirst clauses come from JDBC limit/offset escape syntax
- * @param updateMode The user-specified update mode for the cursor,
- * for example, CursorNode.READ_ONLY
- * @param updatableColumns The array of updatable columns specified by
- * the user in the FOR UPDATE clause, null if no
- * updatable columns specified. May only be
- * provided if the updateMode parameter is
- * CursorNode.UPDATE.
- */
- public void init(
- Object statementType,
- Object resultSet,
- Object name,
- Object orderByList,
- Object offset,
- Object fetchFirst,
- Object hasJDBClimitClause,
- Object updateMode,
- Object updatableColumns)
- {
- init(resultSet);
- this.name = (String) name;
- this.statementType = (String) statementType;
- this.orderByList = (OrderByList) orderByList;
- this.offset = (ValueNode)offset;
- this.fetchFirst = (ValueNode)fetchFirst;
- this.hasJDBClimitClause = (hasJDBClimitClause == null) ? false : ((Boolean) hasJDBClimitClause).booleanValue();
-
- this.updateMode = ((Integer) updateMode).intValue();
+ * @param statementType Type of statement (SELECT, UPDATE, INSERT)
+ * @param resultSet A ResultSetNode specifying the result set for
+ * the cursor
+ * @param name The name of the cursor, null if no name
+ * @param orderByList The order by list for the cursor, null if no
+ * order by list
+ * @param offset The value of a <result offset clause> if
+ * present
+ * @param fetchFirst The value of a <fetch first clause> if present
+ * @param hasJDBClimitClause True if the offset/fetchFirst clauses come
+ * from JDBC limit/offset escape syntax
+ * @param updateMode The user-specified update mode for the cursor,
+ * for example, CursorNode.READ_ONLY
+ * @param updatableColumns The array of updatable columns specified by
+ * the user in the FOR UPDATE clause, null if no
+ * updatable columns specified. May only be
+ * provided if the updateMode parameter is
+ * CursorNode.UPDATE.
+ * @param cm The context manager
+ */
+ CursorNode(String statementType,
+ ResultSetNode resultSet,
+ String name,
+ OrderByList orderByList,
+ ValueNode offset,
+ ValueNode fetchFirst,
+ boolean hasJDBClimitClause,
+ int updateMode,
+ String[] updatableColumns,
+ ContextManager cm)
+ {
+ super(resultSet, cm);
+ setNodeType(C_NodeTypes.CURSOR_NODE);
+ this.name = name;
+ this.statementType = statementType;
+ this.orderByList = orderByList;
+ this.offset = offset;
+ this.fetchFirst = fetchFirst;
+ this.hasJDBClimitClause = hasJDBClimitClause;
+ this.updateMode = updateMode;
this.updatableColumns =
updatableColumns == null ?
- null : Arrays.asList((String[]) updatableColumns);
+ null : Arrays.asList(updatableColumns);
/*
** This is a sanity check and not an error since the parser
** controls setting updatableColumns and updateMode.
*/
- if (SanityManager.DEBUG)
- SanityManager.ASSERT(this.updatableColumns == null ||
- this.updatableColumns.isEmpty() || this.updateMode == UPDATE,
- "Can only have explicit updatable columns if update mode is UPDATE");
+ if (SanityManager.DEBUG) {
+ SanityManager.ASSERT(
+ this.updatableColumns == null ||
+ this.updatableColumns.isEmpty() ||
+ this.updateMode == UPDATE,
+ "Can only have explicit updatable columns if " +
+ "update mode is UPDATE");
+ }
}
/**
@@ -139,7 +146,7 @@ public class CursorNode extends DMLState
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -154,7 +161,7 @@ public class CursorNode extends DMLState
}
}
- public String statementToString()
+ String statementToString()
{
return statementType;
}
@@ -198,8 +205,8 @@ public class CursorNode extends DMLState
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -232,7 +239,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void bindStatement() throws StandardException
{
DataDictionary dataDictionary;
@@ -257,9 +264,8 @@ public class CursorNode extends DMLState
getCompilerContext().pushCurrentPrivType(getPrivType());
try {
- FromList fromList = (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
+ FromList fromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
getContextManager());
/* Check for ? parameters directly under the ResultColums */
@@ -366,12 +372,10 @@ public class CursorNode extends DMLState
bindUpdateColumns(updateTable);
// If the target table is a FromBaseTable, mark the updatable
- // columns. (I can't think of a way that an updatable table
- // could be anything but a FromBaseTable at this point, but
- // it's better to be careful.
- if (updateTable instanceof FromTable)
+ // columns.
+ if (updateTable != null)
{
- ((FromTable) updateTable).markUpdatableByCursor(updatableColumns);
+ updateTable.markUpdatableByCursor(updatableColumns);
//make sure that alongwith the FromTable, we keep other ResultSetLists
//in correct state too. ResultSetMetaData.isWritable looks at this to
//return the correct value.
@@ -438,6 +442,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -572,7 +577,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void optimizeStatement() throws StandardException
{
// Push the order by list down to the ResultSet
@@ -603,7 +608,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException Thrown on error
*/
-
+ @Override
int activationKind()
{
return NEED_CURSOR_ACTIVATION;
@@ -617,7 +622,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException Thrown on error
*/
-
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
{
if (indexOfSessionTableNamesInSavedObjects != -1 ) //if this cursor references session schema tables, do following
@@ -656,25 +661,25 @@ public class CursorNode extends DMLState
// class interface
- public String getUpdateBaseTableName()
+ String getUpdateBaseTableName()
{
return (updateTable == null) ? null : updateTable.getBaseTableName();
}
- public String getUpdateExposedTableName()
+ String getUpdateExposedTableName()
throws StandardException
{
return (updateTable == null) ? null : updateTable.getExposedName();
}
- public String getUpdateSchemaName()
+ String getUpdateSchemaName()
throws StandardException
{
//we need to use the base table for the schema name
return (updateTable == null) ? null : ((FromBaseTable)updateTable).getTableNameField().getSchemaName();
}
- public int getUpdateMode()
+ int getUpdateMode()
{
return updateMode;
}
@@ -687,6 +692,7 @@ public class CursorNode extends DMLState
*
* @return boolean Whether or not this Statement requires a set/clear savepoint
*/
+ @Override
public boolean needsSavepoint()
{
return false;
@@ -700,6 +706,7 @@ public class CursorNode extends DMLState
* @return the cursor info
* @exception StandardException thrown if generation fails
*/
+ @Override
public Object getCursorInfo()
throws StandardException
{
@@ -758,7 +765,7 @@ public class CursorNode extends DMLState
}
}
- public String getXML()
+ String getXML()
{
return null;
}
@@ -771,6 +778,7 @@ public class CursorNode extends DMLState
* @throws StandardException if accessing the index descriptors of a base
* table fails
*/
+ @Override
public TableDescriptor[] updateIndexStatisticsFor()
throws StandardException {
if (!checkIndexStats || statsToUpdate == null) {
@@ -802,6 +810,7 @@ public class CursorNode extends DMLState
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,24 +21,19 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
import java.lang.reflect.Modifier;
-
import java.sql.Types;
-
import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
/**
* This node represents a unary DB2 compatible length operator
@@ -47,19 +42,18 @@ import java.util.List;
public final class DB2LengthOperatorNode extends UnaryOperatorNode
{
-
- /**
- * Initializer for a DB2LengthOperatorNode
- *
- * @param operand The operand of the node
- */
- public void init(Object operand)
- {
- super.init( operand, "length", "getDB2Length");
+ /**
+ * @param operand The operand of the node
+ * @param cm context manager
+ * @throws StandardException
+ */
+ DB2LengthOperatorNode(ValueNode operand, ContextManager cm)
+ throws StandardException {
+ super(operand, "length", "getDB2Length", cm);
+ setNodeType(C_NodeTypes.DB2_LENGTH_OPERATOR_NODE);
}
-
- /**
+ /**
* Bind this operator
*
* @param fromList The query's FROM list
@@ -70,7 +64,7 @@ public final class DB2LengthOperatorNode
*
* @exception StandardException Thrown on error
*/
-
+ @Override
ValueNode bindExpression(
FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
throws StandardException
@@ -94,7 +88,8 @@ public final class DB2LengthOperatorNode
* This is a length operator node. Overrides this method
* in UnaryOperatorNode for code generation purposes.
*/
- public String getReceiverInterfaceName() {
+ @Override
+ String getReceiverInterfaceName() {
return ClassName.ConcatableDataValue;
}
@@ -107,7 +102,7 @@ public final class DB2LengthOperatorNode
*
* @exception StandardException Thrown on error
*/
-
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java Fri Jun 21 07:47:47 2013
@@ -21,26 +21,19 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.sql.ResultSet;
-
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.conn.Authorizer;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-import org.apache.derby.catalog.UUID;
/**
* A DDLStatementNode represents any type of DDL statement: CREATE TABLE,
@@ -71,7 +64,7 @@ abstract class DDLStatementNode extends
//
/////////////////////////////////////////////////////////////////////////
- private TableName objectName;
+ private TableName tableName;
private boolean initOk;
/**
@@ -87,10 +80,16 @@ abstract class DDLStatementNode extends
//
/////////////////////////////////////////////////////////////////////////
- public void init(Object objectName)
- throws StandardException {
- initAndCheck(objectName);
- }
+ DDLStatementNode(TableName tableName, ContextManager cm) {
+ super(cm);
+ this.tableName = tableName;
+ initOk = true;
+ }
+
+ DDLStatementNode(ContextManager cm) {
+ super(cm);
+ }
+
/**
Initialize the object name we will be performing the DDL
@@ -100,7 +99,7 @@ abstract class DDLStatementNode extends
protected void initAndCheck(Object objectName)
throws StandardException {
- this.objectName = (TableName) objectName;
+ this.tableName = (TableName) objectName;
initOk = true;
}
@@ -110,6 +109,7 @@ abstract class DDLStatementNode extends
*
* @return true
*/
+ @Override
public boolean isAtomic()
{
return true;
@@ -121,9 +121,9 @@ abstract class DDLStatementNode extends
*
* @return the relative name
*/
- public String getRelativeName()
+ String getRelativeName()
{
- return objectName.getTableName() ;
+ return tableName.getTableName() ;
}
/**
@@ -132,12 +132,12 @@ abstract class DDLStatementNode extends
*
* @return the full name
*/
- public String getFullName()
+ String getFullName()
{
- return objectName.getFullTableName() ;
+ return tableName.getFullTableName() ;
}
- public final TableName getObjectName() { return objectName; }
+ public final TableName getObjectName() { return tableName; }
/**
* Convert this object to a String. See comments in QueryTreeNode.java
@@ -145,13 +145,13 @@ abstract class DDLStatementNode extends
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
{
- return ((objectName==null)?"":
- "name: " + objectName.toString() +"\n") + super.toString();
+ return ((tableName==null)?"":
+ "name: " + tableName.toString() +"\n") + super.toString();
}
else
{
@@ -172,7 +172,7 @@ abstract class DDLStatementNode extends
*
* @exception StandardException Thrown on error
*/
-
+ @Override
final void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -244,7 +244,7 @@ abstract class DDLStatementNode extends
boolean doSystemSchemaCheck)
throws StandardException
{
- String schemaName = objectName.getSchemaName();
+ String schemaName = tableName.getSchemaName();
//boolean needError = !(implicitCreateSchema || (schemaName == null));
boolean needError = !implicitCreateSchema;
SchemaDescriptor sd = getSchemaDescriptor(schemaName, needError);
@@ -285,7 +285,7 @@ abstract class DDLStatementNode extends
protected final TableDescriptor getTableDescriptor()
throws StandardException
{
- return getTableDescriptor(objectName);
+ return getTableDescriptor(tableName);
}
/**
@@ -306,7 +306,7 @@ abstract class DDLStatementNode extends
protected final TableDescriptor getTableDescriptor(boolean doSystemTableCheck)
throws StandardException
{
- TableDescriptor td = justGetDescriptor(objectName);
+ TableDescriptor td = justGetDescriptor(tableName);
td = checkTableDescriptor(td,doSystemTableCheck);
return td;
}
@@ -428,8 +428,8 @@ abstract class DDLStatementNode extends
void bindName( DataDictionary dataDictionary )
throws StandardException
{
- if (objectName != null)
- objectName.bind( dataDictionary );
+ if (tableName != null)
+ tableName.bind( dataDictionary );
}
/**
@@ -452,15 +452,11 @@ abstract class DDLStatementNode extends
if (tableName.getSchemaName() == null)
{ tableName.setSchemaName(getSchemaDescriptor().getSchemaName()); }
- FromList fromList = (FromList) getNodeFactory().getNode
- (
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager()
- );
- FromBaseTable table = (FromBaseTable) getNodeFactory().getNode
- (
- C_NodeTypes.FROM_BASE_TABLE,
+ FromList fromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager());
+
+ FromBaseTable table = new FromBaseTable(
tableName,
null,
null,
@@ -472,27 +468,16 @@ abstract class DDLStatementNode extends
{
table.setTableNumber(0);
fromList.addFromTable(table);
- table.setResultColumns
- ((ResultColumnList) getNodeFactory().getNode
- (
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager()
- )
- );
+ table.setResultColumns(new ResultColumnList(getContextManager()));
}
else // ALTER TABLE
{
fromList.addFromTable(table);
- fromList.bindTables
- (
+ fromList.bindTables(
dd,
- (FromList) getNodeFactory().getNode
- (
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager()
- )
- );
+ new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager()));
}
tableElementList.appendNewColumnsToRCL(table);