Search in sources :

Example 31 with DataDescriptorGenerator

use of org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator 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 32 with DataDescriptorGenerator

use of org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator 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 33 with DataDescriptorGenerator

use of org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator 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

DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)33 UUID (org.apache.derby.catalog.UUID)23 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)15 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)14 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)13 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)13 TransactionController (org.apache.derby.iapi.store.access.TransactionController)12 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)7 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)5 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)5 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)5 Timestamp (java.sql.Timestamp)4 Iterator (java.util.Iterator)4 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)4 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)4 Provider (org.apache.derby.iapi.sql.depend.Provider)3 SubKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor)3 Properties (java.util.Properties)2 ReferencedColumns (org.apache.derby.catalog.ReferencedColumns)2 TypeDescriptor (org.apache.derby.catalog.TypeDescriptor)2