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

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


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

        SPSDescriptor spsd = getDescriptorViaIndex(
            SYSSTATEMENTSRowFactory.SYSSTATEMENTS_INDEX1_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            (TupleDescriptor) null,
View Full Code Here


   * @exception StandardException    Thrown on failure
   */
  public SPSDescriptor getSPSDescriptor(String stmtName, SchemaDescriptor sd)
    throws StandardException
  {
    SPSDescriptor    sps = null;
    TableKey      stmtKey;
    UUID        schemaUUID;

    /*
    ** If we didn't get a schema descriptor, we had better
View Full Code Here

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

        SPSDescriptor spsd = getDescriptorViaIndex(
            SYSSTATEMENTSRowFactory.SYSSTATEMENTS_INDEX2_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            (TupleDescriptor) null,
            (List<TupleDescriptor>) null,
                        SPSDescriptor.class,
            false);
 
    /*
    ** Set up the parameter defaults.  We are only
    ** doing this when we look up by name because
    ** this is the only time we cache, and it can
    ** be foolish to look up the parameter defaults
    ** for someone that doesn't need them.
    */
    if (spsd != null)
    {
            List<DataValueDescriptor> tmpDefaults = new ArrayList<DataValueDescriptor>();
            spsd.setParams(getSPSParams(spsd, tmpDefaults));
            Object[] defaults = tmpDefaults.toArray();
      spsd.setParameterDefaults(defaults);
    }

    return spsd;
  }
View Full Code Here

   
    while (e.hasMoreElements())
    {
      String spsName = (String)e.nextElement();
      String spsText =  p.getProperty(spsName);
      SPSDescriptor spsd = new SPSDescriptor(this, spsName,
                           getUUIDFactory().createUUID(),
                           schemaID,
                           schemaID,
                           SPSDescriptor.SPS_TYPE_REGULAR,
                           !nocompile,    // it is valid, unless nocompile
View Full Code Here

    TupleDescriptor      parentTupleDescriptor,
    DataDictionary       dd )
          throws StandardException
  {
    DataValueDescriptor      col;
    SPSDescriptor        descriptor;
    String            name;
    String            text;
    String            usingText;
    UUID            uuid;
    UUID            compUuid = null;
    String            uuidStr;
    UUID            suuid;    // schema
    String            suuidStr;  // schema
    String            typeStr;
    char            type;
    boolean            valid;
    Timestamp          time = null;
    ExecPreparedStatement    preparedStatement = null;
    boolean            initiallyCompilable;
    DataDescriptorGenerator    ddg = dd.getDataDescriptorGenerator();

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(row.nColumns() == SYSSTATEMENTS_COLUMN_COUNT,
                 "Wrong number of columns for a SYSSTATEMENTS row");
    }

    // 1st column is STMTID (UUID - char(36))
    col = row.getColumn(1);
    uuidStr = col.getString();
    uuid = getUUIDFactory().recreateUUID(uuidStr);

    // 2nd column is STMTNAME (varchar(128))
    col = row.getColumn(2);
    name = col.getString();

    // 3rd column is SCHEMAID (UUID - char(36))
    col = row.getColumn(3);
    suuidStr = col.getString();
    suuid = getUUIDFactory().recreateUUID(suuidStr);

    // 4th column is TYPE (char(1))
    col = row.getColumn(4);
    type = col.getString().charAt(0);

    if (SanityManager.DEBUG)
    {
      if (!SPSDescriptor.validType(type))
      {
        SanityManager.THROWASSERT("Bad type value ("+type+") for  statement "+name);
      }
    }

    // In soft upgrade mode the plan may not be understand by this engine
    // so force a recompile.
    if (dd.isReadOnlyUpgrade()) {
      valid = false;
    } else {
      // 5th column is VALID (boolean)
      col = row.getColumn(5);
      valid = col.getBoolean();
    }

    // 6th column is TEXT (LONG VARCHAR)
    col = row.getColumn(6);
    text = col.getString();

    /* 7th column is LASTCOMPILED (TIMESTAMP) */
    col = row.getColumn(7);
    time = col.getTimestamp(new java.util.GregorianCalendar());

    // 8th column is COMPILATIONSCHEMAID (UUID - char(36))
    col = row.getColumn(8);
    uuidStr = col.getString();
    if (uuidStr != null)
      compUuid = getUUIDFactory().recreateUUID(uuidStr);

    // 9th column is TEXT (LONG VARCHAR)
    col = row.getColumn(9);
    usingText = col.getString();

    // 10th column is CONSTANTSTATE (COM...ExecPreparedStatement)

    // Only load the compiled plan if the statement is valid
    if (valid) {
      col = row.getColumn(10);
      preparedStatement = (ExecPreparedStatement) col.getObject();
    }

    // 11th column is INITIALLY_COMPILABLE (boolean)
    col = row.getColumn(11);
    if ( col.isNull() ) { initiallyCompilable = true; }
    else { initiallyCompilable = col.getBoolean(); }

    descriptor = new SPSDescriptor(dd, name,
                  uuid,
                  suuid,
                  compUuid,
                  type,
                  valid,
View Full Code Here

     * entry.  Don't want to block.
     */
    lcc.beginNestedTransaction(true);

    DataDictionary dd = getLanguageConnectionContext().getDataDictionary();
    SPSDescriptor spsd = dd.getSPSDescriptor(
                    spsName,
                    net ? dd.getSysIBMSchemaDescriptor() :
                    dd.getSystemSchemaDescriptor());
    lcc.commitNestedTransaction();

View Full Code Here

   * @exception StandardException    Thrown on failure
   */
  public void  executeConstantAction(Activation activation)
            throws StandardException
  {
    SPSDescriptor        whenspsd = null;
    SPSDescriptor        actionspsd;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();
View Full Code Here

    */
    String spsName = "TRIGGER" +
            (isWhen ? "WHEN_" : "ACTN_") +
            triggerId + "_" + triggerTable.getUUID().toString();

    SPSDescriptor spsd = new SPSDescriptor(dd, spsName,
                  (spsId == null) ?
                    dd.getUUIDFactory().createUUID() :
                    spsId,
                  sd.getUUID(),
                  compSchemaId == null ?
                    lcc.getDefaultSchema().getUUID() :
                    compSchemaId,
                  SPSDescriptor.SPS_TYPE_TRIGGER,
                  true,        // it is valid
                  text,        // the text
                  true )// no defaults

    /*
    ** Prepared the stored prepared statement
    ** and release the activation class -- we
    ** know we aren't going to execute statement
    ** after create it, so for now we are finished.
    */
    spsd.prepareAndRelease(lcc, triggerTable);


    dd.addSPSDescriptor(spsd, tc);

    return spsd;
View Full Code Here

      //    AFTER UPDATE OF c12
      //    ON DERBY4998_SOFT_UPGRADE_RESTRICT REFERENCING OLD AS oldt
      //    FOR EACH ROW
      //    SELECT oldt.c11 from DERBY4998_SOFT_UPGRADE_RESTRICT

            SPSDescriptor sps = isWhenClause ? trd.getWhenClauseSPS(lcc)
                                             : trd.getActionSPS(lcc);
      int[] referencedColsInTriggerAction = new int[td.getNumberOfColumns()];
      java.util.Arrays.fill(referencedColsInTriggerAction, -1);
            String newText = dd.getTriggerActionString(node,
        trd.getOldReferencingName(),
        trd.getNewReferencingName(),
                originalSQL,
        trd.getReferencedCols(),
        referencedColsInTriggerAction,
        0,
        trd.getTableDescriptor(),
        trd.getTriggerEventMask(),
                true,
                null);

            if (isWhenClause) {
                // The WHEN clause is not a full SQL statement, just a search
                // condition, so we need to turn it into a statement in order
                // to create an SPS.
                newText = "VALUES " + newText;
            }

            sps.setText(newText);
     
      // Now that we have the internal format of the trigger action sql,
      // bind that sql to make sure that we are not using colunm being
      // dropped in the trigger action sql directly (ie not through
      // REFERENCING clause.
      // eg
      // create table atdc_12 (a integer, b integer);
      // create trigger atdc_12_trigger_1 after update of a
      //     on atdc_12 for each row select a,b from atdc_12
      // Drop one of the columns used in the trigger action
      //   alter table atdc_12 drop column b
      // Following rebinding of the trigger action sql will catch the use
      // of column b in trigger atdc_12_trigger_1
      newCC = lcc.pushCompilerContext(compSchema);
        newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
      pa = newCC.getParser();
            StatementNode stmtnode = (StatementNode) pa.parseStatement(newText);
      // need a current dependent for bind
            newCC.setCurrentDependent(sps.getPreparedStatement());
      stmtnode.bindStatement();
    } catch (StandardException se)
    {
      //Need to catch for few different kinds of sql states depending
      // on what kind of trigger action sql is using the column being
View Full Code Here

     * </p>
     *
     * @throws StandardException if trigger execution fails
     */
    final void executeWhenClauseAndAction() throws StandardException {
        SPSDescriptor whenClauseDescriptor = getWhenClause();
        if (whenClauseDescriptor == null ||
                executeSPS(whenClauseDescriptor, true)) {
            executeSPS(getAction(), false);
        }
    }
View Full Code Here

TOP

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

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.