Search in sources :

Example 41 with SQLChar

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

the class SYSROLESRowFactory method makeRow.

/**
 * Make a SYSROLES row
 *
 * @param td a role grant descriptor
 * @param parent unused
 *
 * @return  Row suitable for inserting into SYSROLES.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    ExecRow row;
    String oid_string = null;
    String roleid = null;
    String grantee = null;
    String grantor = null;
    boolean wao = false;
    boolean isdef = false;
    if (td != null) {
        RoleGrantDescriptor rgd = (RoleGrantDescriptor) td;
        roleid = rgd.getRoleName();
        grantee = rgd.getGrantee();
        grantor = rgd.getGrantor();
        wao = rgd.isWithAdminOption();
        isdef = rgd.isDef();
        UUID oid = rgd.getUUID();
        oid_string = oid.toString();
    }
    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSROLES_COLUMN_COUNT);
    /* 1st column is UUID */
    row.setColumn(1, new SQLChar(oid_string));
    /* 2nd column is ROLEID */
    row.setColumn(2, new SQLVarchar(roleid));
    /* 3rd column is GRANTEE */
    row.setColumn(3, new SQLVarchar(grantee));
    /* 4th column is GRANTOR */
    row.setColumn(4, new SQLVarchar(grantor));
    /* 5th column is WITHADMINOPTION */
    row.setColumn(5, new SQLChar(wao ? "Y" : "N"));
    /* 6th column is ISDEF */
    row.setColumn(6, new SQLChar(isdef ? "Y" : "N"));
    return row;
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) UUID(org.apache.derby.catalog.UUID) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) RoleGrantDescriptor(org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)

Example 42 with SQLChar

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

the class SYSROUTINEPERMSRowFactory method makeRow.

public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    UUID oid;
    String routinePermID = null;
    DataValueDescriptor grantee = null;
    DataValueDescriptor grantor = null;
    String routineID = null;
    if (td == null) {
        grantee = getNullAuthorizationID();
        grantor = getNullAuthorizationID();
    } else {
        RoutinePermsDescriptor rpd = (RoutinePermsDescriptor) td;
        oid = rpd.getUUID();
        if (oid == null) {
            oid = getUUIDFactory().createUUID();
            rpd.setUUID(oid);
        }
        routinePermID = oid.toString();
        grantee = getAuthorizationID(rpd.getGrantee());
        grantor = getAuthorizationID(rpd.getGrantor());
        if (rpd.getRoutineUUID() != null)
            routineID = rpd.getRoutineUUID().toString();
    }
    ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
    row.setColumn(ROUTINEPERMSID_COL_NUM, new SQLChar(routinePermID));
    row.setColumn(GRANTEE_COL_NUM, grantee);
    row.setColumn(GRANTOR_COL_NUM, grantor);
    row.setColumn(ALIASID_COL_NUM, new SQLChar(routineID));
    row.setColumn(GRANTOPTION_COL_NUM, new SQLChar("N"));
    return row;
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) RoutinePermsDescriptor(org.apache.derby.iapi.sql.dictionary.RoutinePermsDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 43 with SQLChar

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

the class SYSROUTINEPERMSRowFactory method buildIndexKeyRow.

/**
 * builds an index key row given for a given index number.
 */
public ExecIndexRow buildIndexKeyRow(int indexNumber, PermissionsDescriptor perm) throws StandardException {
    ExecIndexRow row = null;
    switch(indexNumber) {
        case GRANTEE_ALIAS_GRANTOR_INDEX_NUM:
            // RESOLVE We do not support the FOR GRANT OPTION, so rougine permission rows are unique on the
            // grantee and alias UUID columns. The grantor column will always have the name of the owner of the
            // routine. So the index key, used for searching the index, only has grantee and alias UUID columns.
            // It does not have a grantor column.
            // 
            // If we support FOR GRANT OPTION then there may be multiple routine permissions rows for a
            // (grantee, aliasID) combination. Since there is only one kind of routine permission (execute)
            // execute permission checking need not worry about multiple routine permission rows for a
            // (grantee, aliasID) combination, it only cares whether there are any. Grant and revoke must
            // look through multiple rows to see if the current user has grant/revoke permission and use
            // the full key in checking for the pre-existence of the permission being granted or revoked.
            row = getExecutionFactory().getIndexableRow(2);
            row.setColumn(1, getAuthorizationID(perm.getGrantee()));
            String routineUUIDStr = ((RoutinePermsDescriptor) perm).getRoutineUUID().toString();
            row.setColumn(2, new SQLChar(routineUUIDStr));
            break;
        case ROUTINEPERMSID_INDEX_NUM:
            row = getExecutionFactory().getIndexableRow(1);
            String routinePermsUUIDStr = perm.getObjectID().toString();
            row.setColumn(1, new SQLChar(routinePermsUUIDStr));
            break;
        case ALIASID_INDEX_NUM:
            row = getExecutionFactory().getIndexableRow(1);
            routineUUIDStr = ((RoutinePermsDescriptor) perm).getRoutineUUID().toString();
            row.setColumn(1, new SQLChar(routineUUIDStr));
            break;
    }
    return row;
}
Also used : SQLChar(org.apache.derby.iapi.types.SQLChar) RoutinePermsDescriptor(org.apache.derby.iapi.sql.dictionary.RoutinePermsDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 44 with SQLChar

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

the class SYSTABLESRowFactory method makeRow.

// ///////////////////////////////////////////////////////////////////////////
// 
// METHODS
// 
// ///////////////////////////////////////////////////////////////////////////
/**
 * Make a SYSTABLES row
 *
 * @return	Row suitable for inserting into SYSTABLES.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    UUID oid;
    String tabSType = null;
    int tabIType;
    ExecRow row;
    String lockGranularity = null;
    String tableID = null;
    String schemaID = null;
    String tableName = null;
    if (td != null) {
        /*
			** We only allocate a new UUID if the descriptor doesn't already have one.
			** For descriptors replicated from a Source system, we already have an UUID.
			*/
        TableDescriptor descriptor = (TableDescriptor) td;
        SchemaDescriptor schema = (SchemaDescriptor) parent;
        oid = descriptor.getUUID();
        if (oid == null) {
            oid = getUUIDFactory().createUUID();
            descriptor.setUUID(oid);
        }
        tableID = oid.toString();
        if (SanityManager.DEBUG) {
            SanityManager.ASSERT(schema != null, "Schema should not be null unless empty row is true");
            if (schema.getUUID() == null) {
                SanityManager.THROWASSERT("schema " + schema + " has a null OID");
            }
        }
        schemaID = schema.getUUID().toString();
        tableName = descriptor.getName();
        /* RESOLVE - Table Type should really be a char in the descriptor
			 * T, S, V, S instead of 0, 1, 2, 3
			 */
        tabIType = descriptor.getTableType();
        switch(tabIType) {
            case TableDescriptor.BASE_TABLE_TYPE:
                tabSType = "T";
                break;
            case TableDescriptor.SYSTEM_TABLE_TYPE:
                tabSType = "S";
                break;
            case TableDescriptor.VIEW_TYPE:
                tabSType = "V";
                break;
            case TableDescriptor.SYNONYM_TYPE:
                tabSType = "A";
                break;
            default:
                if (SanityManager.DEBUG)
                    SanityManager.THROWASSERT("invalid table type");
        }
        char[] lockGChar = new char[1];
        lockGChar[0] = descriptor.getLockGranularity();
        lockGranularity = new String(lockGChar);
    }
    /* Insert info into systables */
    /* RESOLVE - It would be nice to require less knowledge about systables
		 * and have this be more table driven.
		 */
    /* Build the row to insert  */
    row = getExecutionFactory().getValueRow(SYSTABLES_COLUMN_COUNT);
    /* 1st column is TABLEID (UUID - char(36)) */
    row.setColumn(SYSTABLES_TABLEID, new SQLChar(tableID));
    /* 2nd column is NAME (varchar(30)) */
    row.setColumn(SYSTABLES_TABLENAME, new SQLVarchar(tableName));
    /* 3rd column is TABLETYPE (char(1)) */
    row.setColumn(SYSTABLES_TABLETYPE, new SQLChar(tabSType));
    /* 4th column is SCHEMAID (UUID - char(36)) */
    row.setColumn(SYSTABLES_SCHEMAID, new SQLChar(schemaID));
    /* 5th column is LOCKGRANULARITY (char(1)) */
    row.setColumn(SYSTABLES_LOCKGRANULARITY, new SQLChar(lockGranularity));
    return row;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) UUID(org.apache.derby.catalog.UUID) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 45 with SQLChar

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

the class SYSTABLESRowFactory method buildEmptyIndexRow.

/**
 * Builds an empty index row.
 *
 *	@param	indexNumber	Index to build empty row for.
 *  @param  rowLocation	Row location for last column of index row
 *
 * @return corresponding empty index row
 * @exception   StandardException thrown on failure
 */
ExecIndexRow buildEmptyIndexRow(int indexNumber, RowLocation rowLocation) throws StandardException {
    int ncols = getIndexColumnCount(indexNumber);
    ExecIndexRow row = getExecutionFactory().getIndexableRow(ncols + 1);
    row.setColumn(ncols + 1, rowLocation);
    switch(indexNumber) {
        case SYSTABLES_INDEX1_ID:
            /* 1st column is TABLENAME (varchar(128)) */
            row.setColumn(1, new SQLVarchar());
            /* 2nd column is SCHEMAID (UUID - char(36)) */
            row.setColumn(2, new SQLChar());
            break;
        case SYSTABLES_INDEX2_ID:
            /* 1st column is TABLEID (UUID - char(36)) */
            row.setColumn(1, new SQLChar());
            break;
    }
    return row;
}
Also used : SQLChar(org.apache.derby.iapi.types.SQLChar) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Aggregations

SQLChar (org.apache.derby.iapi.types.SQLChar)60 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)42 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)22 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)21 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)18 UUID (org.apache.derby.catalog.UUID)15 SQLLongint (org.apache.derby.iapi.types.SQLLongint)13 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)12 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)12 RowLocation (org.apache.derby.iapi.types.RowLocation)10 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)9 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)8 StandardException (org.apache.derby.shared.common.error.StandardException)8 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)7 UserType (org.apache.derby.iapi.types.UserType)7 ScanController (org.apache.derby.iapi.store.access.ScanController)6 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)4 LinkedList (java.util.LinkedList)3