use of org.apache.derby.catalog.UUID in project derby by apache.
the class DataDictionaryImpl method getViewDescriptorScan.
/**
* Get the information for the view from sys.sysviews.
*
* @param tdi The TableDescriptor for the view.
*
* @return ViewDescriptor The ViewDescriptor for the view.
*
* @exception StandardException Thrown on error
*/
private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi) throws StandardException {
ViewDescriptor vd;
DataValueDescriptor viewIdOrderable;
TabInfoImpl ti = getNonCoreTI(SYSVIEWS_CATALOG_NUM);
UUID viewID = tdi.getUUID();
/* Use viewIdOrderable in both start
* and stop position for scan.
*/
viewIdOrderable = getIDValueAsCHAR(viewID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, viewIdOrderable);
vd = getDescriptorViaIndex(SYSVIEWSRowFactory.SYSVIEWS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ViewDescriptor.class, false);
if (vd != null) {
vd.setViewName(tdi.getName());
}
return vd;
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class SYSSTATISTICSRowFactory method buildDescriptor.
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentDesc, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(row.nColumns() == SYSSTATISTICS_COLUMN_COUNT, "Wrong number of columns for a SYSSTATISTICS row");
}
DataValueDescriptor col;
String scratch;
UUIDFactory uuidFactory = getUUIDFactory();
UUID statUUID, statReferenceUUID, statTableUUID;
String statName;
/* 1st column is UUID */
col = row.getColumn(SYSSTATISTICS_ID);
scratch = col.getString();
statUUID = uuidFactory.recreateUUID(scratch);
/* 2nd column is reference UUID */
col = row.getColumn(SYSSTATISTICS_REFERENCEID);
scratch = col.getString();
statReferenceUUID = uuidFactory.recreateUUID(scratch);
/* 3rd column is table UUID */
col = row.getColumn(SYSSTATISTICS_TABLEID);
scratch = col.getString();
statTableUUID = uuidFactory.recreateUUID(scratch);
/* 4th column is timestamp */
col = row.getColumn(SYSSTATISTICS_TIMESTAMP);
Timestamp updateTime = (Timestamp) col.getObject();
/* 5th column is stat type -- string */
col = row.getColumn(SYSSTATISTICS_TYPE);
String statType = col.getString();
/* 6th column is stat valid -- boolean */
col = row.getColumn(SYSSTATISTICS_VALID);
boolean valid = col.getBoolean();
/* 7th column is column count */
col = row.getColumn(SYSSTATISTICS_COLCOUNT);
int columnCount = col.getInt();
/* 8th column is statistics itself */
col = row.getColumn(SYSSTATISTICS_STAT);
Statistics stat = (Statistics) col.getObject();
return new StatisticsDescriptor(dd, statUUID, statReferenceUUID, // statName, colMap,
statTableUUID, statType, stat, columnCount);
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class SYSTABLEPERMSRowFactory method buildDescriptor.
// end of makeRow
/**
* builds a tuple descriptor from a row
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTuple, DataDictionary dataDictionary) throws StandardException {
if (SanityManager.DEBUG)
SanityManager.ASSERT(row.nColumns() == COLUMN_COUNT, "Wrong size row passed to SYSTABLEPERMSRowFactory.buildDescriptor");
String tablePermsUUIDString = row.getColumn(TABLEPERMSID_COL_NUM).getString();
UUID tablePermsUUID = getUUIDFactory().recreateUUID(tablePermsUUIDString);
String tableUUIDString = row.getColumn(TABLEID_COL_NUM).getString();
UUID tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
String selectPriv = row.getColumn(SELECTPRIV_COL_NUM).getString();
String deletePriv = row.getColumn(DELETEPRIV_COL_NUM).getString();
String insertPriv = row.getColumn(INSERTPRIV_COL_NUM).getString();
String updatePriv = row.getColumn(UPDATEPRIV_COL_NUM).getString();
String referencesPriv = row.getColumn(REFERENCESPRIV_COL_NUM).getString();
String triggerPriv = row.getColumn(TRIGGERPRIV_COL_NUM).getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT("y".equals(selectPriv) || "Y".equals(selectPriv) || "N".equals(selectPriv), "Invalid SYSTABLEPERMS.selectPriv column value: " + selectPriv);
SanityManager.ASSERT("y".equals(deletePriv) || "Y".equals(deletePriv) || "N".equals(deletePriv), "Invalid SYSTABLEPERMS.deletePriv column value: " + deletePriv);
SanityManager.ASSERT("y".equals(insertPriv) || "Y".equals(insertPriv) || "N".equals(insertPriv), "Invalid SYSTABLEPERMS.insertPriv column value: " + insertPriv);
SanityManager.ASSERT("y".equals(updatePriv) || "Y".equals(updatePriv) || "N".equals(updatePriv), "Invalid SYSTABLEPERMS.updatePriv column value: " + updatePriv);
SanityManager.ASSERT("y".equals(referencesPriv) || "Y".equals(referencesPriv) || "N".equals(referencesPriv), "Invalid SYSTABLEPERMS.referencesPriv column value: " + referencesPriv);
SanityManager.ASSERT("y".equals(triggerPriv) || "Y".equals(triggerPriv) || "N".equals(triggerPriv), "Invalid SYSTABLEPERMS.triggerPriv column value: " + triggerPriv);
}
TablePermsDescriptor tabPermsDesc = new TablePermsDescriptor(dataDictionary, getAuthorizationID(row, GRANTEE_COL_NUM), getAuthorizationID(row, GRANTOR_COL_NUM), tableUUID, selectPriv, deletePriv, insertPriv, updatePriv, referencesPriv, triggerPriv);
tabPermsDesc.setUUID(tablePermsUUID);
return tabPermsDesc;
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class SYSTABLEPERMSRowFactory method makeRow.
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
UUID oid;
DataValueDescriptor grantee = null;
DataValueDescriptor grantor = null;
String tablePermID = null;
String tableID = null;
String selectPriv = null;
String deletePriv = null;
String insertPriv = null;
String updatePriv = null;
String referencesPriv = null;
String triggerPriv = null;
if (td == null) {
grantee = getNullAuthorizationID();
grantor = getNullAuthorizationID();
} else {
TablePermsDescriptor tpd = (TablePermsDescriptor) td;
oid = tpd.getUUID();
if (oid == null) {
oid = getUUIDFactory().createUUID();
tpd.setUUID(oid);
}
tablePermID = oid.toString();
grantee = getAuthorizationID(tpd.getGrantee());
grantor = getAuthorizationID(tpd.getGrantor());
tableID = tpd.getTableUUID().toString();
selectPriv = tpd.getSelectPriv();
deletePriv = tpd.getDeletePriv();
insertPriv = tpd.getInsertPriv();
updatePriv = tpd.getUpdatePriv();
referencesPriv = tpd.getReferencesPriv();
triggerPriv = tpd.getTriggerPriv();
}
ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
row.setColumn(TABLEPERMSID_COL_NUM, new SQLChar(tablePermID));
row.setColumn(GRANTEE_COL_NUM, grantee);
row.setColumn(GRANTOR_COL_NUM, grantor);
row.setColumn(TABLEID_COL_NUM, new SQLChar(tableID));
row.setColumn(SELECTPRIV_COL_NUM, new SQLChar(selectPriv));
row.setColumn(DELETEPRIV_COL_NUM, new SQLChar(deletePriv));
row.setColumn(INSERTPRIV_COL_NUM, new SQLChar(insertPriv));
row.setColumn(UPDATEPRIV_COL_NUM, new SQLChar(updatePriv));
row.setColumn(REFERENCESPRIV_COL_NUM, new SQLChar(referencesPriv));
row.setColumn(TRIGGERPRIV_COL_NUM, new SQLChar(triggerPriv));
return row;
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class SYSTABLESRowFactory method buildDescriptorBody.
public TupleDescriptor buildDescriptorBody(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd, int isolationLevel) throws StandardException {
if (SanityManager.DEBUG)
SanityManager.ASSERT(row.nColumns() == SYSTABLES_COLUMN_COUNT, "Wrong number of columns for a SYSTABLES row");
DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
String tableUUIDString;
String schemaUUIDString;
int tableTypeEnum;
String lockGranularity;
String tableName, tableType;
DataValueDescriptor col;
UUID tableUUID;
UUID schemaUUID;
SchemaDescriptor schema;
TableDescriptor tabDesc;
/* 1st column is TABLEID (UUID - char(36)) */
col = row.getColumn(SYSTABLES_TABLEID);
tableUUIDString = col.getString();
tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
/* 2nd column is TABLENAME (varchar(128)) */
col = row.getColumn(SYSTABLES_TABLENAME);
tableName = col.getString();
/* 3rd column is TABLETYPE (char(1)) */
col = row.getColumn(SYSTABLES_TABLETYPE);
tableType = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(tableType.length() == 1, "Fourth column type incorrect");
}
switch(tableType.charAt(0)) {
case 'T':
tableTypeEnum = TableDescriptor.BASE_TABLE_TYPE;
break;
case 'S':
tableTypeEnum = TableDescriptor.SYSTEM_TABLE_TYPE;
break;
case 'V':
tableTypeEnum = TableDescriptor.VIEW_TYPE;
break;
case 'A':
tableTypeEnum = TableDescriptor.SYNONYM_TYPE;
break;
default:
if (SanityManager.DEBUG)
SanityManager.THROWASSERT("Fourth column value invalid");
tableTypeEnum = -1;
}
/* 4th column is SCHEMAID (UUID - char(36)) */
col = row.getColumn(SYSTABLES_SCHEMAID);
schemaUUIDString = col.getString();
schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
schema = dd.getSchemaDescriptor(schemaUUID, isolationLevel, null);
/* 5th column is LOCKGRANULARITY (char(1)) */
col = row.getColumn(SYSTABLES_LOCKGRANULARITY);
lockGranularity = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(lockGranularity.length() == 1, "Fifth column type incorrect");
}
// RESOLVE - Deal with lock granularity
tabDesc = ddg.newTableDescriptor(tableName, schema, tableTypeEnum, lockGranularity.charAt(0));
tabDesc.setUUID(tableUUID);
return tabDesc;
}
Aggregations