Search in sources :

Example 66 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class SYSCONSTRAINTSRowFactory method makeRow.

// ///////////////////////////////////////////////////////////////////////////
// 
// METHODS
// 
// ///////////////////////////////////////////////////////////////////////////
/**
 * Make a SYSCONTRAINTS row
 *
 * @return	Row suitable for inserting into SYSCONTRAINTS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    DataValueDescriptor col;
    ExecRow row;
    int constraintIType;
    UUID oid;
    String constraintSType = null;
    String constraintID = null;
    String tableID = null;
    String constraintName = null;
    String schemaID = null;
    boolean deferrable = ConstraintDefinitionNode.DEFERRABLE_DEFAULT;
    boolean initiallyDeferred = ConstraintDefinitionNode.INITIALLY_DEFERRED_DEFAULT;
    boolean enforced = ConstraintDefinitionNode.ENFORCED_DEFAULT;
    int referenceCount = 0;
    if (td != null) {
        ConstraintDescriptor constraint = (ConstraintDescriptor) td;
        /*
			** We only allocate a new UUID if the descriptor doesn't already have one.
			** For descriptors replicated from a Source system, we already have an UUID.
			*/
        oid = constraint.getUUID();
        constraintID = oid.toString();
        oid = constraint.getTableId();
        tableID = oid.toString();
        constraintName = constraint.getConstraintName();
        constraintIType = constraint.getConstraintType();
        switch(constraintIType) {
            case DataDictionary.PRIMARYKEY_CONSTRAINT:
                constraintSType = "P";
                break;
            case DataDictionary.UNIQUE_CONSTRAINT:
                constraintSType = "U";
                break;
            case DataDictionary.CHECK_CONSTRAINT:
                constraintSType = "C";
                break;
            case DataDictionary.FOREIGNKEY_CONSTRAINT:
                constraintSType = "F";
                break;
            default:
                if (SanityManager.DEBUG) {
                    SanityManager.THROWASSERT("invalid constraint type");
                }
        }
        schemaID = constraint.getSchemaDescriptor().getUUID().toString();
        // constraint characteristics
        deferrable = constraint.deferrable();
        initiallyDeferred = constraint.initiallyDeferred();
        enforced = constraint.enforced();
        referenceCount = constraint.getReferenceCount();
    }
    /* Insert info into sysconstraints */
    /* RESOLVE - It would be nice to require less knowledge about sysconstraints
		 * and have this be more table driven.
		 */
    /* Build the row to insert  */
    row = getExecutionFactory().getValueRow(SYSCONSTRAINTS_COLUMN_COUNT);
    /* 1st column is CONSTRAINTID (UUID - char(36)) */
    row.setColumn(SYSCONSTRAINTS_CONSTRAINTID, new SQLChar(constraintID));
    /* 2nd column is TABLEID (UUID - char(36)) */
    row.setColumn(SYSCONSTRAINTS_TABLEID, new SQLChar(tableID));
    /* 3rd column is NAME (varchar(128)) */
    row.setColumn(SYSCONSTRAINTS_CONSTRAINTNAME, new SQLVarchar(constraintName));
    /* 4th column is TYPE (char(1)) */
    row.setColumn(SYSCONSTRAINTS_TYPE, new SQLChar(constraintSType));
    /* 5th column is SCHEMAID (UUID - char(36)) */
    row.setColumn(SYSCONSTRAINTS_SCHEMAID, new SQLChar(schemaID));
    /* 6th column is STATE (char(1)) */
    row.setColumn(SYSCONSTRAINTS_STATE, new SQLChar(encodeCharacteristics(deferrable, initiallyDeferred, enforced)));
    /* 7th column is REFERENCED */
    row.setColumn(SYSCONSTRAINTS_REFERENCECOUNT, new SQLInteger(referenceCount));
    return row;
}
Also used : SubConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubConstraintDescriptor) ConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor) SubCheckConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubCheckConstraintDescriptor) SubKeyConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) SQLInteger(org.apache.derby.iapi.types.SQLInteger)

Example 67 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class SYSCONSTRAINTSRowFactory method getSchemaId.

/**
 * Get the schema ID of the row.
 *
 * @param row	The row from sysconstraints
 *
 * @return UUID	The schema
 *
 * @exception   StandardException thrown on failure
 */
protected UUID getSchemaId(ExecRow row) throws StandardException {
    DataValueDescriptor col;
    String schemaUUIDString;
    /* 5th column is SCHEMAID (UUID - char(36)) */
    col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);
    schemaUUIDString = col.getString();
    return getUUIDFactory().recreateUUID(schemaUUIDString);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 68 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class SYSFILESRowFactory method buildDescriptor.

// /////////////////////////////////////////////////////////////////////////
// 
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
// 
// /////////////////////////////////////////////////////////////////////////
/**
 * Make a descriptor out of a SYSFILES row
 *
 * @param row a row
 * @param parentTupleDescriptor	Null for this kind of descriptor.
 * @param dd dataDictionary
 *
 * @return	a descriptor equivalent to a row
 *
 * @exception   StandardException thrown on failure
 */
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
    if (SanityManager.DEBUG) {
        if (row.nColumns() != SYSFILES_COLUMN_COUNT) {
            SanityManager.THROWASSERT("Wrong number of columns for a SYSFILES row: " + row.nColumns());
        }
    }
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    String id_S;
    UUID id;
    String schemaId_S;
    UUID schemaId;
    String name;
    long generationId;
    DataValueDescriptor col;
    SchemaDescriptor schemaDescriptor;
    FileInfoDescriptor result;
    /* 1st column is ID (UUID - char(36)) */
    col = row.getColumn(ID_COL_NUM);
    id_S = col.getString();
    id = getUUIDFactory().recreateUUID(id_S);
    /* 2nd column is SchemaId */
    col = row.getColumn(SCHEMA_ID_COL_NUM);
    schemaId_S = col.getString();
    schemaId = getUUIDFactory().recreateUUID(schemaId_S);
    schemaDescriptor = dd.getSchemaDescriptor(schemaId, null);
    if (SanityManager.DEBUG) {
        if (schemaDescriptor == null) {
            SanityManager.THROWASSERT("Missing schema for FileInfo: " + id_S);
        }
    }
    /* 3nd column is NAME (varchar(128)) */
    col = row.getColumn(NAME_COL_NUM);
    name = col.getString();
    /* 4th column is generationId (long) */
    col = row.getColumn(GENERATION_ID_COL_NUM);
    generationId = col.getLong();
    result = ddg.newFileInfoDescriptor(id, schemaDescriptor, name, generationId);
    return result;
}
Also used : DataDescriptorGenerator(org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator) SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) FileInfoDescriptor(org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 69 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class SYSKEYSRowFactory method makeRow.

// ///////////////////////////////////////////////////////////////////////////
// 
// METHODS
// 
// ///////////////////////////////////////////////////////////////////////////
/**
 * Make a SYSKEYS row
 *
 * @return	Row suitable for inserting into SYSKEYS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    DataValueDescriptor col;
    ExecRow row;
    UUID oid;
    String constraintID = null;
    String conglomerateID = null;
    if (td != null) {
        KeyConstraintDescriptor constraint = (KeyConstraintDescriptor) td;
        /*
			** We only allocate a new UUID if the descriptor doesn't already have one.
			** For descriptors replicated from a Source system, we already have an UUID.
			*/
        oid = constraint.getUUID();
        constraintID = oid.toString();
        conglomerateID = constraint.getIndexUUIDString();
    }
    /* Insert info into syskeys */
    /* RESOLVE - It would be nice to require less knowledge about syskeys
		 * and have this be more table driven.
		 */
    /* Build the row to insert  */
    row = getExecutionFactory().getValueRow(SYSKEYS_COLUMN_COUNT);
    /* 1st column is CONSTRAINTID (UUID - char(36)) */
    row.setColumn(SYSKEYS_CONSTRAINTID, new SQLChar(constraintID));
    /* 2nd column is CONGLOMERATEID (UUID - char(36)) */
    row.setColumn(SYSKEYS_CONGLOMERATEID, new SQLChar(conglomerateID));
    return row;
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) KeyConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor) SubKeyConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 70 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class SYSPERMSRowFactory method setUUIDOfThePassedDescriptor.

// end of removePermissions
/**
 * @see PermissionsCatalogRowFactory#setUUIDOfThePassedDescriptor
 */
void setUUIDOfThePassedDescriptor(ExecRow row, PermissionsDescriptor perm) throws StandardException {
    DataValueDescriptor existingPermDVD = row.getColumn(SYSPERMS_PERMISSIONID);
    perm.setUUID(getUUIDFactory().recreateUUID(existingPermDVD.getString()));
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Aggregations

DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)328 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)62 RowLocation (org.apache.derby.iapi.types.RowLocation)54 SQLLongint (org.apache.derby.iapi.types.SQLLongint)51 StandardException (org.apache.derby.shared.common.error.StandardException)43 SQLChar (org.apache.derby.iapi.types.SQLChar)42 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)36 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)36 ScanController (org.apache.derby.iapi.store.access.ScanController)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 UUID (org.apache.derby.catalog.UUID)31 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)24 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)16 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)15 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)15 Properties (java.util.Properties)14 UserType (org.apache.derby.iapi.types.UserType)13 Page (org.apache.derby.iapi.store.raw.Page)11