org.apache.derby.impl.sql.compile
Class TableElementList

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.QueryTreeNodeVector
          extended byorg.apache.derby.impl.sql.compile.TableElementList
All Implemented Interfaces:
Visitable

public class TableElementList
extends QueryTreeNodeVector

A TableElementList represents the list of columns and other table elements such as constraints in a CREATE TABLE or ALTER TABLE statement.

Author:
Jeff Lichtman

Field Summary
private  int numColumns
           
private  TableDescriptor td
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
TableElementList()
           
 
Method Summary
 Visitable accept(Visitor v)
          Accept a visitor, and call v.visit() on child nodes as necessary.
 void addElement(QueryTreeNode qt)
           
 void addTableElement(TableElementNode tableElement)
          Add a TableElementNode to this TableElementList
 void appendNewColumnsToRCL(FromBaseTable table)
          Append goobered up ResultColumns to the table's RCL.
(package private)  void bindAndValidateCheckConstraints(FromList fromList)
          Bind and validate all of the check constraints in this list against the specified FromList.
private  void checkForDuplicateColumns(DDLStatementNode ddlStmt, java.util.Hashtable ht, java.lang.String colName)
          Check to make sure that there are no duplicate column names in the list.
private  void checkForDuplicateConstraintNames(DDLStatementNode ddlStmt, java.util.Hashtable ht, java.lang.String constraintName)
          Check to make sure that there are no duplicate constraint names in the list.
private  void checkForNullColumns(ConstraintDefinitionNode cdn, TableDescriptor td)
           
private  boolean columnsMatch(java.lang.String[] columnNames1, java.lang.String[] columnNames2)
           
 boolean containsColumnName(java.lang.String colName)
          Determine whether or not the parameter matches a column name in this list.
 int countConstraints(int constraintType)
          Count the number of constraints of the specified type.
 int countNumberOfColumns()
          Count the number of columns.
 void destructiveAppend(QueryTreeNodeVector qtnv)
           
 QueryTreeNode elementAt(int index)
           
 int genColumnInfos(ColumnInfo[] colInfos)
          Fill in the ColumnInfo[] for this table element list.
(package private)  void genConstraintActions(ConstraintConstantAction[] conActions, java.lang.String tableName, SchemaDescriptor tableSd, DataDictionary dd)
          Fill in the ConstraintConstantAction[] for this create/alter table.
private  IndexConstantAction genIndexAction(boolean isUnique, java.lang.String indexName, ConstraintDefinitionNode cdn, java.lang.String[] columnNames, boolean isConstraint, SchemaDescriptor sd, java.lang.String tableName, int constraintType, DataDictionary dd)
           
private  DataTypeDescriptor getColumnDataTypeDescriptor(java.lang.String colName)
           
private  DataTypeDescriptor getColumnDataTypeDescriptor(java.lang.String colName, TableDescriptor td)
           
(package private)  int indexOf(QueryTreeNode qt)
           
(package private)  void insertElementAt(QueryTreeNode qt, int index)
           
 void nondestructiveAppend(QueryTreeNodeVector qtnv)
           
(package private)  java.lang.Object remove(int index)
           
(package private)  void removeAllElements()
           
(package private)  void removeElement(QueryTreeNode qt)
           
(package private)  void removeElementAt(int index)
           
private  void setColumnListToNotNull(ConstraintDefinitionNode cdn)
          Set all columns in that appear in a PRIMARY KEY constraint in a CREATE TABLE statement to NOT NULL.
(package private)  void setElementAt(QueryTreeNode qt, int index)
           
 int size()
           
 java.lang.String toString()
          Convert this object to a String.
(package private)  void validate(DDLStatementNode ddlStmt, DataDictionary dd, TableDescriptor td)
          Validate this TableElementList.
private  void verifyUniqueColumnList(DDLStatementNode ddlStmt, ConstraintDefinitionNode cdn)
          Verify that a primary/unique table constraint has a valid column list.
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numColumns

private int numColumns

td

private TableDescriptor td
Constructor Detail

TableElementList

public TableElementList()
Method Detail

addTableElement

public void addTableElement(TableElementNode tableElement)
Add a TableElementNode to this TableElementList

Parameters:
tableElement - The TableElementNode to add to this list

toString

public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class QueryTreeNodeVector
Returns:
This object as a String

validate

void validate(DDLStatementNode ddlStmt,
              DataDictionary dd,
              TableDescriptor td)
        throws StandardException
Validate this TableElementList. This includes checking for duplicate columns names, and checking that user types really exist.

Parameters:
ddlStmt - DDLStatementNode which contains this list
dd - DataDictionary to use
td - TableDescriptor for table, if existing table.
Throws:
StandardException - Thrown on error

countConstraints

public int countConstraints(int constraintType)
Count the number of constraints of the specified type.

Parameters:
constraintType - The constraint type to search for.
Returns:
int The number of constraints of the specified type.

countNumberOfColumns

public int countNumberOfColumns()
Count the number of columns.

Returns:
int The number of columns.

genColumnInfos

public int genColumnInfos(ColumnInfo[] colInfos)
Fill in the ColumnInfo[] for this table element list.

Parameters:
colInfos - The ColumnInfo[] to be filled in.
Returns:
int The number of constraints in the create table.

appendNewColumnsToRCL

public void appendNewColumnsToRCL(FromBaseTable table)
                           throws StandardException
Append goobered up ResultColumns to the table's RCL. This is useful for binding check constraints for CREATE and ALTER TABLE.

Parameters:
table - The table in question.
Throws:
StandardException - Thrown on error

bindAndValidateCheckConstraints

void bindAndValidateCheckConstraints(FromList fromList)
                               throws StandardException
Bind and validate all of the check constraints in this list against the specified FromList.

Parameters:
fromList - The FromList in question.
Throws:
StandardException - Thrown on error

genConstraintActions

void genConstraintActions(ConstraintConstantAction[] conActions,
                          java.lang.String tableName,
                          SchemaDescriptor tableSd,
                          DataDictionary dd)
                    throws StandardException
Fill in the ConstraintConstantAction[] for this create/alter table.

Parameters:
conActions - The ConstraintConstantAction[] to be filled in.
tableName - The name of the Table being created.
tableSd - The schema for that table.
dd - The DataDictionary
Throws:
StandardException - Thrown on failure

columnsMatch

private boolean columnsMatch(java.lang.String[] columnNames1,
                             java.lang.String[] columnNames2)

genIndexAction

private IndexConstantAction genIndexAction(boolean isUnique,
                                           java.lang.String indexName,
                                           ConstraintDefinitionNode cdn,
                                           java.lang.String[] columnNames,
                                           boolean isConstraint,
                                           SchemaDescriptor sd,
                                           java.lang.String tableName,
                                           int constraintType,
                                           DataDictionary dd)
                                    throws StandardException
Throws:
StandardException

checkForDuplicateColumns

private void checkForDuplicateColumns(DDLStatementNode ddlStmt,
                                      java.util.Hashtable ht,
                                      java.lang.String colName)
                               throws StandardException
Check to make sure that there are no duplicate column names in the list. (The comparison here is case sensitive. The work of converting column names that are not quoted identifiers to upper case is handled by the parser.) RESOLVE: This check will also be performed by alter table.

Parameters:
ddlStmt - DDLStatementNode which contains this list
ht - Hashtable for enforcing uniqueness.
colName - Column name to check for.
Throws:
StandardException - Thrown on error

checkForDuplicateConstraintNames

private void checkForDuplicateConstraintNames(DDLStatementNode ddlStmt,
                                              java.util.Hashtable ht,
                                              java.lang.String constraintName)
                                       throws StandardException
Check to make sure that there are no duplicate constraint names in the list. (The comparison here is case sensitive. The work of converting column names that are not quoted identifiers to upper case is handled by the parser.) RESOLVE: This check will also be performed by alter table.

Parameters:
ddlStmt - DDLStatementNode which contains this list
Throws:
StandardException - Thrown on error

verifyUniqueColumnList

private void verifyUniqueColumnList(DDLStatementNode ddlStmt,
                                    ConstraintDefinitionNode cdn)
                             throws StandardException
Verify that a primary/unique table constraint has a valid column list. (All columns in table and no duplicates.)

Parameters:
ddlStmt - The outer DDLStatementNode
cdn - The ConstraintDefinitionNode
Throws:
StandardException - Thrown if the column list is invalid

setColumnListToNotNull

private void setColumnListToNotNull(ConstraintDefinitionNode cdn)
Set all columns in that appear in a PRIMARY KEY constraint in a CREATE TABLE statement to NOT NULL.

Parameters:
cdn - The ConstraintDefinitionNode for a PRIMARY KEY constraint

checkForNullColumns

private void checkForNullColumns(ConstraintDefinitionNode cdn,
                                 TableDescriptor td)
                          throws StandardException
Throws:
StandardException

getColumnDataTypeDescriptor

private DataTypeDescriptor getColumnDataTypeDescriptor(java.lang.String colName)

getColumnDataTypeDescriptor

private DataTypeDescriptor getColumnDataTypeDescriptor(java.lang.String colName,
                                                       TableDescriptor td)

containsColumnName

public boolean containsColumnName(java.lang.String colName)
Determine whether or not the parameter matches a column name in this list.

Parameters:
colName - The column name to search for.
Returns:
boolean Whether or not a match is found.

size

public final int size()

elementAt

public QueryTreeNode elementAt(int index)

addElement

public final void addElement(QueryTreeNode qt)

removeElementAt

final void removeElementAt(int index)

removeElement

final void removeElement(QueryTreeNode qt)

remove

final java.lang.Object remove(int index)

indexOf

final int indexOf(QueryTreeNode qt)

setElementAt

final void setElementAt(QueryTreeNode qt,
                        int index)

destructiveAppend

public void destructiveAppend(QueryTreeNodeVector qtnv)

nondestructiveAppend

public void nondestructiveAppend(QueryTreeNodeVector qtnv)

removeAllElements

final void removeAllElements()

insertElementAt

final void insertElementAt(QueryTreeNode qt,
                           int index)

accept

public Visitable accept(Visitor v)
                 throws StandardException
Accept a visitor, and call v.visit() on child nodes as necessary.

Specified by:
accept in interface Visitable
Overrides:
accept in class QueryTreeNode
Parameters:
v - the visitor
Throws:
StandardException - on error

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.