Search in sources :

Example 36 with SQLVarchar

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

the class DataDictionaryImpl method upgradeSYSROUTINEPERMS_10_6.

/**
 * 10.6 upgrade logic to update the permissions granted to SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE.
 * If a 10.0 database was upgraded to 10.2, 10.3, or 10.4, then there will
 * be an extra permissions tuple in SYSROUTINEPERMS--that tuple will have a
 * null grantor field. We must delete this tuple. See DERBY-4215.
 */
void upgradeSYSROUTINEPERMS_10_6(TransactionController tc) throws StandardException {
    // 
    // Get the aliasID of SYSCS_INPLACE_COMPRESS_TABLE
    // 
    TabInfoImpl aliasTI = getNonCoreTI(SYSALIASES_CATALOG_NUM);
    ExecIndexRow aliasKeyRow = exFactory.getIndexableRow(3);
    DataValueDescriptor aliasNameOrderable = new SQLVarchar("SYSCS_INPLACE_COMPRESS_TABLE");
    ;
    DataValueDescriptor nameSpaceOrderable = new SQLChar(new String(new char[] { AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR }));
    aliasKeyRow.setColumn(1, new SQLChar(SchemaDescriptor.SYSCS_UTIL_SCHEMA_UUID));
    aliasKeyRow.setColumn(2, aliasNameOrderable);
    aliasKeyRow.setColumn(3, nameSpaceOrderable);
    AliasDescriptor oldAD = getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, aliasKeyRow, (ScanQualifier[][]) null, aliasTI, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, true, TransactionController.ISOLATION_REPEATABLE_READ, tc);
    UUID aliasID = oldAD.getUUID();
    // 
    // Now delete the permissions tuple which has a null grantor
    // 
    TabInfoImpl rpTI = getNonCoreTI(SYSROUTINEPERMS_CATALOG_NUM);
    ExecIndexRow rpKeyRow = exFactory.getIndexableRow(3);
    rpKeyRow.setColumn(1, new SQLVarchar("PUBLIC"));
    rpKeyRow.setColumn(2, new SQLChar(aliasID.toString()));
    rpKeyRow.setColumn(3, new SQLVarchar((String) null));
    int deleteCount = rpTI.deleteRow(tc, rpKeyRow, SYSROUTINEPERMSRowFactory.GRANTEE_ALIAS_GRANTOR_INDEX_NUM);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) UUID(org.apache.derby.catalog.UUID) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 37 with SQLVarchar

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

the class DataDictionaryImpl method dropTableDescriptor.

/**
 * Drop the table descriptor.
 *
 * @param td	The table descriptor to drop
 * @param schema		A descriptor for the schema the table
 *						is a part of.  If this parameter is
 *						NULL, then the table is part of the
 *						current (default) schema
 * @param tc			TransactionController for the transaction
 *
 * @exception StandardException		Thrown on error
 */
public void dropTableDescriptor(TableDescriptor td, SchemaDescriptor schema, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow1 = null;
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor tableNameOrderable;
    TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
    /* 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 */
    keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(2);
    keyRow1.setColumn(1, tableNameOrderable);
    keyRow1.setColumn(2, schemaIDOrderable);
    ti.deleteRow(tc, keyRow1, SYSTABLESRowFactory.SYSTABLES_INDEX1_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 38 with SQLVarchar

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

the class DataDictionaryImpl method dropAliasDescriptor.

/**
 * Drop a AliasDescriptor from the DataDictionary
 *
 * @param ad	The AliasDescriptor to drop
 * @param tc	The TransactionController
 *
 * @exception StandardException		Thrown on failure
 */
public void dropAliasDescriptor(AliasDescriptor ad, TransactionController tc) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM);
    /* Use aliasNameOrderable and nameSpaceOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    char[] charArray = new char[1];
    charArray[0] = ad.getNameSpace();
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(3);
    keyRow1.setColumn(1, getIDValueAsCHAR(ad.getSchemaUUID()));
    keyRow1.setColumn(2, new SQLVarchar(ad.getDescriptorName()));
    keyRow1.setColumn(3, new SQLChar(new String(charArray)));
    ti.deleteRow(tc, keyRow1, SYSALIASESRowFactory.SYSALIASES_INDEX1_ID);
}
Also used : SQLChar(org.apache.derby.iapi.types.SQLChar) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 39 with SQLVarchar

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

the class DataDictionaryImpl method locateSchemaRow.

/**
 * Get the target schema by searching for a matching row
 * in SYSSCHEMAS by schema name.  Read only scan.
 *
 * @param schemaName	The name of the schema we're interested in.
 *						If schemaId is null, used to qual.
 *
 * @param tc			TransactionController.  If null, one
 *						is gotten off of the language connection context.
 *
 * @return	The row for the schema
 *
 * @exception StandardException		Thrown on error
 */
private SchemaDescriptor locateSchemaRow(String schemaName, TransactionController tc) throws StandardException {
    DataValueDescriptor schemaNameOrderable;
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    /* Use aliasNameOrderable in both start 
		 * and stop position for scan. 
		 */
    schemaNameOrderable = new SQLVarchar(schemaName);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, schemaNameOrderable);
    return getDescriptorViaIndex(SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SchemaDescriptor.class, false, TransactionController.ISOLATION_REPEATABLE_READ, tc);
}
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 40 with SQLVarchar

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

the class DataDictionaryImpl method dropUser.

public void dropUser(String userName, TransactionController tc) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSUSERS_CATALOG_NUM);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow1.setColumn(1, new SQLVarchar(userName));
    ti.deleteRow(tc, keyRow1, SYSUSERSRowFactory.SYSUSERS_INDEX1_ID);
}
Also used : 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