Search in sources :

Example 96 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class SYSCHECKSRowFactory method buildDescriptor.

// /////////////////////////////////////////////////////////////////////////
// 
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
// 
// /////////////////////////////////////////////////////////////////////////
/**
 * Make a ViewDescriptor out of a SYSCHECKS row
 *
 * @param row a SYSCHECKS 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 {
    SubCheckConstraintDescriptor checkDesc = null;
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(row.nColumns() == SYSCHECKS_COLUMN_COUNT, "Wrong number of columns for a SYSCHECKS row");
    }
    DataValueDescriptor col;
    DataDescriptorGenerator ddg;
    ReferencedColumns referencedColumns;
    String constraintText;
    String constraintUUIDString;
    UUID constraintUUID;
    ddg = dd.getDataDescriptorGenerator();
    /* 1st column is CONSTRAINTID (UUID - char(36)) */
    col = row.getColumn(SYSCHECKS_CONSTRAINTID);
    constraintUUIDString = col.getString();
    constraintUUID = getUUIDFactory().recreateUUID(constraintUUIDString);
    /* 2nd column is CHECKDEFINITION */
    col = row.getColumn(SYSCHECKS_CHECKDEFINITION);
    constraintText = col.getString();
    /* 3rd column is REFERENCEDCOLUMNS */
    col = row.getColumn(SYSCHECKS_REFERENCEDCOLUMNS);
    referencedColumns = (ReferencedColumns) col.getObject();
    /* now build and return the descriptor */
    checkDesc = new SubCheckConstraintDescriptor(constraintUUID, constraintText, referencedColumns);
    return checkDesc;
}
Also used : DataDescriptorGenerator(org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator) ReferencedColumns(org.apache.derby.catalog.ReferencedColumns) SubCheckConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubCheckConstraintDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 97 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class SYSCOLPERMSRowFactory method makeRow.

public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    UUID oid;
    String colPermID = null;
    DataValueDescriptor grantee = null;
    DataValueDescriptor grantor = null;
    String tableID = null;
    String type = null;
    FormatableBitSet columns = null;
    if (td == null) {
        grantee = getNullAuthorizationID();
        grantor = getNullAuthorizationID();
    } else {
        ColPermsDescriptor cpd = (ColPermsDescriptor) td;
        oid = cpd.getUUID();
        if (oid == null) {
            oid = getUUIDFactory().createUUID();
            cpd.setUUID(oid);
        }
        colPermID = oid.toString();
        grantee = getAuthorizationID(cpd.getGrantee());
        grantor = getAuthorizationID(cpd.getGrantor());
        tableID = cpd.getTableUUID().toString();
        type = cpd.getType();
        columns = cpd.getColumns();
    }
    ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
    row.setColumn(COLPERMSID_COL_NUM, new SQLChar(colPermID));
    row.setColumn(GRANTEE_COL_NUM, grantee);
    row.setColumn(GRANTOR_COL_NUM, grantor);
    row.setColumn(TABLEID_COL_NUM, new SQLChar(tableID));
    row.setColumn(TYPE_COL_NUM, new SQLChar(type));
    row.setColumn(COLUMNS_COL_NUM, new UserType((Object) columns));
    return row;
}
Also used : ColPermsDescriptor(org.apache.derby.iapi.sql.dictionary.ColPermsDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) UserType(org.apache.derby.iapi.types.UserType)

Example 98 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class SYSCOLPERMSRowFactory 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 SYSCOLPERMSRowFactory.buildDescriptor");
    String colPermsUUIDString = row.getColumn(COLPERMSID_COL_NUM).getString();
    UUID colPermsUUID = getUUIDFactory().recreateUUID(colPermsUUIDString);
    String tableUUIDString = row.getColumn(TABLEID_COL_NUM).getString();
    UUID tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
    String type = row.getColumn(TYPE_COL_NUM).getString();
    FormatableBitSet columns = (FormatableBitSet) row.getColumn(COLUMNS_COL_NUM).getObject();
    if (SanityManager.DEBUG)
        SanityManager.ASSERT("s".equals(type) || "S".equals(type) || "u".equals(type) || "U".equals(type) || "r".equals(type) || "R".equals(type), "Invalid type passed to SYSCOLPERMSRowFactory.buildDescriptor");
    ColPermsDescriptor colPermsDesc = new ColPermsDescriptor(dataDictionary, getAuthorizationID(row, GRANTEE_COL_NUM), getAuthorizationID(row, GRANTOR_COL_NUM), tableUUID, type, columns);
    colPermsDesc.setUUID(colPermsUUID);
    return colPermsDesc;
}
Also used : ColPermsDescriptor(org.apache.derby.iapi.sql.dictionary.ColPermsDescriptor) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) UUID(org.apache.derby.catalog.UUID)

Example 99 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class SYSCOLUMNSRowFactory method buildDescriptor.

// /////////////////////////////////////////////////////////////////////////
// 
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
// 
// /////////////////////////////////////////////////////////////////////////
/**
 * Make a ColumnDescriptor out of a SYSCOLUMNS row
 *
 * @param row 					a SYSCOLUMNS row
 * @param parentTupleDescriptor	The UniqueTupleDescriptor for the object that is tied
 *								to this column
 * @param dd 					dataDictionary
 *
 * @return	a column descriptor equivalent to a SYSCOLUMNS row
 *
 * @exception   StandardException thrown on failure
 */
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
    if (SanityManager.DEBUG) {
        int expectedCols = dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_14, null) ? SYSCOLUMNS_COLUMN_COUNT : (SYSCOLUMNS_COLUMN_COUNT - 1);
        SanityManager.ASSERT(row.nColumns() == expectedCols, "Wrong number of columns for a SYSCOLUMNS row");
    }
    int columnNumber;
    String columnName;
    String defaultID;
    DefaultInfoImpl defaultInfo = null;
    ColumnDescriptor colDesc;
    DataValueDescriptor defaultValue = null;
    UUID defaultUUID = null;
    UUID uuid = null;
    UUIDFactory uuidFactory = getUUIDFactory();
    long autoincStart, autoincInc, autoincValue;
    boolean autoincCycle = false;
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    /*
		** We're going to be getting the UUID for this sucka
		** so make sure it is a UniqueTupleDescriptor.
		*/
    if (parentTupleDescriptor != null) {
        if (SanityManager.DEBUG) {
            if (!(parentTupleDescriptor instanceof UniqueTupleDescriptor)) {
                SanityManager.THROWASSERT(parentTupleDescriptor.getClass().getName() + " not instanceof UniqueTupleDescriptor");
            }
        }
        uuid = ((UniqueTupleDescriptor) parentTupleDescriptor).getUUID();
    } else {
        /* 1st column is REFERENCEID (char(36)) */
        uuid = uuidFactory.recreateUUID(row.getColumn(SYSCOLUMNS_REFERENCEID).getString());
    }
    /* NOTE: We get columns 5 and 6 next in order to work around 
		 * a 1.3.0 HotSpot bug.  (#4361550)
		 */
    // 5th column is COLUMNDEFAULT (serialiazable)
    Object object = row.getColumn(SYSCOLUMNS_COLUMNDEFAULT).getObject();
    if (object instanceof DataValueDescriptor) {
        defaultValue = (DataValueDescriptor) object;
    } else if (object instanceof DefaultInfoImpl) {
        defaultInfo = (DefaultInfoImpl) object;
        defaultValue = defaultInfo.getDefaultValue();
    }
    /* 6th column is DEFAULTID (char(36)) */
    defaultID = row.getColumn(SYSCOLUMNS_COLUMNDEFAULTID).getString();
    if (defaultID != null) {
        defaultUUID = uuidFactory.recreateUUID(defaultID);
    }
    /* 2nd column is COLUMNNAME (varchar(128)) */
    columnName = row.getColumn(SYSCOLUMNS_COLUMNNAME).getString();
    /* 3rd column is COLUMNNUMBER (int) */
    columnNumber = row.getColumn(SYSCOLUMNS_COLUMNNUMBER).getInt();
    /* 4th column is COLUMNDATATYPE */
    /*
		** What is stored in the column is a TypeDescriptorImpl, which
		** points to a BaseTypeIdImpl.  These are simple types that are
		** intended to be movable to the client, so they don't have
		** the entire implementation.  We need to wrap them in DataTypeServices
		** and TypeId objects that contain the full implementations for
		** language processing.
		*/
    TypeDescriptor catalogType = (TypeDescriptor) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).getObject();
    DataTypeDescriptor dataTypeServices = DataTypeDescriptor.getType(catalogType);
    /* 7th column is AUTOINCREMENTVALUE (long) */
    autoincValue = row.getColumn(SYSCOLUMNS_AUTOINCREMENTVALUE).getLong();
    /* 8th column is AUTOINCREMENTSTART (long) */
    autoincStart = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART).getLong();
    /* 9th column is AUTOINCREMENTINC (long) */
    autoincInc = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC).getLong();
    if (row.nColumns() >= 10) {
        DataValueDescriptor col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE);
        autoincCycle = col.getBoolean();
    }
    DataValueDescriptor col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART);
    autoincStart = col.getLong();
    col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC);
    autoincInc = col.getLong();
    // Hard upgraded tables <=10.13 come with a false autoincCyle before they are first
    // explicitly set with cycle or no cycle command.
    colDesc = new ColumnDescriptor(columnName, columnNumber, dataTypeServices, defaultValue, defaultInfo, uuid, defaultUUID, autoincStart, autoincInc, autoincValue, autoincCycle);
    return colDesc;
}
Also used : UUIDFactory(org.apache.derby.iapi.services.uuid.UUIDFactory) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) DefaultInfoImpl(org.apache.derby.catalog.types.DefaultInfoImpl) DataDescriptorGenerator(org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator) TypeDescriptor(org.apache.derby.catalog.TypeDescriptor) UUID(org.apache.derby.catalog.UUID) UniqueTupleDescriptor(org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor)

Example 100 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class SYSCONGLOMERATESRowFactory method buildDescriptor.

// /////////////////////////////////////////////////////////////////////////
// 
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
// 
// /////////////////////////////////////////////////////////////////////////
/**
 * @param row a SYSCOLUMNS row
 * @param parentTupleDescriptor	Null for this kind of descriptor.
 * @param dd dataDictionary
 *
 * @return	a conglomerate descriptor equivalent to a SYSCONGOMERATES row
 *
 * @exception   StandardException thrown on failure
 */
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
    if (SanityManager.DEBUG)
        SanityManager.ASSERT(row.nColumns() == SYSCONGLOMERATES_COLUMN_COUNT, "Wrong number of columns for a SYSCONGLOMERATES row");
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    long conglomerateNumber;
    String name;
    boolean isConstraint;
    boolean isIndex;
    IndexRowGenerator indexRowGenerator;
    DataValueDescriptor col;
    ConglomerateDescriptor conglomerateDesc;
    String conglomUUIDString;
    UUID conglomUUID;
    String schemaUUIDString;
    UUID schemaUUID;
    String tableUUIDString;
    UUID tableUUID;
    /* 1st column is SCHEMAID (UUID - char(36)) */
    col = row.getColumn(1);
    schemaUUIDString = col.getString();
    schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
    /* 2nd column is TABLEID (UUID - char(36)) */
    col = row.getColumn(2);
    tableUUIDString = col.getString();
    tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
    /* 3nd column is CONGLOMERATENUMBER (long) */
    col = row.getColumn(3);
    conglomerateNumber = col.getLong();
    /* 4rd column is CONGLOMERATENAME (varchar(128)) */
    col = row.getColumn(4);
    name = col.getString();
    /* 5th column is ISINDEX (boolean) */
    col = row.getColumn(5);
    isIndex = col.getBoolean();
    /* 6th column is DESCRIPTOR */
    col = row.getColumn(6);
    indexRowGenerator = new IndexRowGenerator((IndexDescriptor) col.getObject());
    /* 7th column is ISCONSTRAINT (boolean) */
    col = row.getColumn(7);
    isConstraint = col.getBoolean();
    /* 8th column is CONGLOMERATEID (UUID - char(36)) */
    col = row.getColumn(8);
    conglomUUIDString = col.getString();
    conglomUUID = getUUIDFactory().recreateUUID(conglomUUIDString);
    /* now build and return the descriptor */
    conglomerateDesc = ddg.newConglomerateDescriptor(conglomerateNumber, name, isIndex, indexRowGenerator, isConstraint, conglomUUID, tableUUID, schemaUUID);
    return conglomerateDesc;
}
Also used : DataDescriptorGenerator(org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator) IndexRowGenerator(org.apache.derby.iapi.sql.dictionary.IndexRowGenerator) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) IndexDescriptor(org.apache.derby.catalog.IndexDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)

Aggregations

UUID (org.apache.derby.catalog.UUID)101 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)31 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)23 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)22 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)21 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)19 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)15 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)15 SQLChar (org.apache.derby.iapi.types.SQLChar)15 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)14 TransactionController (org.apache.derby.iapi.store.access.TransactionController)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)12 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)12 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)11 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 ArrayList (java.util.ArrayList)9 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)9 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)8