use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor in project derby by apache.
the class DropAliasNode method bindStatement.
/**
* Bind this DropMethodAliasNode.
*
* @exception StandardException Thrown on error
*/
@Override
public void bindStatement() throws StandardException {
DataDictionary dataDictionary = getDataDictionary();
String aliasName = getRelativeName();
AliasDescriptor ad = null;
SchemaDescriptor sd = getSchemaDescriptor();
if (sd.getUUID() != null) {
ad = dataDictionary.getAliasDescriptor(sd.getUUID().toString(), aliasName, nameSpace);
}
if (ad == null) {
throw StandardException.newException(SQLState.LANG_OBJECT_DOES_NOT_EXIST, statementToString(), aliasName);
}
// User cannot drop a system alias
if (ad.getSystemAlias()) {
throw StandardException.newException(SQLState.LANG_CANNOT_DROP_SYSTEM_ALIASES, aliasName);
}
// Statement is dependent on the AliasDescriptor
getCompilerContext().createDependency(ad);
}
use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor in project derby by apache.
the class DataDictionaryImpl method grantPublicAccessToSystemRoutine.
/**
* Grant PUBLIC access to a system routine. This method should be used only
* for granting access to a system routine (other than routines in SYSFUN
* schema). It expects the routine to be present in SYSALIASES catalog.
*
* @param schemaID Schema ID
* @param routineName Routine Name
* @param nameSpace Indicates whether the routine is a function/procedure.
* @param tc TransactionController to use
* @param authorizationID authorization ID of the permission grantor
* @throws StandardException Standard exception policy.
*/
private void grantPublicAccessToSystemRoutine(String schemaID, String routineName, char nameSpace, TransactionController tc, String authorizationID) throws StandardException {
// For system routines, a valid alias descriptor will be returned.
AliasDescriptor ad = getAliasDescriptor(schemaID, routineName, nameSpace);
//
if (ad == null) {
return;
}
UUID routineUUID = ad.getUUID();
createRoutinePermPublicDescriptor(routineUUID, tc, authorizationID);
}
use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor 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.sql.dictionary.AliasDescriptor 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);
}
use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor in project derby by apache.
the class SYSALIASESRowFactory method buildDescriptor.
// /////////////////////////////////////////////////////////////////////////
//
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
//
// /////////////////////////////////////////////////////////////////////////
/**
* Make a AliasDescriptor out of a SYSALIASES row
*
* @param row a SYSALIASES row
* @param parentTupleDescriptor Null for this kind of descriptor.
* @param dd dataDictionary
*
* @exception StandardException thrown on failure
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(row.nColumns() == SYSALIASES_COLUMN_COUNT, "Wrong number of columns for a SYSALIASES row");
}
char cAliasType;
char cNameSpace;
DataValueDescriptor col;
String aliasID;
UUID aliasUUID;
String aliasName;
String javaClassName;
String sAliasType;
String sNameSpace;
String typeStr;
boolean systemAlias = false;
AliasInfo aliasInfo = null;
/* 1st column is ALIASID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_ALIASID);
aliasID = col.getString();
aliasUUID = getUUIDFactory().recreateUUID(aliasID);
/* 2nd column is ALIAS (varchar(128)) */
col = row.getColumn(SYSALIASES_ALIAS);
aliasName = col.getString();
/* 3rd column is SCHEMAID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_SCHEMAID);
UUID schemaUUID = col.isNull() ? null : getUUIDFactory().recreateUUID(col.getString());
/* 4th column is JAVACLASSNAME (longvarchar) */
col = row.getColumn(SYSALIASES_JAVACLASSNAME);
javaClassName = col.getString();
/* 5th column is ALIASTYPE (char(1)) */
col = row.getColumn(SYSALIASES_ALIASTYPE);
sAliasType = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sAliasType.length() == 1, "Fifth column (aliastype) type incorrect");
switch(sAliasType.charAt(0)) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sAliasType + "' for alias");
}
}
cAliasType = sAliasType.charAt(0);
/* 6th column is NAMESPACE (char(1)) */
col = row.getColumn(SYSALIASES_NAMESPACE);
sNameSpace = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sNameSpace.length() == 1, "Sixth column (namespace) type incorrect");
switch(sNameSpace.charAt(0)) {
case AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sNameSpace + "' for alias");
}
}
cNameSpace = sNameSpace.charAt(0);
/* 7th column is SYSTEMALIAS (boolean) */
col = row.getColumn(SYSALIASES_SYSTEMALIAS);
systemAlias = col.getBoolean();
/* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */
col = row.getColumn(SYSALIASES_ALIASINFO);
aliasInfo = (AliasInfo) col.getObject();
/* 9th column is specific name */
col = row.getColumn(SYSALIASES_SPECIFIC_NAME);
String specificName = col.getString();
/* now build and return the descriptor */
return new AliasDescriptor(dd, aliasUUID, aliasName, schemaUUID, javaClassName, cAliasType, cNameSpace, systemAlias, aliasInfo, specificName);
}
Aggregations