Package org.apache.derby.iapi.sql.depend

Examples of org.apache.derby.iapi.sql.depend.DependencyManager


    TransactionController       tc
  )
    throws StandardException
  {
    ContextManager cm = lcc.getContextManager();
    DependencyManager dm;
    ProviderInfo[] providerInfo;

    LanguageConnectionFactory  lcf = lcc.getLanguageConnectionFactory();

    DataDictionary dd = getDataDictionary();


    /*
    ** If we are a trigger, then we have to go ahead
    ** and locate the trigger's table descriptor and
    ** push it on the lcc.  This is expensive, but
    ** pretty atypical since trigger actions aren't
    ** likely to be invalidated too often.  Also, when
    ** possible, we already have the triggerTable.
    */
    if (type == SPS_TYPE_TRIGGER && triggerTable == null)
    {
      String uuidStr = name.substring(49);
      triggerTable = dd.getTableDescriptor(recreateUUID(uuidStr));
      if (SanityManager.DEBUG)
      {
        if (triggerTable == null)
        {
          SanityManager.THROWASSERT("couldn't find trigger table for trigger sps "+name);
        }
      }
    }

    if (triggerTable != null)
    {
      lcc.pushTriggerTable(triggerTable);
    }

    // stored statements always stored as unicode.
    Statement       stmt = lcf.getStatement(dd.getSchemaDescriptor(compSchemaId, null), text, true);

    try
    {
      preparedStatement = (ExecPreparedStatement) stmt.prepareStorable(
                lcc,
                preparedStatement,
                getParameterDefaults(),
                getSchemaDescriptor(),
                type == SPS_TYPE_TRIGGER);
    }
    finally
    {
      if (triggerTable != null)
      {
        lcc.popTriggerTable(triggerTable);
      }
    }

    //If this references a SESSION schema table (temporary or permanent), then throw an exception
    //This is if EXECUTE STATEMENT executing a statement that was created with NOCOMPILE. Because
    //of NOCOMPILE, we could not catch SESSION schema table reference by the statement at
    //CREATE STATEMENT time. And hence need to catch such statements at EXECUTE STATEMENT time
    //when the query is getting compiled.
    if (preparedStatement.referencesSessionSchema())
      throw StandardException.newException(SQLState.LANG_OPERATION_NOT_ALLOWED_ON_SESSION_SCHEMA_TABLES);
     
    setCompileTime();
    setParams(preparedStatement.getParameterTypes());

    if (!((org.apache.derby.impl.sql.catalog.DataDictionaryImpl) dd).readOnlyUpgrade) {

      /*
      ** Indicate that we are going to write the data
      ** dictionary.  We have probably already done this
      ** but it is ok to call startWriting more than once.
      */
      dd.startWriting(lcc);

      dm = dd.getDependencyManager();
      /*
      ** Clear out all the dependencies that exist
      ** before we recreate them so we don't grow
      ** SYS.SYSDEPENDS forever.
      */
      dm.clearDependencies(lcc, this, tc);

      /*
      ** Copy over all the dependencies to me
      */
      dm.copyDependencies(preparedStatement,   // from
                      this,   // to
                      false,  // persistent only
                      cm,
                      tc);
    }
View Full Code Here


      /*
      ** The rest are errors
      */
        default:

        DependencyManager dm;

        dm = getDataDictionary().getDependencyManager();
        throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_S_P_S,
          dm.getActionString(action),
          p.getObjectName(), name);

    }
  }
View Full Code Here

   */
  public final synchronized void makeInvalid(int action,
                         LanguageConnectionContext lcc)
    throws StandardException
  {
    DependencyManager dm;

    dm = getDataDictionary().getDependencyManager();

    switch (action)
    {
      /*
      ** Some things that don't affect stored prepared
       ** statements.
      */
      case DependencyManager.PREPARED_STATEMENT_RELEASE:
        case DependencyManager.CREATE_VIEW:
        break;

      /*
       ** Things that can invalidate a stored
      ** prepared statement.
      */
      case DependencyManager.CREATE_INDEX:
      case DependencyManager.CREATE_CONSTRAINT:
      case DependencyManager.DROP_CONSTRAINT:
      case DependencyManager.DROP_TABLE:
      case DependencyManager.DROP_INDEX:
      case DependencyManager.DROP_VIEW:
      case DependencyManager.DROP_METHOD_ALIAS:
      case DependencyManager.DROP_SYNONYM:
      case DependencyManager.ALTER_TABLE:
      case DependencyManager.RENAME:
      case DependencyManager.RENAME_INDEX:
      case DependencyManager.USER_RECOMPILE_REQUEST:
      case DependencyManager.CHANGED_CURSOR:
      case DependencyManager.BULK_INSERT:
      case DependencyManager.COMPRESS_TABLE:
      case DependencyManager.SET_CONSTRAINTS_ENABLE:
      case DependencyManager.SET_CONSTRAINTS_DISABLE:
      case DependencyManager.SET_TRIGGERS_ENABLE:
      case DependencyManager.SET_TRIGGERS_DISABLE:
      case DependencyManager.ROLLBACK:
      case DependencyManager.INTERNAL_RECOMPILE_REQUEST:
      case DependencyManager.CREATE_TRIGGER:
      case DependencyManager.DROP_TRIGGER:
      case DependencyManager.DROP_COLUMN:
      case DependencyManager.DROP_COLUMN_RESTRICT:
        case DependencyManager.UPDATE_STATISTICS:
        case DependencyManager.DROP_STATISTICS:
      case DependencyManager.TRUNCATE_TABLE:
        /*
        ** If we are already invalid, don't write ourselves
        ** out.  Just to be safe, we'll send out an invalidate
        ** to our dependents either way.
        */
        if (valid == true)
        {
          valid = false;
          updateSYSSTATEMENTS(lcc, INVALIDATE, null);
        }
        dm.invalidateFor(this, dm.USER_RECOMPILE_REQUEST, lcc);
        break;
      case DependencyManager.DROP_SPS:
        //System.out.println("SPSD " + preparedStatement);
        dm.clearDependencies(lcc, this);
        break;
 
        default:

        /*
        ** We should never get here, since we can't have dangling references
        */
        if (SanityManager.DEBUG)
        {
          SanityManager.THROWASSERT("makeInvalid("+
            dm.getActionString(action)+
            ") not expected to get called; should have failed in "+
            "prepareToInvalidate()");
        }
        break;

View Full Code Here

        case DependencyManager.DROP_TABLE:
        case DependencyManager.DROP_SYNONYM:
        case DependencyManager.DROP_SPS:
        case DependencyManager.RENAME:
        case DependencyManager.REVOKE_PRIVILEGE_RESTRICT:
        DependencyManager dm = getDataDictionary().getDependencyManager();
        throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
                  dm.getActionString(action),
                  p.getObjectName(), "TRIGGER", name);

        /*
      ** The trigger descriptor depends on the trigger table.
      ** This means that we get called whenever anything happens
View Full Code Here

    switch (action)
    {
      // invalidate this trigger descriptor
      case DependencyManager.USER_RECOMPILE_REQUEST:
        DependencyManager dm = getDataDictionary().getDependencyManager();
        dm.invalidateFor(this, DependencyManager.PREPARED_STATEMENT_RELEASE, lcc);
        break;

      // When REVOKE_PRIVILEGE gets sent (this happens for privilege
      // types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we 
      // make the TriggerDescriptor drop itself.
View Full Code Here

  }
   
    public void drop(LanguageConnectionContext   lcc) throws StandardException
    {
        DataDictionary dd = getDataDictionary();
        DependencyManager dm = getDataDictionary().getDependencyManager();
        TransactionController tc = lcc.getTransactionExecute();

        dm.invalidateFor(this, DependencyManager.DROP_TRIGGER, lcc);

        // Drop the trigger
        dd.dropTriggerDescriptor(this, tc);

        // Clear the dependencies for the trigger
        dm.clearDependencies(lcc, this);

        // Drop the spses
        SPSDescriptor spsd = dd.getSPSDescriptor(this.getActionId());

        // there shouldn't be any dependencies, but in case
        // there are, lets clear them
        dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
        dm.clearDependencies(lcc, spsd);
        dd.dropSPSDescriptor(spsd, tc);
       
        if (getWhenClauseId() != null)
        {  
            spsd = dd.getSPSDescriptor(getWhenClauseId());
            dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
            dm.clearDependencies(lcc, spsd);
            dd.dropSPSDescriptor(spsd, tc);
        }
    }
View Full Code Here

     * @throws StandardException Schema could not be dropped.
     */
  public void drop(LanguageConnectionContext lcc) throws StandardException
  {
        DataDictionary dd = getDataDictionary();
        DependencyManager dm = dd.getDependencyManager();
        TransactionController tc = lcc.getTransactionExecute();
      
      //If user is attempting to drop SESSION schema and there is no physical SESSION schema, then throw an exception
      //Need to handle it this special way is because SESSION schema is also used for temporary tables. If there is no
      //physical SESSION schema, we internally generate an in-memory SESSION schema in order to support temporary tables
      //But there is no way for the user to access that in-memory SESSION schema. Following if will be true if there is
      //no physical SESSION schema and hence getSchemaDescriptor has returned an in-memory SESSION schema
      if (getSchemaName().equals(SchemaDescriptor.STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME)
                && (getUUID() == null))
          throw StandardException.newException(SQLState.LANG_SCHEMA_DOES_NOT_EXIST, getSchemaName());
     
      /*
       ** Make sure the schema is empty.
       ** In the future we want to drop everything
       ** in the schema if it is CASCADE.
       */
      if (!dd.isSchemaEmpty(this))
      {
          throw StandardException.newException(SQLState.LANG_SCHEMA_NOT_EMPTY, getSchemaName());
      }
     
      /* Prepare all dependents to invalidate.  (This is there chance
       * to say that they can't be invalidated.  For example, an open
       * cursor referencing a table/view that the user is attempting to
       * drop.) If no one objects, then invalidate any dependent objects.
       */
      dm.invalidateFor(this, DependencyManager.DROP_SCHEMA, lcc);
     
      dd.dropSchemaDescriptor(getSchemaName(), tc);
     
      /*
       ** If we have dropped the current default schema,
View Full Code Here

   */
  public void prepareToInvalidate(Provider p, int action,
          LanguageConnectionContext lcc)
    throws StandardException
  {
    DependencyManager dm = getDataDictionary().getDependencyManager();

    switch (action)
    {
      /*
      ** A SET CONSTRAINT stmt will throw an SET_CONSTRAINTS action
      ** when enabling/disabling constraints.  We'll ignore it.
      ** Same for SET TRIGGERS
      */
        case DependencyManager.SET_CONSTRAINTS_ENABLE:
        case DependencyManager.SET_CONSTRAINTS_DISABLE:
        case DependencyManager.SET_TRIGGERS_ENABLE:
        case DependencyManager.SET_TRIGGERS_DISABLE:
      //When REVOKE_PRIVILEGE gets sent (this happens for privilege
      //types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we 
      //don't do anything here. Later in makeInvalid method, we make 
      //the ConstraintDescriptor drop itself.
        case DependencyManager.REVOKE_PRIVILEGE:
        break;

      /*
      ** Currently, the only thing we are depenedent
      ** on is another constraint or an alias..
      */
      //Notice that REVOKE_PRIVILEGE_RESTRICT is not caught earlier.
        //It gets handled in this default: action where an exception
        //will be thrown. This is because, if such an invalidation
        //action type is ever received by a dependent, the dependent
        //should throw an exception.
      //In Derby, at this point, REVOKE_PRIVILEGE_RESTRICT gets sent
        //when execute privilege on a routine is getting revoked.
        //Currently, in Derby, a constraint can't depend on a routine
        //and hence a REVOKE_PRIVILEGE_RESTRICT invalidation action
        //should never be received by a ConstraintDescriptor. But this
        //may change in future and when it does, the code to do the right
        //thing is already here.
        default:
        throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
                  dm.getActionString(action),
                  p.getObjectName(), "CONSTRAINT", constraintName);
    }
  }
View Full Code Here

      ** We should never get here, we should have barfed on
      ** prepareToInvalidate().
      */
      if (SanityManager.DEBUG)
      {
        DependencyManager dm;
   
        dm = getDataDictionary().getDependencyManager();
 
        SanityManager.THROWASSERT("makeInvalid("+
          dm.getActionString(action)+
          ") not expected to get called");
      }
    }
  }
View Full Code Here

    public void drop(LanguageConnectionContext lcc,
            boolean clearDependencies)
        throws StandardException
    {      
        DataDictionary dd = getDataDictionary();
        DependencyManager dm = dd.getDependencyManager();
        TransactionController tc = lcc.getTransactionExecute();

        if (clearDependencies)
        {
            dm.clearDependencies(lcc, this);
        }

        /* Drop the constraint.
         * NOTE: This must occur before dropping any backing index, since
         * a user is not allowed to drop a backing index without dropping
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.depend.DependencyManager

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.