Search in sources :

Example 26 with DataDictionary

use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.

the class DropSequenceNode method bindStatement.

/**
 * Bind this DropSequenceNode.
 *
 * @throws StandardException Thrown on error
 */
@Override
public void bindStatement() throws StandardException {
    DataDictionary dataDictionary = getDataDictionary();
    String sequenceName = getRelativeName();
    SequenceDescriptor seqDesc = null;
    SchemaDescriptor sd = getSchemaDescriptor();
    if (sd.getUUID() != null) {
        seqDesc = dataDictionary.getSequenceDescriptor(sd, sequenceName);
    }
    if (seqDesc == null) {
        throw StandardException.newException(SQLState.LANG_OBJECT_DOES_NOT_EXIST, statementToString(), sequenceName);
    }
    // Statement is dependent on the SequenceDescriptor
    getCompilerContext().createDependency(seqDesc);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) SequenceDescriptor(org.apache.derby.iapi.sql.dictionary.SequenceDescriptor)

Example 27 with DataDictionary

use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.

the class DropTriggerNode method bindStatement.

/**
 * Bind this DropTriggerNode.  This means looking up the trigger,
 * verifying it exists and getting its table uuid.
 *
 * @exception StandardException		Thrown on error
 */
@Override
public void bindStatement() throws StandardException {
    CompilerContext cc = getCompilerContext();
    DataDictionary dd = getDataDictionary();
    SchemaDescriptor sd = getSchemaDescriptor();
    TriggerDescriptor triggerDescriptor = null;
    if (sd.getUUID() != null)
        triggerDescriptor = dd.getTriggerDescriptor(getRelativeName(), sd);
    if (triggerDescriptor == null) {
        throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND, "TRIGGER", getFullName());
    }
    /* Get the table descriptor */
    td = triggerDescriptor.getTableDescriptor();
    cc.createDependency(td);
    cc.createDependency(triggerDescriptor);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TriggerDescriptor(org.apache.derby.iapi.sql.dictionary.TriggerDescriptor)

Example 28 with DataDictionary

use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.

the class DropViewNode method bindStatement.

/**
 *  Bind the drop view node
 *
 * @exception StandardException		Thrown on error
 */
@Override
public void bindStatement() throws StandardException {
    DataDictionary dd = getDataDictionary();
    CompilerContext cc = getCompilerContext();
    TableDescriptor td = dd.getTableDescriptor(getRelativeName(), getSchemaDescriptor(), getLanguageConnectionContext().getTransactionCompile());
    /* 
		 * Statement is dependent on the TableDescriptor 
		 * If td is null, let execution throw the error like
		 * it is before.
		 */
    if (td != null) {
        cc.createDependency(td);
    }
}
Also used : CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 29 with DataDictionary

use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.

the class ExecSPSNode method bindStatement.

/**
 * Bind this ExecSPSNode.  This means doing any static error
 * checking that can be done before actually creating the table.
 * For example, verifying that the ResultColumnList does not
 * contain any duplicate column names.
 *
 * @exception StandardException		Thrown on error
 */
@Override
public void bindStatement() throws StandardException {
    /*
		** Grab the compiler context each time we bind just
		** to make sure we have the write one (even though
		** we are caching it).
		*/
    DataDictionary dd = getDataDictionary();
    String schemaName = name.getSchemaName();
    SchemaDescriptor sd = getSchemaDescriptor(name.getSchemaName());
    if (schemaName == null)
        name.setSchemaName(sd.getSchemaName());
    if (sd.getUUID() != null)
        spsd = dd.getSPSDescriptor(name.getTableName(), sd);
    if (spsd == null) {
        throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND, "STATEMENT", name);
    }
    if (spsd.getType() == SPSDescriptor.SPS_TYPE_TRIGGER) {
        throw StandardException.newException(SQLState.LANG_TRIGGER_SPS_CANNOT_BE_EXECED, name);
    }
    /*
		** This execute statement is dependent on the
		** stored prepared statement.  If for any reason
		** the underlying statement is invalidated by
		** the time we get to execution, the 'execute statement'
		** will get invalidated when the underlying statement
		** is invalidated.
		*/
    getCompilerContext().createDependency(spsd);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 30 with DataDictionary

use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.

the class BaseJoinStrategy method fillInScanArgs2.

final void fillInScanArgs2(MethodBuilder mb, Optimizable innerTable, int bulkFetch, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel) throws StandardException {
    mb.push(innerTable.getBaseTableName());
    // run time statistics.
    if (innerTable.getProperties() != null)
        mb.push(PropertyUtil.sortProperties(innerTable.getProperties()));
    else
        mb.pushNull("java.lang.String");
    ConglomerateDescriptor cd = innerTable.getTrulyTheBestAccessPath().getConglomerateDescriptor();
    if (cd.isConstraint()) {
        DataDictionary dd = innerTable.getDataDictionary();
        TableDescriptor td = innerTable.getTableDescriptor();
        ConstraintDescriptor constraintDesc = dd.getConstraintDescriptor(td, cd.getUUID());
        mb.push(constraintDesc.getConstraintName());
    } else if (cd.isIndex()) {
        mb.push(cd.getConglomerateName());
    } else {
        mb.pushNull("java.lang.String");
    }
    // Whether or not the conglomerate is the backing index for a constraint
    mb.push(cd.isConstraint());
    // tell it whether it's to open for update, which we should do if
    // it's an update or delete statement, or if it's the target
    // table of an updatable cursor.
    mb.push(innerTable.forUpdate());
    mb.push(colRefItem);
    mb.push(indexColItem);
    mb.push(lockMode);
    mb.push(tableLocked);
    mb.push(isolationLevel);
    if (bulkFetch > 0) {
        mb.push(bulkFetch);
        // If the table references LOBs, we want to disable bulk fetching
        // when the cursor is holdable. Otherwise, a commit could close
        // LOBs before they have been returned to the user.
        mb.push(innerTable.hasLargeObjectColumns());
    }
    /* 1 row scans (avoiding 2nd next()) are
 		 * only meaningful for some join strategies.
		 * (Only an issue for outer table, which currently
		 * can only be nested loop, as avoidance of 2nd next
		 * on inner table already factored in to join node.)
		 */
    if (validForOutermostTable()) {
        mb.push(innerTable.isOneRowScan());
    }
    mb.push(innerTable.getTrulyTheBestAccessPath().getCostEstimate().rowCount());
    mb.push(innerTable.getTrulyTheBestAccessPath().getCostEstimate().getEstimatedCost());
}
Also used : ConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Aggregations

DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)102 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)57 TransactionController (org.apache.derby.iapi.store.access.TransactionController)40 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)33 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)23 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)22 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)17 StandardException (org.apache.derby.shared.common.error.StandardException)16 UUID (org.apache.derby.catalog.UUID)15 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)15 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)13 CompilerContext (org.apache.derby.iapi.sql.compile.CompilerContext)10 AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)9 RoleGrantDescriptor (org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)8 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)7 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)7 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)7 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)6 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)6 Iterator (java.util.Iterator)5