Search in sources :

Example 41 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method getSubCheckConstraint.

/**
 * Get a SubCheckConstraintDescriptor from syschecks for
 * the specified constraint id.  (Useful for check constraints.)
 *
 * @param constraintId	The UUID for the constraint.
 *
 * @return SubCheckConstraintDescriptor	The Sub descriptor for the constraint.
 *
 * @exception StandardException		Thrown on failure
 */
private SubCheckConstraintDescriptor getSubCheckConstraint(UUID constraintId) throws StandardException {
    DataValueDescriptor constraintIDOrderable = null;
    TabInfoImpl ti = getNonCoreTI(SYSCHECKS_CATALOG_NUM);
    /* Use constraintIDOrderable in both start and stop positions for scan */
    constraintIDOrderable = getIDValueAsCHAR(constraintId);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, constraintIDOrderable);
    return getDescriptorViaIndex(SYSCHECKSRowFactory.SYSCHECKS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SubCheckConstraintDescriptor.class, false);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 42 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method dropConstraintDescriptor.

/**
 * Drops the given ConstraintDescriptor from the data dictionary.
 *
 * @param descriptor	The descriptor to drop
 * @param tc			The TransactionController
 *
 * @exception StandardException		Thrown on error
 */
public void dropConstraintDescriptor(ConstraintDescriptor descriptor, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow = null;
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor constraintNameOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    switch(descriptor.getConstraintType()) {
        case DataDictionary.PRIMARYKEY_CONSTRAINT:
        case DataDictionary.FOREIGNKEY_CONSTRAINT:
        case DataDictionary.UNIQUE_CONSTRAINT:
            dropSubKeyConstraint(descriptor, tc);
            break;
        case DataDictionary.CHECK_CONSTRAINT:
            dropSubCheckConstraint(descriptor.getUUID(), tc);
            break;
    }
    /* Use constraintNameOrderable and schemaIdOrderable in both start 
		 * and stop position for index 2 scan. 
		 */
    constraintNameOrderable = new SQLVarchar(descriptor.getConstraintName());
    schemaIDOrderable = getIDValueAsCHAR(descriptor.getSchemaDescriptor().getUUID());
    /* Set up the start/stop position for the scan */
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(2);
    keyRow.setColumn(1, constraintNameOrderable);
    keyRow.setColumn(2, schemaIDOrderable);
    ti.deleteRow(tc, keyRow, SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX2_ID);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 43 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method updateLockGranularity.

/**
 * Update the lockGranularity for the specified table.
 *
 * @param td				The TableDescriptor for the table
 * @param schema			The SchemaDescriptor for the table
 * @param lockGranularity	The new lockGranularity
 * @param tc				The TransactionController to use.
 *
 * @exception StandardException		Thrown on error
 */
public void updateLockGranularity(TableDescriptor td, SchemaDescriptor schema, char lockGranularity, TransactionController tc) throws StandardException {
    ExecRow row;
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor tableNameOrderable;
    TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
    SYSTABLESRowFactory rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();
    /* Use tableIdOrderable and schemaIdOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    tableNameOrderable = new SQLVarchar(td.getName());
    schemaIDOrderable = getIDValueAsCHAR(schema.getUUID());
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow1 = exFactory.getIndexableRow(2);
    keyRow1.setColumn(1, tableNameOrderable);
    keyRow1.setColumn(2, schemaIDOrderable);
    // build the row to be stuffed into SYSTABLES.
    row = rf.makeRow(td, schema);
    // update row in catalog (no indexes)
    boolean[] bArray = new boolean[2];
    for (int index = 0; index < 2; index++) {
        bArray[index] = false;
    }
    ti.updateRow(keyRow1, row, SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, bArray, (int[]) null, tc);
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 44 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method getViewDescriptorScan.

/**
 * Get the information for the view from sys.sysviews.
 *
 * @param tdi					The TableDescriptor for the view.
 *
 * @return ViewDescriptor	The ViewDescriptor for the view.
 *
 * @exception StandardException		Thrown on error
 */
private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi) throws StandardException {
    ViewDescriptor vd;
    DataValueDescriptor viewIdOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSVIEWS_CATALOG_NUM);
    UUID viewID = tdi.getUUID();
    /* Use viewIdOrderable in both start 
		 * and stop position for scan. 
		 */
    viewIdOrderable = getIDValueAsCHAR(viewID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, viewIdOrderable);
    vd = getDescriptorViaIndex(SYSVIEWSRowFactory.SYSVIEWS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ViewDescriptor.class, false);
    if (vd != null) {
        vd.setViewName(tdi.getName());
    }
    return vd;
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ConglomerateDescriptorList(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList) ArrayList(java.util.ArrayList) TriggerDescriptorList(org.apache.derby.iapi.sql.dictionary.TriggerDescriptorList) List(java.util.List) ConstraintDescriptorList(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList) LinkedList(java.util.LinkedList) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) ViewDescriptor(org.apache.derby.iapi.sql.dictionary.ViewDescriptor)

Example 45 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method getFileInfoDescriptorIndex1Scan.

/**
 * Scan sysfiles_index1 (schemaid,name) for a match.
 * @return The matching descriptor or null.
 * @exception StandardException		Thrown on failure
 */
private FileInfoDescriptor getFileInfoDescriptorIndex1Scan(UUID schemaId, String name) throws StandardException {
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor nameOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSFILES_CATALOG_NUM);
    nameOrderable = new SQLVarchar(name);
    schemaIDOrderable = getIDValueAsCHAR(schemaId);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, nameOrderable);
    keyRow.setColumn(2, schemaIDOrderable);
    FileInfoDescriptor r = getDescriptorViaIndex(SYSFILESRowFactory.SYSFILES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, FileInfoDescriptor.class, false);
    return r;
}
Also used : FileInfoDescriptor(org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor) TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Aggregations

DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)328 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)62 RowLocation (org.apache.derby.iapi.types.RowLocation)54 SQLLongint (org.apache.derby.iapi.types.SQLLongint)51 StandardException (org.apache.derby.shared.common.error.StandardException)43 SQLChar (org.apache.derby.iapi.types.SQLChar)42 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)36 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)36 ScanController (org.apache.derby.iapi.store.access.ScanController)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 UUID (org.apache.derby.catalog.UUID)31 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)24 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)16 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)15 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)15 Properties (java.util.Properties)14 UserType (org.apache.derby.iapi.types.UserType)13 Page (org.apache.derby.iapi.store.raw.Page)11