use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class DataDictionaryImpl method getAliasDescriptor.
/**
* Get a AliasDescriptor by alias name and name space.
* NOTE: caller responsible for handling no match.
*
* @param schemaId schema identifier
* @param aliasName The alias name.
* @param nameSpace The alias type.
*
* @return AliasDescriptor AliasDescriptor for the alias name and name space
*
* @exception StandardException Thrown on failure
*/
public AliasDescriptor getAliasDescriptor(String schemaId, String aliasName, char nameSpace) throws StandardException {
DataValueDescriptor aliasNameOrderable;
DataValueDescriptor nameSpaceOrderable;
TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM);
/* Use aliasNameOrderable and aliasTypeOrderable in both start
* and stop position for scan.
*/
aliasNameOrderable = new SQLVarchar(aliasName);
char[] charArray = new char[1];
charArray[0] = nameSpace;
nameSpaceOrderable = new SQLChar(new String(charArray));
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(3);
keyRow.setColumn(1, new SQLChar(schemaId));
keyRow.setColumn(2, aliasNameOrderable);
keyRow.setColumn(3, nameSpaceOrderable);
return getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, false);
}
use of org.apache.derby.iapi.types.SQLChar 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);
}
use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class DataDictionaryImpl method upgradeCLOBGETSUBSTRING_10_6.
/**
* 10.6 upgrade logic to update the return type of SYSIBM.CLOBGETSUBSTRING. The length of the
* return type was changed in 10.5 but old versions of the metadata were not
* upgraded at that time. See DERBY-4214.
*/
void upgradeCLOBGETSUBSTRING_10_6(TransactionController tc) throws StandardException {
TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM);
ExecIndexRow keyRow = exFactory.getIndexableRow(3);
DataValueDescriptor aliasNameOrderable = new SQLVarchar("CLOBGETSUBSTRING");
DataValueDescriptor nameSpaceOrderable = new SQLChar(new String(new char[] { AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR }));
keyRow.setColumn(1, new SQLChar(SchemaDescriptor.SYSIBM_SCHEMA_UUID));
keyRow.setColumn(2, aliasNameOrderable);
keyRow.setColumn(3, nameSpaceOrderable);
AliasDescriptor oldAD = getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, true, TransactionController.ISOLATION_REPEATABLE_READ, tc);
RoutineAliasInfo oldRai = (RoutineAliasInfo) oldAD.getAliasInfo();
TypeDescriptor newReturnType = DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.MAX_CLOB_RETURN_LEN);
RoutineAliasInfo newRai = new RoutineAliasInfo(oldRai.getMethodName(), oldRai.getParameterCount(), oldRai.getParameterNames(), oldRai.getParameterTypes(), oldRai.getParameterModes(), oldRai.getMaxDynamicResultSets(), oldRai.getParameterStyle(), oldRai.getSQLAllowed(), oldRai.isDeterministic(), oldRai.hasVarargs(), oldRai.hasDefinersRights(), oldRai.calledOnNullInput(), newReturnType);
AliasDescriptor newAD = new AliasDescriptor(this, oldAD.getUUID(), oldAD.getObjectName(), oldAD.getSchemaUUID(), oldAD.getJavaClassName(), oldAD.getAliasType(), oldAD.getNameSpace(), oldAD.getSystemAlias(), newRai, oldAD.getSpecificName());
ExecRow newRow = ti.getCatalogRowFactory().makeRow(newAD, null);
ti.updateRow(keyRow, newRow, SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, new boolean[] { false, false, false }, (int[]) null, tc);
}
use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class DataDictionaryImpl method getProvidersDescriptorList.
/**
* Gets a list of the dependency descriptors for the given provider's id.
*
* @param providerID The ID of the provider we're interested in
*
* @return List Returns a list of DependencyDescriptors.
* Returns an empty List if no stored dependencies for the
* provider's ID.
*
* @exception StandardException Thrown on failure
*/
public List<DependencyDescriptor> getProvidersDescriptorList(String providerID) throws StandardException {
List<DependencyDescriptor> ddlList = newSList();
DataValueDescriptor providerIDOrderable;
TabInfoImpl ti = getNonCoreTI(SYSDEPENDS_CATALOG_NUM);
/* Use providerIDOrderable in both start and stop positions for scan */
providerIDOrderable = new SQLChar(providerID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, providerIDOrderable);
getDescriptorViaIndex(SYSDEPENDSRowFactory.SYSDEPENDS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, ddlList, DependencyDescriptor.class, false);
return ddlList;
}
use of org.apache.derby.iapi.types.SQLChar 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);
}
Aggregations