Search in sources :

Example 6 with SQLVarchar

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

the class DataDictionaryImpl method getTriggerDescriptor.

/**
 * Get the stored prepared statement descriptor given
 * a sps name.
 *
 * @param name	The sps name.
 * @param sd	The schema descriptor.
 *
 * @return The TriggerDescriptor for the constraint.
 *
 * @exception StandardException		Thrown on failure
 */
public TriggerDescriptor getTriggerDescriptor(String name, SchemaDescriptor sd) throws StandardException {
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor triggerNameOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSTRIGGERS_CATALOG_NUM);
    /* Use triggerNameOrderable and schemaIdOrderable in both start 
		 * and stop position for scan. 
		 */
    triggerNameOrderable = new SQLVarchar(name);
    schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, triggerNameOrderable);
    keyRow.setColumn(2, schemaIDOrderable);
    return getDescriptorViaIndex(SYSTRIGGERSRowFactory.SYSTRIGGERS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, TriggerDescriptor.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 7 with SQLVarchar

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

the class DataDictionaryImpl method getTableDescriptorIndex1Scan.

/**
 * Scan systables_index1 (tablename, schemaid) for a match.
 *
 * @return TableDescriptor	The matching descriptor, if any.
 *
 * @exception StandardException		Thrown on failure
 */
private TableDescriptor getTableDescriptorIndex1Scan(String tableName, String schemaUUID) throws StandardException {
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor tableNameOrderable;
    TableDescriptor td;
    TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
    /* Use tableNameOrderable and schemaIdOrderable in both start 
		 * and stop position for scan. 
		 */
    tableNameOrderable = new SQLVarchar(tableName);
    schemaIDOrderable = new SQLChar(schemaUUID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, tableNameOrderable);
    keyRow.setColumn(2, schemaIDOrderable);
    td = getDescriptorViaIndex(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, TableDescriptor.class, false);
    return finishTableDescriptor(td);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) 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) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 8 with SQLVarchar

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

the class DataDictionaryImpl method existsSchemaOwnedBy.

/**
 * Return true of there exists a schema whose authorizationId equals
 * authid, i.e.  SYS.SYSSCHEMAS contains a row whose column
 * (AUTHORIZATIONID) equals authid.
 *
 * @param authid authorizationId
 * @param tc TransactionController
 * @return true iff there is a matching schema
 * @exception StandardException
 */
public boolean existsSchemaOwnedBy(String authid, TransactionController tc) throws StandardException {
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    SYSSCHEMASRowFactory rf = (SYSSCHEMASRowFactory) ti.getCatalogRowFactory();
    ConglomerateController heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
    DataValueDescriptor authIdOrderable = new SQLVarchar(authid);
    ScanQualifier[][] scanQualifier = exFactory.getScanQualifier(1);
    scanQualifier[0][0].setQualifier(SYSSCHEMASRowFactory.SYSSCHEMAS_SCHEMAAID - 1, /* to zero-based */
    authIdOrderable, Orderable.ORDER_OP_EQUALS, false, false, false);
    ScanController sc = tc.openScan(ti.getHeapConglomerate(), // don't hold open across commit
    false, // for update
    0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
    (FormatableBitSet) null, // start position -
    (DataValueDescriptor[]) null, // startSearchOperation - none
    0, // 
    scanQualifier, // stop position -through last row
    (DataValueDescriptor[]) null, // stopSearchOperation - none
    0);
    boolean result = false;
    try {
        ExecRow outRow = rf.makeEmptyRow();
        if (sc.fetchNext(outRow.getRowArray())) {
            result = true;
        }
    } finally {
        if (sc != null) {
            sc.close();
        }
        if (heapCC != null) {
            heapCC.close();
        }
    }
    return result;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar)

Example 9 with SQLVarchar

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

the class DataDictionaryImpl method getRoleDefinitionDescriptor.

/**
 * Get the target role definition by searching for a matching row
 * in SYSROLES by rolename where isDef==true.  Read only scan.
 * Uses index on (rolename, isDef) columns.
 *
 * @param roleName The name of the role we're interested in.
 *
 * @return The descriptor (row) for the role
 * @exception StandardException Thrown on error
 *
 * @see DataDictionary#getRoleDefinitionDescriptor
 */
public RoleGrantDescriptor getRoleDefinitionDescriptor(String roleName) throws StandardException {
    DataValueDescriptor roleNameOrderable;
    DataValueDescriptor isDefOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSROLES_CATALOG_NUM);
    /* Use aliasNameOrderable , isDefOrderable in both start
		 * and stop position for scan.
		 */
    roleNameOrderable = new SQLVarchar(roleName);
    isDefOrderable = new SQLVarchar("Y");
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, roleNameOrderable);
    keyRow.setColumn(2, isDefOrderable);
    return getDescriptorViaIndex(SYSROLESRowFactory.SYSROLES_INDEX_ID_DEF_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 10 with SQLVarchar

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

the class DataDictionaryImpl method getConglomerateDescriptor.

/**
 * Gets a conglomerate descriptor for the named index in the given schema,
 * getting an exclusive row lock on the matching row in
 * sys.sysconglomerates (for DDL concurrency) if requested.
 *
 * @param indexName	The name of the index we're looking for
 * @param sd		The schema descriptor
 * @param forUpdate	Whether or not to get an exclusive row
 *					lock on the row in sys.sysconglomerates.
 *
 * @return	A ConglomerateDescriptor describing the requested
 *		conglomerate. Returns NULL if no such conglomerate.
 *
 * @exception StandardException		Thrown on failure
 */
public ConglomerateDescriptor getConglomerateDescriptor(String indexName, SchemaDescriptor sd, boolean forUpdate) throws StandardException {
    ExecIndexRow keyRow2 = null;
    DataValueDescriptor nameOrderable;
    DataValueDescriptor schemaIDOrderable = null;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    nameOrderable = new SQLVarchar(indexName);
    schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
    /* Set up the start/stop position for the scan */
    keyRow2 = exFactory.getIndexableRow(2);
    keyRow2.setColumn(1, nameOrderable);
    keyRow2.setColumn(2, schemaIDOrderable);
    return getDescriptorViaIndex(SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX2_ID, keyRow2, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ConglomerateDescriptor.class, forUpdate);
}
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)

Aggregations

SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)45 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)33 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)30 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)22 SQLChar (org.apache.derby.iapi.types.SQLChar)18 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)13 UUID (org.apache.derby.catalog.UUID)9 SQLLongint (org.apache.derby.iapi.types.SQLLongint)6 ScanController (org.apache.derby.iapi.store.access.ScanController)5 UserType (org.apache.derby.iapi.types.UserType)5 Timestamp (java.sql.Timestamp)4 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)4 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)4 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)4 SQLBoolean (org.apache.derby.iapi.types.SQLBoolean)4 ArrayList (java.util.ArrayList)3 AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)3 SQLTimestamp (org.apache.derby.iapi.types.SQLTimestamp)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2