Examples of TableDescriptor


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

     * staleness (or to create).
     *
     * @param fromTable the table
     */
    private void collectTablePrivsAndStats(FromBaseTable fromTable) {
        TableDescriptor td = fromTable.getTableDescriptor();
        if (fromTable.isPrivilegeCollectionRequired()) {
            // We ask for MIN_SELECT_PRIV requirement of the first column in
            // the table. The first column is just a place holder. What we
            // really do at execution time when we see we are looking for
            // MIN_SELECT_PRIV privilege is as follows:
            //
            // 1) We will look for SELECT privilege at table level.
            // 2) If not found, we will look for SELECT privilege on
            //    ANY column, not necessarily the first column. But since
            //    the constructor for column privilege requires us to pass
            //    a column descriptor, we just choose the first column for
            //    MIN_SELECT_PRIV requirement.
            getCompilerContext().addRequiredColumnPriv(
                    td.getColumnDescriptor(1));
        }
        // Save a list of base tables to check the index statistics for at a
        // later time. We want to compute statistics for base user tables only,
        // not for instance system tables or VTIs (see TableDescriptor for a
        // list of all available "table types").
        if (checkIndexStats &&
                td.getTableType() == TableDescriptor.BASE_TABLE_TYPE) {
            if (statsToUpdate == null) {
                statsToUpdate = new ArrayList();
            }
            statsToUpdate.add(td);
        }
View Full Code Here

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

   */
  private void bindUpdateColumns(FromTable targetTable)
          throws StandardException
  {
    int size = updatableColumns.size();
    TableDescriptor tableDescriptor;
    String columnName;
    ResultColumnList rcls = resultSet.getResultColumns();

    for (int index = 0; index < size; index++)
    {
        columnName = (String) updatableColumns.get(index);
        tableDescriptor = targetTable.getTableDescriptor();
        if ( tableDescriptor.getColumnDescriptor(columnName) == null)
        {
          throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND, columnName);
        }

        ResultColumn rc;
View Full Code Here

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

        }
        // Remove table descriptors whose statistics are considered up-to-date.
        // Iterate backwards to remove elements, chances are high the stats are
        // mostly up-to-date (minor performance optimization to avoid copy).
        for (int i=statsToUpdate.size() -1; i >= 0; i--) {
            TableDescriptor td = (TableDescriptor)statsToUpdate.get(i);
            if (td.getAndClearIndexStatsIsUpToDate()) {
                statsToUpdate.remove(i);
            }
        }
        if (statsToUpdate.isEmpty()) {
            return EMPTY_TD_LIST;
View Full Code Here

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

        fkNames = new String[size];
        conglomNumbers = new long[size];
        isSelfReferencingFK = new boolean[size];
        raRules = new int[size];
        ForeignKeyConstraintDescriptor fkcd = null;
        TableDescriptor fktd;
        ColumnDescriptorList coldl;
        int[] refColumns;
        ColumnDescriptor cold;
        int[] colArray = remapReferencedColumns(cd, rowMap);
        for (int inner = 0; inner < size; inner++)
        {
          fkcd = (ForeignKeyConstraintDescriptor) fkcdl.elementAt(inner);
          fkSetupArrays(dd, fkcd,
                inner, uuids, conglomNumbers, fkNames,
                isSelfReferencingFK, raRules);
          if((raRules[inner] == StatementType.RA_CASCADE) ||
             (raRules[inner] ==StatementType.RA_SETNULL))
          {
            //find  the referencing  table Name
            fktd = fkcd.getTableDescriptor();
            refTableNames.add(fktd.getSchemaName() + "." + fktd.getName());
            refActions.add(new Integer(raRules[inner]));
            //find the referencing column name required for update null.
            refColumns = fkcd.getReferencedColumns();
            coldl = fktd.getColumnDescriptorList();
            ColumnDescriptorList releventColDes = new ColumnDescriptorList();
            for(int i = 0 ; i < refColumns.length; i++)
            {
              cold =(ColumnDescriptor)coldl.elementAt(refColumns[i]-1);
              releventColDes.add(cold);
            }
            refColDescriptors.add(releventColDes);
            refIndexConglomNum.add(new Long(conglomNumbers[inner]));
            fkColMap.add(colArray);
          }
        }
      }
      else
      {
        continue;
      }

      TableDescriptor  pktd = refcd.getTableDescriptor();
      UUID pkuuid = refcd.getIndexId();
      ConglomerateDescriptor pkIndexConglom = pktd.getConglomerateDescriptor(pkuuid);

      TableDescriptor refTd = cd.getTableDescriptor();
      fkVector.add(new FKInfo(
                  fkNames,              // foreign key names
                  refTd.getName(),        // table being modified
                  statementType,            // INSERT|UPDATE|DELETE
                  type,                // FOREIGN_KEY|REFERENCED_KEY
                  pkuuid,                // referenced backing index uuid
                  pkIndexConglom.getConglomerateNumber(), // referened backing index conglom
                  uuids,                // fk backing index uuids
View Full Code Here

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

        "Exactly one of vtiTableFuncName or tableDescriptor should " +
        "be null, but neither or both of them were null.");
    }

    TableName vtiName = (TableName)vtiTableFuncName;
    TableDescriptor td = (TableDescriptor)tableDescriptor;
    boolean isTableFunctionVTI = (vtiTableFuncName != null);
    if (isTableFunctionVTI)
    {
      // We have to create a generic TableDescriptor to
      // pass to the data dictionary.
      td = new TableDescriptor(getDataDictionary(),
          vtiName.getTableName(),
          getSchemaDescriptor(vtiName.getSchemaName()),
          TableDescriptor.VTI_TYPE,
          TableDescriptor.DEFAULT_LOCK_GRANULARITY);
    }

    /* Use the table descriptor to figure out what the corresponding
     * VTI class name is; we let the data dictionary do the mapping
     * for us.
     */
    this.javaClassName = getDataDictionary().getVTIClass(
      td, isTableFunctionVTI);

    this.isBuiltinVTI =
        ( getDataDictionary().getBuiltinVTIClass( td, isTableFunctionVTI) != null);

    /* If javaClassName is still null at this point then we
     * could not find the target class for the received table
     * (or table function) name.  So throw the appropriate
     * error.
     */
    if (this.javaClassName == null)
    {
      if (!isTableFunctionVTI)
      {
        /* Create a TableName object from the table descriptor
         * that we received.  This gives us the name to use
         * in the error message.
         */
        vtiName = makeTableName(td.getSchemaName(),
          td.getDescriptorName());
      }

      throw StandardException.newException(
        isTableFunctionVTI
          ? SQLState.LANG_NO_SUCH_METHOD_ALIAS
View Full Code Here

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

   */
  protected final TableDescriptor getTableDescriptor(String tableName,
          SchemaDescriptor schema)
            throws StandardException
  {
    TableDescriptor retval;

    //Following if means we are dealing with SESSION schema.
    if (isSessionSchema(schema))
    {
      //First we need to look in the list of temporary tables to see if this table is a temporary table.
      retval = getLanguageConnectionContext().getTableDescriptorForDeclaredGlobalTempTable(tableName);
      if (retval != null)
        return retval; //this is a temporary table
    }

    //Following if means we are dealing with SESSION schema and we are dealing with in-memory schema (ie there is no physical SESSION schema)
    //If following if is true, it means SESSION.table is not a declared table & it can't be physical SESSION.table
    //because there is no physical SESSION schema
    if (schema.getUUID() == null)
      return null;

    //it is not a temporary table, so go through the data dictionary to find the physical persistent table
    TableDescriptor td = getDataDictionary().getTableDescriptor(tableName, schema,
                this.getLanguageConnectionContext().getTransactionCompile());
    if (td == null || td.isSynonymDescriptor())
      return null;

    return td;
  }
View Full Code Here

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

  public ResultSetNode bindNonVTITables(DataDictionary dataDictionary,
               FromList fromListParam)
          throws StandardException
  {
    TableDescriptor tableDescriptor = bindTableDescriptor();

    if (tableDescriptor.getTableType() == TableDescriptor.VTI_TYPE) {
      ResultSetNode vtiNode = getNodeFactory().mapTableAsVTI(
          tableDescriptor,
          getCorrelationName(),
          resultColumns,
          getProperties(),
          getContextManager());
      return vtiNode.bindNonVTITables(dataDictionary, fromListParam);
   
   
    ResultColumnList  derivedRCL = resultColumns;
 
    // make sure there's a restriction list
    restrictionList = (PredicateList) getNodeFactory().getNode(
                      C_NodeTypes.PREDICATE_LIST,
                      getContextManager());
    baseTableRestrictionList = (PredicateList) getNodeFactory().getNode(
                      C_NodeTypes.PREDICATE_LIST,
                      getContextManager());


    CompilerContext compilerContext = getCompilerContext();

    /* Generate the ResultColumnList */
    resultColumns = genResultColList();
    templateColumns = resultColumns;

    /* Resolve the view, if this is a view */
    if (tableDescriptor.getTableType() == TableDescriptor.VIEW_TYPE)
    {
      FromSubquery                fsq;
      ResultSetNode        rsn;
      ViewDescriptor        vd;
      CreateViewNode        cvn;
      SchemaDescriptor      compSchema;

      /* Get the associated ViewDescriptor so that we can get
       * the view definition text.
       */
      vd = dataDictionary.getViewDescriptor(tableDescriptor);

      /*
      ** Set the default compilation schema to be whatever
      ** this schema this view was originally compiled against.
      ** That way we pick up the same tables no matter what
      ** schema we are running against.
      */
      compSchema = dataDictionary.getSchemaDescriptor(vd.getCompSchemaId(), null);

      compilerContext.pushCompilationSchema(compSchema);
 
      try
      {
   
        /* This represents a view - query is dependent on the ViewDescriptor */
        compilerContext.createDependency(vd);
 
        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(vd != null,
            "vd not expected to be null for " + tableName);
        }

        cvn = (CreateViewNode)
                  parseStatement(vd.getViewText(), false);

        rsn = cvn.getParsedQueryExpression();

        /* If the view contains a '*' then we mark the views derived column list
         * so that the view will still work, and return the expected results,
         * if any of the tables referenced in the view have columns added to
         * them via ALTER TABLE.  The expected results means that the view
         * will always return the same # of columns.
         */
        if (rsn.getResultColumns().containsAllResultColumn())
        {
          resultColumns.setCountMismatchAllowed(true);
        }
        //Views execute with definer's privileges and if any one of
        //those privileges' are revoked from the definer, the view gets
        //dropped. So, a view can exist in Derby only if it's owner has
        //all the privileges needed to create one. In order to do a
        //select from a view, a user only needs select privilege on the
        //view and doesn't need any privilege for objects accessed by
        //the view. Hence, when collecting privilege requirement for a
        //sql accessing a view, we only need to look for select privilege
        //on the actual view and that is what the following code is
        //checking.
        for (int i = 0; i < resultColumns.size(); i++) {
          ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
          if (rc.isPrivilegeCollectionRequired())
            compilerContext.addRequiredColumnPriv( rc.getTableColumnDescriptor());
        }

        fsq = (FromSubquery) getNodeFactory().getNode(
          C_NodeTypes.FROM_SUBQUERY,
          rsn,
                    cvn.getOrderByList(),
                    cvn.getOffset(),
                    cvn.getFetchFirst(),
          (correlationName != null) ?
                        correlationName : getOrigTableName().getTableName(),
          resultColumns,
          tableProperties,
          getContextManager());
        // Transfer the nesting level to the new FromSubquery
        fsq.setLevel(level);
        //We are getting ready to bind the query underneath the view. Since
        //that query is going to run with definer's privileges, we do not
        //need to collect any privilege requirement for that query.
        //Following call is marking the query to run with definer
        //privileges. This marking will make sure that we do not collect
        //any privilege requirement for it.
        fsq.disablePrivilegeCollection();
        fsq.setOrigTableName(this.getOrigTableName());

        // since we reset the compilation schema when we return, we
        // need to save it for use when we bind expressions:
        fsq.setOrigCompilationSchema(compSchema);
        ResultSetNode fsqBound =
          fsq.bindNonVTITables(dataDictionary, fromListParam);

        /* Do error checking on derived column list and update "exposed"
         * column names if valid.
         */
        if (derivedRCL != null) {
          fsqBound.getResultColumns().propagateDCLInfo(
            derivedRCL,
            origTableName.getFullTableName());
        }

        return fsqBound;
      }
      finally
      {
        compilerContext.popCompilationSchema();
      }
    }
    else
    {
      /* This represents a table - query is dependent on the TableDescriptor */
      compilerContext.createDependency(tableDescriptor);

      /* Get the base conglomerate descriptor */
      baseConglomerateDescriptor =
        tableDescriptor.getConglomerateDescriptor(
          tableDescriptor.getHeapConglomerateId()
          );

      /* Build the 0-based array of base column names. */
      columnNames = resultColumns.getColumnNames();

View Full Code Here

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

        // the transaction until loop below finds one it needs to
        // process.
       
        for (int i=0; i<allDeclaredGlobalTempTables.size(); i++)
        {
            TableDescriptor td =
                ((TempTableInfo) (allDeclaredGlobalTempTables.
                                      get(i))).getTableDescriptor();
            if (td.isOnCommitDeleteRows() == false)
            {
                // do nothing for temp table with ON COMMIT PRESERVE ROWS
                continue;
            }
            else if (checkIfAnyActivationHasHoldCursor(td.getName()) ==
                        false)
            {
                // temp tables with ON COMMIT DELETE ROWS and
                // no open held cursors
                getDataDictionary().getDependencyManager().invalidateFor(
View Full Code Here

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

        // network server, consistently remove temp tables at XA commit
        // transaction boundary.
        for (int i=0; i < allDeclaredGlobalTempTables.size(); i++)
        {
            // remove all temp tables from this context.
            TableDescriptor td =
                ((TempTableInfo)
                 (allDeclaredGlobalTempTables.get(i))).getTableDescriptor();

            //remove the conglomerate created for this temp table
            tc.dropConglomerate(td.getHeapConglomerateId());

            //remove it from the list of temp tables
            allDeclaredGlobalTempTables.remove(i);
        }
View Full Code Here

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

            try
            {
                TempTableInfo tempTableInfo =
                    (TempTableInfo)allDeclaredGlobalTempTables.get(i);

                TableDescriptor td = tempTableInfo.getTableDescriptor();

                // the following 2 lines of code has been copied from
                // DropTableConstantAction. If there are any changes made there
                // in future, we should check if they need to be made here too.
                dm.invalidateFor(td, DependencyManager.DROP_TABLE, this);
                tran.dropConglomerate(td.getHeapConglomerateId());

            }
            catch (StandardException e)
            {
                if (topLevelStandardException == null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.