You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2007/07/10 20:30:49 UTC
svn commit: r555028 - in /db/derby/code/trunk/java/engine/org/apache/derby:
catalog/ catalog/types/ iapi/types/ impl/sql/catalog/
Author: djd
Date: Tue Jul 10 11:30:47 2007
New Revision: 555028
URL: http://svn.apache.org/viewvc?view=rev&rev=555028
Log:
DERBY-2775 Add some comments to the main type classes to indicate their roles:
TypeId Information about the type without specific attributes
TypeDescriptor Catalog type descriptor
DataTypeDescriptor Runtime type descriptor
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java
db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java Tue Jul 10 11:30:47 2007
@@ -24,12 +24,9 @@
import org.apache.derby.iapi.types.StringDataValue;
/**
- *
- * An interface for describing types in Derby systems.
- *
- *
- * <p>The values in system catalog DATATYPE columns are of type
- * TypeDescriptor.
+ * TypeDescriptor represents a type in a system catalog, a
+ * persistent type. Examples are columns in tables and parameters
+ * for routines. A TypeDescriptor is immutable.
*/
public interface TypeDescriptor
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java Tue Jul 10 11:30:47 2007
@@ -69,11 +69,16 @@
** getTypeFormatId() method.
**
********************************************************/
+
+ private int formatId;
String SQLTypeName;
- int JDBCTypeId;
- int formatId;
- int wrapperTypeFormatId;
+ /**
+ * JDBC type - derived from the format identifier.
+ */
+ transient int JDBCTypeId;
+
+ private int wrapperTypeFormatId;
/**
* niladic constructor. Needed for Formatable interface to work.
@@ -99,7 +104,7 @@
* @param SQLTypeName The SQL name of the type
*/
- protected BaseTypeIdImpl(String SQLTypeName)
+ BaseTypeIdImpl(String SQLTypeName)
{
this.SQLTypeName = SQLTypeName;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java Tue Jul 10 11:30:47 2007
@@ -34,9 +34,11 @@
the readExternal needs to know the formatId atleast for decimal types
to read the extra information.
*/
- public DecimalTypeIdImpl()
+ public DecimalTypeIdImpl(boolean isNumeric)
{
super(StoredFormatIds.DECIMAL_TYPE_ID_IMPL);
+ if (isNumeric)
+ setNumericType();
}
/**
@@ -71,12 +73,12 @@
public void writeExternal( ObjectOutput out )
throws IOException
{
- out.writeBoolean(JDBCTypeId == Types.NUMERIC);
+ out.writeBoolean(getJDBCTypeId() == Types.NUMERIC);
super.writeExternal(out);
}
- public void setNumericType()
+ private void setNumericType()
{
SQLTypeName = "NUMERIC";
JDBCTypeId = Types.NUMERIC;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java Tue Jul 10 11:30:47 2007
@@ -55,7 +55,7 @@
case StoredFormatIds.XML_TYPE_ID_IMPL:
return new BaseTypeIdImpl(fmtId);
case StoredFormatIds.DECIMAL_TYPE_ID_IMPL:
- return new DecimalTypeIdImpl();
+ return new DecimalTypeIdImpl(false);
default:
return null;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Tue Jul 10 11:30:47 2007
@@ -39,10 +39,7 @@
import org.apache.derby.iapi.sql.conn.ConnectionUtil;
/**
- * This is an implementation of DataTypeDescriptor from the generic language
- * datatype module interface.
- *
- * @version 1.0
+ * DataTypeDescriptor describes a runtime SQL type.
*/
public final class DataTypeDescriptor implements TypeDescriptor, Formatable
@@ -60,12 +57,14 @@
** method.
**
********************************************************/
+
+ public static final DataTypeDescriptor INTEGER = new DataTypeDescriptor(TypeId.INTEGER_ID, true);
/*
** Static creators
*/
/**
- * Get a descriptor that corresponds to a builtin JDBC type.
+ * Get a descriptor that corresponds to a nullable builtin JDBC type.
*
* @param jdbcType The int type of the JDBC type for which to get
* a corresponding SQL DataTypeDescriptor
@@ -1144,7 +1143,7 @@
* Get the simplified type descriptor that is intended to be stored
* in the system tables.
*/
- public TypeDescriptorImpl getCatalogType()
+ public TypeDescriptor getCatalogType()
{
return typeDescriptor;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Tue Jul 10 11:30:47 2007
@@ -48,13 +48,17 @@
import java.sql.Types;
/**
- * The TypeId interface provides methods to get information about datatype ids.
-
+ * TypeId describes the static information about a SQL type
+ * independent of any specific attributes of the type such
+ * as length. So the TypeId for CHARACTER describes the
+ * fundamental information about CHARACTER. A specific
+ * type (e.g. CHARACTER(10)) is described by a DataTypeDescriptor.
<P>
* The equals(Object) method can be used to determine if two typeIds are for the same type,
* which defines type id equality.
- *
+
+ @see DataTypeDescriptor
*/
public final class TypeId implements Formatable
@@ -330,14 +334,13 @@
ret = DECIMAL_ID;
if (ret == null)
ret = DECIMAL_ID = new TypeId(StoredFormatIds.DECIMAL_TYPE_ID,
- new DecimalTypeIdImpl());
+ new DecimalTypeIdImpl(false));
break;
case Types.NUMERIC:
ret = NUMERIC_ID;
if (ret == null) {
- DecimalTypeIdImpl numericTypeIdImpl = new DecimalTypeIdImpl();
- numericTypeIdImpl.setNumericType();
+ DecimalTypeIdImpl numericTypeIdImpl = new DecimalTypeIdImpl(true);
ret = NUMERIC_ID = new TypeId(StoredFormatIds.DECIMAL_TYPE_ID, numericTypeIdImpl);
}
break;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Tue Jul 10 11:30:47 2007
@@ -8740,6 +8740,9 @@
TransactionController tc)
throws StandardException
{
+ TypeDescriptor integerType = DataTypeDescriptor.INTEGER.getCatalogType();
+ TypeDescriptor varchar128Type =
+ DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 128).getCatalogType();
/*
** SYSCS_UTIL routines.
*/
@@ -8760,8 +8763,7 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH)
};
@@ -8786,10 +8788,8 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.SMALLINT)
@@ -8989,8 +8989,7 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128)
+ varchar128Type
};
createSystemProcedureOrFunction(
@@ -9013,10 +9012,8 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128)
+ varchar128Type,
+ varchar128Type
};
createSystemProcedureOrFunction(
@@ -9073,10 +9070,8 @@
TypeDescriptor[] arg_types = {
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 256),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.INTEGER)
+ varchar128Type,
+ integerType
};
createSystemProcedureOrFunction(
@@ -9098,8 +9093,7 @@
TypeDescriptor[] arg_types = {
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 256),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128)
+ varchar128Type
};
createSystemProcedureOrFunction(
@@ -9119,10 +9113,8 @@
String[] arg_names = {"JAR", "UNDEPLOY"};
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.INTEGER)
+ varchar128Type,
+ integerType
};
createSystemProcedureOrFunction(
@@ -9152,18 +9144,15 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 32672),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128)
+ varchar128Type
};
createSystemProcedureOrFunction(
@@ -9200,8 +9189,7 @@
Types.CHAR, 1),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128)
+ varchar128Type
};
createSystemProcedureOrFunction(
@@ -9232,18 +9220,15 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 32672),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.SMALLINT),
};
@@ -9278,10 +9263,8 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 32672),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
@@ -9292,8 +9275,7 @@
Types.CHAR, 1),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.CHAR, 1),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.SMALLINT),
};
@@ -9326,10 +9308,8 @@
// procedure argument types
TypeDescriptor[] arg_types = {
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
- DataTypeDescriptor.getBuiltInDataTypeDescriptor(
- Types.VARCHAR, 128),
+ varchar128Type,
+ varchar128Type,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Types.VARCHAR, 32672),
DataTypeDescriptor.getBuiltInDataTypeDescriptor(
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java?view=diff&rev=555028&r1=555027&r2=555028
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java Tue Jul 10 11:30:47 2007
@@ -21,61 +21,38 @@
package org.apache.derby.impl.sql.catalog;
-import org.apache.derby.iapi.reference.Property;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.store.raw.RawStoreFactory;
+import java.util.Properties;
-import org.apache.derby.iapi.types.DataValueFactory;
-import org.apache.derby.iapi.sql.dictionary.SystemColumn;
import org.apache.derby.catalog.TypeDescriptor;
+import org.apache.derby.catalog.UUID;
import org.apache.derby.catalog.types.BaseTypeIdImpl;
-
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.types.SQLVarchar;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueFactory;
-import org.apache.derby.iapi.types.RowLocation;
-
+import org.apache.derby.catalog.types.DefaultInfoImpl;
+import org.apache.derby.catalog.types.TypeDescriptorImpl;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.Property;
+import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.uuid.UUIDFactory;
import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
+import org.apache.derby.iapi.sql.dictionary.SystemColumn;
import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;
-import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor;
-
-import org.apache.derby.iapi.sql.execute.ExecutionContext;
-import org.apache.derby.iapi.sql.execute.ExecutionFactory;
-import org.apache.derby.iapi.sql.execute.ExecIndexRow;
import org.apache.derby.iapi.sql.execute.ExecRow;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.monitor.Monitor;
-import org.apache.derby.catalog.types.TypeDescriptorImpl;
-import org.apache.derby.catalog.DefaultInfo;
-import org.apache.derby.iapi.services.uuid.UUIDFactory;
-import org.apache.derby.catalog.UUID;
-
+import org.apache.derby.iapi.sql.execute.ExecutionFactory;
+import org.apache.derby.iapi.store.raw.RawStoreFactory;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.DataValueFactory;
+import org.apache.derby.iapi.types.SQLChar;
+import org.apache.derby.iapi.types.SQLInteger;
+import org.apache.derby.iapi.types.SQLLongint;
+import org.apache.derby.iapi.types.SQLVarchar;
+import org.apache.derby.iapi.types.TypeId;
import org.apache.derby.impl.sql.compile.ColumnDefinitionNode;
-import org.apache.derby.catalog.types.DefaultInfoImpl;
-
-import org.apache.derby.iapi.types.*;
-
-import java.io.Serializable;
-
-import java.util.Properties;
-
/**
* Factory for creating a SYSCOLUMNS row.
*
@@ -182,13 +159,12 @@
throws StandardException
{
ExecRow row;
- DataValueDescriptor col;
String colName = null;
String defaultID = null;
String tabID = null;
Integer colID = null;
- TypeDescriptorImpl typeDesc = null;
+ TypeDescriptor typeDesc = null;
Object defaultSerializable = null;
long autoincStart = 0;
long autoincInc = 0;
@@ -354,8 +330,6 @@
String defaultID;
DefaultInfoImpl defaultInfo = null;
ColumnDescriptor colDesc;
- BaseTypeIdImpl typeId;
- TypeId wrapperTypeId;
DataValueDescriptor defaultValue = null;
UUID defaultUUID = null;
UUID uuid = null;
@@ -430,16 +404,13 @@
*/
TypeDescriptorImpl typeDescriptor = (TypeDescriptorImpl) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).
getObject();
- typeId = typeDescriptor.getTypeId();
+ BaseTypeIdImpl typeId = typeDescriptor.getTypeId();
/*
** The BaseTypeIdImpl tells what type of TypeId it is supposed to
** be wrapped in.
*/
- wrapperTypeId =
- (TypeId) Monitor.newInstanceFromIdentifier(typeId.wrapperTypeFormatId());
- /* Wrap the BaseTypeIdImpl in a full type id */
- wrapperTypeId.setNestedTypeId(typeId);
+ TypeId wrapperTypeId = new TypeId(typeId.wrapperTypeFormatId(), typeId);
/* Wrap the TypeDescriptorImpl in a full DataTypeDescriptor */
DataTypeDescriptor dataTypeServices = new DataTypeDescriptor(typeDescriptor,