Search in sources :

Example 76 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getSequenceDescriptor.

/**
 * Get the sequence descriptor given a sequence name and a schema Id.
 *
 * @param sequenceName The sequence name, guaranteed to be unique only within its schema.
 * @param sd           The schema descriptor.
 * @return The SequenceDescriptor for the constraints.
 * @throws StandardException Thrown on failure
 */
public SequenceDescriptor getSequenceDescriptor(SchemaDescriptor sd, String sequenceName) throws StandardException {
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor sequenceNameOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSSEQUENCES_CATALOG_NUM);
    /* Use sequenceNameOrderable and schemaIdOrderable in both start
           * and stop position for scan.
           */
    sequenceNameOrderable = new SQLVarchar(sequenceName);
    schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, schemaIDOrderable);
    keyRow.setColumn(2, sequenceNameOrderable);
    SequenceDescriptor sequenceDescriptor = getDescriptorViaIndex(SYSSEQUENCESRowFactory.SYSSEQUENCES_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SequenceDescriptor.class, false);
    putSequenceID(sequenceDescriptor);
    return sequenceDescriptor;
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) SequenceDescriptor(org.apache.derby.iapi.sql.dictionary.SequenceDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 77 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method dropSchemaDescriptor.

/**
 * Drop the descriptor for a schema, given the schema's name
 *
 * @param schemaName	The name of the schema to drop
 * @param tc			TransactionController for the transaction
 *
 * @exception StandardException		Thrown on error
 */
public void dropSchemaDescriptor(String schemaName, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow1 = null;
    DataValueDescriptor schemaNameOrderable;
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    if (SanityManager.DEBUG) {
        SchemaDescriptor sd = getSchemaDescriptor(schemaName, getTransactionCompile(), true);
        if (!isSchemaEmpty(sd)) {
            SanityManager.THROWASSERT("Attempt to drop schema " + schemaName + " that is not empty");
        }
    }
    /* Use schemaNameOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    schemaNameOrderable = new SQLVarchar(schemaName);
    /* Set up the start/stop position for the scan */
    keyRow1 = exFactory.getIndexableRow(1);
    keyRow1.setColumn(1, schemaNameOrderable);
    ti.deleteRow(tc, keyRow1, SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX1_ID);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 78 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method dropAllTableAndColPermDescriptors.

/**
 * Drops all table and column permission descriptors for the given table.
 *
 * @param tableID	The UUID of the table from which to drop
 *			all the permission descriptors
 * @param tc		TransactionController for the transaction
 *
 * @exception StandardException		Thrown on error
 */
public void dropAllTableAndColPermDescriptors(UUID tableID, TransactionController tc) throws StandardException {
    DataValueDescriptor tableIdOrderable;
    // In Derby authorization mode, permission catalogs may not be present
    if (!usesSqlAuthorization)
        return;
    /* Use tableIDOrderable in both start and stop position for scan. */
    tableIdOrderable = getIDValueAsCHAR(tableID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, tableIdOrderable);
    dropTablePermDescriptor(tc, keyRow);
    dropColumnPermDescriptor(tc, keyRow);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 79 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getRoleGrantDescriptor.

/**
 * Get the target role by searching for a matching row
 * in SYSROLES by rolename, grantee and grantor.  Read only scan.
 * Uses index on roleid, grantee and grantor columns.
 *
 * @param roleName	    The name of the role we're interested in.
 * @param grantee       The grantee
 * @param grantor       The grantor
 *
 * @return	            The descriptor for the role grant
 *
 * @exception StandardException  Thrown on error
 *
 * @see DataDictionary#getRoleGrantDescriptor(String, String, String)
 */
public RoleGrantDescriptor getRoleGrantDescriptor(String roleName, String grantee, String grantor) throws StandardException {
    DataValueDescriptor roleNameOrderable;
    DataValueDescriptor granteeOrderable;
    DataValueDescriptor grantorOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSROLES_CATALOG_NUM);
    /* Use aliasNameOrderable, granteeOrderable and
		 * grantorOrderable in both start and stop position for scan.
		 */
    roleNameOrderable = new SQLVarchar(roleName);
    granteeOrderable = new SQLVarchar(grantee);
    grantorOrderable = new SQLVarchar(grantor);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(3);
    keyRow.setColumn(1, roleNameOrderable);
    keyRow.setColumn(2, granteeOrderable);
    keyRow.setColumn(3, grantorOrderable);
    return getDescriptorViaIndex(SYSROLESRowFactory.SYSROLES_INDEX_ID_EE_OR_IDX, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, RoleGrantDescriptor.class, false);
}
Also used : 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)

Example 80 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method setAutoincrementValue.

/**
 * sets a new value in SYSCOLUMNS for a particular
 * autoincrement column.
 *
 * @param tc		 Transaction Controller to use.
 * @param columnName Name of the column.
 * @param aiValue	 Value to write to SYSCOLUMNS.
 * @param incrementNeeded whether to increment the value passed in by the
 * user (aiValue) or not before writing it to SYSCOLUMNS.
 */
public void setAutoincrementValue(TransactionController tc, UUID tableUUID, String columnName, long aiValue, boolean incrementNeeded) throws StandardException {
    TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
    ExecIndexRow keyRow = null;
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(2);
    keyRow.setColumn(1, getIDValueAsCHAR(tableUUID));
    keyRow.setColumn(2, new SQLChar(columnName));
    SYSCOLUMNSRowFactory rf = (SYSCOLUMNSRowFactory) ti.getCatalogRowFactory();
    ExecRow row = rf.makeEmptyRow();
    boolean[] bArray = new boolean[2];
    for (int index = 0; index < 2; index++) {
        bArray[index] = false;
    }
    int[] colsToUpdate = new int[1];
    colsToUpdate[0] = SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTVALUE;
    if (incrementNeeded) {
        ExecRow readRow = ti.getRow(tc, keyRow, SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID);
        NumberDataValue increment = (NumberDataValue) readRow.getColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTINC);
        aiValue += increment.getLong();
    }
    row.setColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTVALUE, new SQLLongint(aiValue));
    ti.updateRow(keyRow, row, SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID, bArray, colsToUpdate, tc);
}
Also used : SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLChar(org.apache.derby.iapi.types.SQLChar) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) NumberDataValue(org.apache.derby.iapi.types.NumberDataValue) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)110 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)34 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)30 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)27 SQLChar (org.apache.derby.iapi.types.SQLChar)22 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)14 SQLLongint (org.apache.derby.iapi.types.SQLLongint)13 RowLocation (org.apache.derby.iapi.types.RowLocation)12 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ScanController (org.apache.derby.iapi.store.access.ScanController)9 UUID (org.apache.derby.catalog.UUID)8 ArrayList (java.util.ArrayList)7 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)6 ConglomerateDescriptorList (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList)6 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)6 TransactionController (org.apache.derby.iapi.store.access.TransactionController)6 Properties (java.util.Properties)5 PermissionsDescriptor (org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor)5 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)5