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 2005/02/16 23:55:15 UTC
svn commit: r154096 -
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute
Author: djd
Date: Wed Feb 16 14:55:11 2005
New Revision: 154096
URL: http://svn.apache.org/viewcvs?view=rev&rev=154096
Log:
New all DECIMAL DataValueDescriptor instances indirectly to
handle different implementations for JSR 169 and J2SE.
Modified:
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java?view=diff&r1=154095&r2=154096
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java Wed Feb 16 14:55:11 2005
@@ -251,7 +251,7 @@
/* 197 */ "org.apache.derby.iapi.types.DTSClassInfo", //InstanceGetter
/* 198 */ "org.apache.derby.catalog.types.TypesImplInstanceGetter",
/* 199 */ "org.apache.derby.iapi.types.DTSClassInfo", //InstanceGetter,
- /* 200 */ "org.apache.derby.iapi.types.DTSClassInfo", //InstanceGetter,
+ /* 200 */ /*DECIMAL*/ null, // set by DataValueFactoryImpl at boot time.
/* 201 */ null,
/* 202 */ "org.apache.derby.iapi.types.UserType",
/* 203 */ "org.apache.derby.impl.sql.execute.rts.RealHashScanStatistics",
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java?view=diff&r1=154095&r2=154096
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java Wed Feb 16 14:55:11 2005
@@ -26,6 +26,10 @@
public class DTSClassInfo extends FormatableInstanceGetter {
public Object getNewInstance() {
+
+
+ // Does not handle StoredFormatIds.SQL_DECIMAL_ID as
+ // different implementations are required for different VMs.
switch (fmtId) {
/* Wrappers */
@@ -33,7 +37,6 @@
case StoredFormatIds.SQL_BOOLEAN_ID: return new SQLBoolean();
case StoredFormatIds.SQL_CHAR_ID: return new SQLChar();
case StoredFormatIds.SQL_DATE_ID: return new SQLDate();
- case StoredFormatIds.SQL_DECIMAL_ID: return new SQLDecimal();
case StoredFormatIds.SQL_DOUBLE_ID: return new SQLDouble();
case StoredFormatIds.SQL_INTEGER_ID: return new SQLInteger();
case StoredFormatIds.SQL_LONGINT_ID: return new SQLLongint();
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?view=diff&r1=154095&r2=154096
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Wed Feb 16 14:55:11 2005
@@ -38,10 +38,14 @@
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.services.i18n.LocaleFinder;
+import org.apache.derby.iapi.services.io.RegisteredFormatIds;
+import org.apache.derby.iapi.services.io.StoredFormatIds;
+import org.apache.derby.iapi.services.monitor.ModuleControl;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.Properties;
import org.apache.derby.iapi.db.DatabaseContext;
@@ -54,14 +58,37 @@
*
* @see DataValueFactory
*/
-abstract class DataValueFactoryImpl implements DataValueFactory
+abstract class DataValueFactoryImpl implements DataValueFactory, ModuleControl
{
LocaleFinder localeFinder;
DataValueFactoryImpl()
{
}
-
+
+ /*
+ ** ModuleControl methods.
+ */
+
+ /* (non-Javadoc)
+ * @see org.apache.derby.iapi.services.monitor.ModuleControl#boot(boolean, java.util.Properties)
+ */
+ public void boot(boolean create, Properties properties) throws StandardException {
+
+ DataValueDescriptor decimalImplementation = getNullDecimal(null);
+
+ TypeId.decimalImplementation = decimalImplementation;
+ RegisteredFormatIds.TwoByte[StoredFormatIds.SQL_DECIMAL_ID]
+ = decimalImplementation.getClass().getName();
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.derby.iapi.services.monitor.ModuleControl#stop()
+ */
+ public void stop() {
+ }
+
/**
* @see DataValueFactory#getDataValue
*
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?view=diff&r1=154095&r2=154096
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Wed Feb 16 14:55:11 2005
@@ -22,7 +22,7 @@
import org.apache.derby.iapi.services.io.Formatable;
import org.apache.derby.iapi.services.io.StoredFormatIds;
-
+import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.services.loader.ClassFactory;
import org.apache.derby.iapi.error.StandardException;
@@ -227,7 +227,11 @@
private static TypeId CLOB_ID;
private static TypeId NCLOB_ID;
-
+ /**
+ * Implementation of DECIMAL datatype for generating holders through getNull.
+ * Set by the booted DataValueFactory implementation.
+ */
+ static DataValueDescriptor decimalImplementation;
/*
** Static methods to obtain TypeIds
@@ -1488,8 +1492,9 @@
case StoredFormatIds.CHAR_TYPE_ID:
return new SQLChar();
+ // Implementation of DECIMAL can change.
case StoredFormatIds.DECIMAL_TYPE_ID:
- return new SQLDecimal();
+ return decimalImplementation.getNewNull();
case StoredFormatIds.DOUBLE_TYPE_ID:
return new SQLDouble();
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java?view=diff&r1=154095&r2=154096
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java Wed Feb 16 14:55:11 2005
@@ -114,7 +114,8 @@
} else if (typeName.equals(TypeId.REAL_NAME)) {
newValue = new org.apache.derby.iapi.types.SQLDouble();
} else {
- newValue = new org.apache.derby.iapi.types.SQLDecimal();
+ TypeId decimalTypeId = TypeId.getBuiltInTypeId(java.sql.Types.DECIMAL);
+ newValue = decimalTypeId.getNull();
}
newValue.setValue(value);