Package org.apache.derby.iapi.sql.dictionary

Examples of org.apache.derby.iapi.sql.dictionary.ColumnDescriptor


    SystemColumn[]    columnList = crf.buildColumnList();
    UUID        heapUUID = crf.getCanonicalHeapUUID();
    String        heapName = crf.getCanonicalHeapName();
    TableDescriptor    td;
    UUID        toid;
    ColumnDescriptor  cd;
    int          columnCount;
    SystemColumn    column;

    // add table to the data dictionary
View Full Code Here


            int columnPosition,
                            TableDescriptor  td )
            throws StandardException
  {
    //RESOLVEAUTOINCREMENT
    return new ColumnDescriptor
      (column.getName(), columnPosition, column.getType(), null, null, td,
       (UUID) null, // No defaults yet for system columns
       0, 0
       );
  }
View Full Code Here

            newResultColumn.setExpressionToNullNode();
        }
        else
        {
            // column position is 1-based, index is 0-based.
            ColumnDescriptor colDesc = targetTD.getColumnDescriptor(columnNumber);
            DataTypeDescriptor colType = colDesc.getType();

            // Check for defaults
            DefaultInfoImpl defaultInfo = (DefaultInfoImpl) colDesc.getDefaultInfo();
     
      //Column has constant default value ,
      //if it have defaultInfo and not be autoincrement.
            if (defaultInfo != null && ! colDesc.isAutoincrement())
            {
                //RESOLVEPARAMETER - skip the tree if we have the value
                /*
                  if (defaultInfo.getDefaultValue() != null)
                  {
                  }
                  else
                */
                {
                    if ( colDesc.hasGenerationClause() )
                    {
                        // later on we will revisit the generated columns and bind
                        // their generation clauses
                        newResultColumn = createGeneratedColumn( targetTD, colDesc );
                    }
                    else
                    {
                        // Generate the tree for the default
                        String defaultText = defaultInfo.getDefaultText();
                        ValueNode defaultTree = parseDefault(defaultText);
                        defaultTree = defaultTree.bindExpression
                            (getFromList(), (SubqueryList) null, (Vector) null);
                        newResultColumn = (ResultColumn) getNodeFactory().getNode
                            ( C_NodeTypes.RESULT_COLUMN, defaultTree.getTypeServices(), defaultTree, getContextManager());
                    }

                    DefaultDescriptor defaultDescriptor = colDesc.getDefaultDescriptor(dataDictionary);
                    if (SanityManager.DEBUG)
                    {
                        SanityManager.ASSERT(defaultDescriptor != null,
                                             "defaultDescriptor expected to be non-null");
                    }
                    getCompilerContext().createDependency(defaultDescriptor);
                }
            }
            else if (colDesc.isAutoincrement())
            {
                newResultColumn =
                  (ResultColumn)getNodeFactory().getNode(
                      C_NodeTypes.RESULT_COLUMN,
                      colDesc, null,
View Full Code Here

   * @exception  StandardException, thrown on error.
   */
    private void modifyColumnDefault(int ix)
      throws StandardException            
  {
    ColumnDescriptor columnDescriptor =
      td.getColumnDescriptor(columnInfo[ix].name);
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    int columnPosition = columnDescriptor.getPosition();

    // Clean up after the old default, if non-null
    if (columnDescriptor.hasNonNullDefault())
    {
      // Invalidate off of the old default
      DefaultDescriptor defaultDescriptor = new DefaultDescriptor(dd, columnInfo[ix].oldDefaultUUID,
                     td.getUUID(), columnPosition);

   
      dm.invalidateFor(defaultDescriptor, DependencyManager.MODIFY_COLUMN_DEFAULT, lcc);
   
      // Drop any dependencies
      dm.clearDependencies(lcc, defaultDescriptor);
    }

    UUID defaultUUID = columnInfo[ix].newDefaultUUID;

    /* Generate a UUID for the default, if one exists
     * and there is no default id yet.
     */
    if (columnInfo[ix].defaultInfo != null &&
      defaultUUID == null)
    { 
      defaultUUID = dd.getUUIDFactory().createUUID();
    }

    /* Get a ColumnDescriptor reflecting the new default */
    columnDescriptor = new ColumnDescriptor(
                           columnInfo[ix].name,
                           columnPosition,
                           columnInfo[ix].dataType,
                           columnInfo[ix].defaultValue,
                           columnInfo[ix].defaultInfo,
View Full Code Here

     * be used in validateConstraint to check whether any of the
     * data is null
     */
    for (int colCtr = 0; colCtr < columnNames.length; colCtr++)
    {
      ColumnDescriptor cd = td.getColumnDescriptor(columnNames[colCtr]);

      if (cd == null)
      {
        throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE,
                            columnNames[colCtr],
                            td.getName());
      }

      if (cd.getType().isNullable())
      {
        if (numRows > 0)
        {
          // already found a nullable column so add "AND"
          if (foundNullable)
View Full Code Here

  {
        int                                 generatedColumnCount = affectedGeneratedColumns.size();
       
        for ( int gcIdx = 0; gcIdx < generatedColumnCount; gcIdx++ )
        {
            ColumnDescriptor    gc = affectedGeneratedColumns.elementAt( gcIdx );
            String[]                       mentionedColumnNames = gc.getDefaultInfo().getReferencedColumnNames();
            int[]                       mentionedColumns = baseTable.getColumnIDs( mentionedColumnNames );
            int                         mentionedColumnCount = mentionedColumns.length;

            for ( int mcIdx = 0; mcIdx < mentionedColumnCount; mcIdx++ )
            {
View Full Code Here

            updatedColumns.add( name );
    }

        for ( int gcIdx = 0; gcIdx < generatedColumnCount; gcIdx++ )
        {
            ColumnDescriptor    gc = generatedColumns.elementAt( gcIdx );
            DefaultInfo             defaultInfo = gc.getDefaultInfo();
            String[]                       mentionedColumnNames = defaultInfo.getReferencedColumnNames();
            int                         mentionedColumnCount = mentionedColumnNames.length;

            // handle the case of setting a generated column to the DEFAULT
            // literal
            if ( updatedColumns.contains( gc.getColumnName() ) ) { affectedGeneratedColumns.add( tableID, gc ); }

            // figure out if this generated column is affected by the
            // update
            for ( int mcIdx = 0; mcIdx < mentionedColumnCount; mcIdx++ )
            {
                String                      mentionedColumnName = mentionedColumnNames[ mcIdx ];

                if ( updatedColumns.contains( mentionedColumnName ) )
                {
                    // Yes, we are updating one of the columns mentioned in
                    // this generation clause.
                    affectedGeneratedColumns.add( tableID, gc );
                   
                    // If the generated column isn't in the update list yet,
                    // add it.
                    if ( !updatedColumns.contains( gc.getColumnName() ) )
                    {
                        addedGeneratedColumns.add( tableID, gc );
                       
                        // we will fill in the real value later on in parseAndBindGenerationClauses();
                        ValueNode       dummy = (ValueNode) getNodeFactory().getNode
                            ( C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE, getContextManager());
                       ResultColumn    newResultColumn = (ResultColumn) getNodeFactory().getNode
                            ( C_NodeTypes.RESULT_COLUMN, gc.getType(), dummy, getContextManager());
                        newResultColumn.setColumnDescriptor( baseTable, gc );
                        newResultColumn.setName( gc.getColumnName() );

                        updateColumnList.addResultColumn( newResultColumn );
                    }
                   
                    break;
View Full Code Here

      throws StandardException
  {
    ResultColumnList       rcList = null;
    ResultColumn         resultColumn;
    ValueNode           valueNode;
    ColumnDescriptor       colDesc = null;
    TableName           exposedName;

    /* Cache exposed name for this table.
     * The exposed name becomes the qualifier for each column
     * in the expanded list.
     */
    exposedName = getExposedTableName();

    /* Add all of the columns in the table */
    rcList = (ResultColumnList) getNodeFactory().getNode(
                    C_NodeTypes.RESULT_COLUMN_LIST,
                    getContextManager());
    ColumnDescriptorList cdl = tableDescriptor.getColumnDescriptorList();
    int           cdlSize = cdl.size();

    for (int index = 0; index < cdlSize; index++)
    {
      /* Build a ResultColumn/BaseColumnNode pair for the column */
      colDesc = (ColumnDescriptor) cdl.elementAt(index);
      //A ColumnDescriptor instantiated through SYSCOLUMNSRowFactory only has
      //the uuid set on it and no table descriptor set on it. Since we know here
      //that this columnDescriptor is tied to tableDescriptor, set it so using
      //setTableDescriptor method. ColumnDescriptor's table descriptor is used
      //to get ResultSetMetaData.getTableName & ResultSetMetaData.getSchemaName
      colDesc.setTableDescriptor(tableDescriptor);

      valueNode = (ValueNode) getNodeFactory().getNode(
                      C_NodeTypes.BASE_COLUMN_NODE,
                      colDesc.getColumnName(),
                        exposedName,
                      colDesc.getType(),
                      getContextManager());
      resultColumn = (ResultColumn) getNodeFactory().getNode(
                      C_NodeTypes.RESULT_COLUMN,
                      colDesc,
                      valueNode,
View Full Code Here

      throws StandardException
  {
    ResultColumnList       rcList = null;
    ResultColumn         resultColumn;
    ValueNode           valueNode;
    ColumnDescriptor       cd = null;
    TableName           exposedName;

    /* Cache exposed name for this table.
     * The exposed name becomes the qualifier for each column
     * in the expanded list.
     */
    exposedName = getExposedTableName();

    /* Add all of the columns in the table */
    ResultColumnList newRcl = (ResultColumnList) getNodeFactory().getNode(
                        C_NodeTypes.RESULT_COLUMN_LIST,
                        getContextManager());
    ColumnDescriptorList cdl = tableDescriptor.getColumnDescriptorList();
    int           cdlSize = cdl.size();

    for (int index = 0; index < cdlSize; index++)
    {
      /* Build a ResultColumn/BaseColumnNode pair for the column */
      cd = (ColumnDescriptor) cdl.elementAt(index);
      int position = cd.getPosition();

      if (!colsWeWant.get(position))
      {
        continue;
      }

      if ((resultColumn = inputRcl.getResultColumn(position)) == null)
      { 
        valueNode = (ValueNode) getNodeFactory().getNode(
                        C_NodeTypes.COLUMN_REFERENCE,
                        cd.getColumnName(),
                        exposedName,
                        getContextManager());
        resultColumn = (ResultColumn) getNodeFactory().
                        getNode(
                          C_NodeTypes.RESULT_COLUMN,
View Full Code Here

                      UUID           uuid,
                      ColumnDescriptorList   cdl,
                      TupleDescriptor     td)
      throws StandardException
  {
    ColumnDescriptor    cd;
    ColumnDescriptorList    cdlCopy         = new ColumnDescriptorList();
    DataValueDescriptor    refIDOrderable  = null;
    TabInfoImpl                 ti              = coreInfo[SYSCOLUMNS_CORE_NUM];

    /* Use refIDOrderable in both start and stop position for scan. */
    refIDOrderable = getIDValueAsCHAR(uuid);

    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, refIDOrderable);

    getDescriptorViaIndex(
            SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            td,
            (ColumnDescriptorList) cdl,
            false);

    /* The TableDescriptor's column descriptor list must be ordered by
     * columnNumber.  (It is probably not ordered correctly at this point due
     * to the index on syscolumns being on (tableId, columnName).)  The
     * cheapest way to reorder the list appears to be to copy it (above), and then
     * walk the copy and put the elements back into the original in the
     * expected locations.
     */
    int cdlSize = cdl.size();
    for (int index = 0; index < cdlSize; index++)
    {
      cdlCopy.add( cdl.get(index));
    }
    for (int index = 0; index < cdlSize; index++)
    {
      cd = (ColumnDescriptor) cdlCopy.elementAt(index);
      cdl.set(cd.getPosition() - 1, cd);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.dictionary.ColumnDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.