Examples of CompilerContext


Examples of org.apache.derby.iapi.sql.compile.CompilerContext

   * @exception StandardException    Thrown on error
   */

  public QueryTreeNode bind() throws StandardException
  {
    CompilerContext      cc = getCompilerContext();

    td = getTableDescriptor();

    conglomerateNumber = td.getHeapConglomerateId();

    /* Get the base conglomerate descriptor */
    ConglomerateDescriptor cd = td.getConglomerateDescriptor(conglomerateNumber);

    /* Statement is dependent on the TableDescriptor and ConglomerateDescriptor */
    cc.createDependency(td);
    cc.createDependency(cd);

    return this;
  }
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

    @exception StandardException current mode does not support statement
  */
        private void checkInternalFeature(String feature) throws StandardException
        {
                CompilerContext cc = getCompilerContext();
                if ((cc.getReliability() & CompilerContext.INTERNAL_SQL_ILLEGAL) != 0)
                        throw StandardException.newException(SQLState.LANG_SYNTAX_ERROR, feature);
        }
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

   @exception  StandardException
   */
         private void setUpAndLinkParameters()
                        throws StandardException
         {
                CompilerContext cc = getCompilerContext();
                cc.setParameterList(parameterList);
                /* Link the untyped parameters to the array of parameter descriptors */

                DataTypeDescriptor[] descriptors = cc.getParameterTypes();

                ParameterNode                           newNode;
                ParameterNode                           oldNode;
                int                                                     paramCount;

View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

   *
   * @exception StandardException    Thrown on error
   */
  public QueryTreeNode bind() throws StandardException
  {
    CompilerContext      cc = getCompilerContext();
    DataDictionary      dd = getDataDictionary();
    SchemaDescriptor    sd;

    sd = getSchemaDescriptor();

    if (sd.getUUID() != null)
      cd = dd.getConglomerateDescriptor(getRelativeName(), sd, false);

    if (cd == null)
    {
      throw StandardException.newException(SQLState.LANG_INDEX_NOT_FOUND, getFullName());
    }

    /* Get the table descriptor */
    td = getTableDescriptor(cd.getTableID());

    /* Drop index is not allowed on an index backing a constraint -
     * user must drop the constraint, which will drop the index.
     * Drop constraint drops the constraint before the index,
     * so it's okay to drop a backing index if we can't find its
     * ConstraintDescriptor.
     */
    if (cd.isConstraint())
    {
      ConstraintDescriptor conDesc;
      String constraintName;

      conDesc = dd.getConstraintDescriptor(td, cd.getUUID());
      if (conDesc != null)
      {
        constraintName = conDesc.getConstraintName();
        throw StandardException.newException(SQLState.LANG_CANT_DROP_BACKING_INDEX,
                    getFullName(), constraintName);
      }
    }

    /* Statement is dependent on the TableDescriptor and ConglomerateDescriptor */
    cc.createDependency(td);
    cc.createDependency(cd);

    return this;
  }
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

   *
   * @exception StandardException    Thrown on error
   */
  public QueryTreeNode bind() throws StandardException
  {
    CompilerContext        cc = getCompilerContext();
    DataDictionary        dataDictionary = getDataDictionary();
    ResultColumnList      qeRCL;
    String            duplicateColName;

    // bind the query expression
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

    indexConglomerateNumbers = indexLister.getDistinctIndexConglomerateNumbers();
    indexNames = indexLister.getDistinctIndexNames();

    /* Add dependencies on all indexes in the list */
    ConglomerateDescriptor[]  cds = td.getConglomerateDescriptors();
    CompilerContext cc = getCompilerContext();

     for (int index = 0; index < cds.length; index++)
    {
      cc.createDependency(cds[index]);
    }
  }
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();

   
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

   * @exception StandardException    Thrown on error
   */

  public void bindStatement() throws StandardException
  {
    CompilerContext      cc = getCompilerContext();

    td = getTableDescriptor();

    conglomerateNumber = td.getHeapConglomerateId();

    /* Get the base conglomerate descriptor */
    ConglomerateDescriptor cd = td.getConglomerateDescriptor(conglomerateNumber);

    /* Statement is dependent on the TableDescriptor and ConglomerateDescriptor */
    cc.createDependency(td);
    cc.createDependency(cd);
  }
 
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

    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)
    {
      FromTable          fsq;
      ResultSetNode        rsn;
      ViewDescriptor        vd;
      CreateViewNode        cvn;
      SchemaDescriptor      compSchema;
      SchemaDescriptor      prevCompSchema;

      /* 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);

      prevCompSchema = compilerContext.setCompilationSchema(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 = (FromTable) getNodeFactory().getNode(
          C_NodeTypes.FROM_SUBQUERY,
          rsn,
          (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());
        return fsq.bindNonVTITables(dataDictionary, fromListParam);
      }
      finally
      {
        compilerContext.setCompilationSchema(prevCompSchema);
      }
    }
    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();

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

      /* Assign the tableNumber */
      if (tableNumber == -1// allow re-bind, in which case use old number
        tableNumber = compilerContext.getNextTableNumber();
    }

    return this;
  }
View Full Code Here

Examples of org.apache.derby.iapi.sql.compile.CompilerContext

    ** replaced ourselves.
    */
    if (generatedRef == null)
    {
      String          generatedColName;
      CompilerContext     cc = getCompilerContext();
      generatedColName ="SQLCol" + cc.getNextColumnNumber();
      generatedRC = (ResultColumn) getNodeFactory().getNode(
                      C_NodeTypes.RESULT_COLUMN,
                      generatedColName,
                      this,
                      getContextManager());
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.