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 ka...@apache.org on 2009/08/31 09:47:17 UTC
svn commit: r809490 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/iapi/types/
java/engine/org/apache/derby/impl/sql/execute/
java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: kahatlen
Date: Mon Aug 31 07:47:17 2009
New Revision: 809490
URL: http://svn.apache.org/viewvc?rev=809490&view=rev
Log:
DERBY-4348: Copy table content with "INSERT INTO table SELECT FROM (...)" statement leads to corrupt data
Merged fix from trunk (revision 808850).
Added:
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
- copied unchanged from r808850, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 31 07:47:17 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?rev=809490&r1=809489&r2=809490&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Mon Aug 31 07:47:17 2009
@@ -627,7 +627,9 @@
"Normalization of " + t2 + " being asked to convert to " + t1);
}
}
- }
+ } else {
+ SanityManager.THROWASSERT("cachedDest is null");
+ }
}
if (source.isNull())
@@ -635,15 +637,9 @@
if (!isNullable())
throw StandardException.newException(SQLState.LANG_NULL_INTO_NON_NULL,"");
- if (cachedDest == null)
- cachedDest = getNull();
- else
- cachedDest.setToNull();
+ cachedDest.setToNull();
} else {
- if (cachedDest == null)
- cachedDest = getNull();
-
int jdbcId = getJDBCTypeId();
cachedDest.normalize(this, source);
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java?rev=809490&r1=809489&r2=809490&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java Mon Aug 31 07:47:17 2009
@@ -52,6 +52,12 @@
private int numCols;
private int startCol;
+ /**
+ * This array contains data value descriptors that can be used (and reused)
+ * by normalizeRow() to hold the normalized column values.
+ */
+ private final DataValueDescriptor[] cachedDestinations;
+
/* RESOLVE - We need to pass the ResultDescription for this ResultSet
* as a parameter to the constructor and use it instead of the one from
* the activation
@@ -107,6 +113,7 @@
startCol = computeStartColumn( forUpdate, resultDescription );
normalizedRow = activation.getExecutionFactory().getValueRow(numCols);
+ cachedDestinations = new DataValueDescriptor[numCols];
recordConstructorTime();
}
@@ -350,10 +357,6 @@
*/
private ExecRow normalizeRow(ExecRow sourceRow) throws StandardException
{
- int whichCol;
-
- if (desiredTypes == null) { desiredTypes = fetchResultTypes( resultDescription ); }
-
int count = resultDescription.getColumnCount();
for (int i = 1; i <= count; i++)
@@ -367,8 +370,9 @@
{ normalizedCol = sourceCol; }
else
{
- normalizedCol = normalizeColumn
- ( desiredTypes[i - 1], sourceRow, i, normalizedRow.getColumn(i), resultDescription );
+ normalizedCol = normalizeColumn(
+ getDesiredType(i), sourceRow, i,
+ getCachedDestination(i), resultDescription);
}
normalizedRow.setColumn(i, normalizedCol);
@@ -379,12 +383,43 @@
}
/**
+ * Get a cached data value descriptor that can receive the normalized
+ * value of the specified column.
+ *
+ * @param col the column number (1-based)
+ * @return a data value descriptor of the correct type for the column
+ * @throws StandardException if a new data value descriptor cannot be
+ * created
+ */
+ private DataValueDescriptor getCachedDestination(int col)
+ throws StandardException {
+ int index = col - 1;
+ if (cachedDestinations[index] == null) {
+ cachedDestinations[index] = getDesiredType(col).getNull();
+ }
+ return cachedDestinations[index];
+ }
+
+ /**
+ * Get a data type descriptor that describes the desired type for the
+ * specified column.
+ *
+ * @param col the column number (1-based)
+ * @return a data type descriptor for the column
+ */
+ private DataTypeDescriptor getDesiredType(int col) {
+ if (desiredTypes == null) {
+ desiredTypes = fetchResultTypes(resultDescription);
+ }
+ return desiredTypes[col - 1];
+ }
+
+ /**
* <p>
* Fetch the result datatypes out of the activation.
* </p>
*/
- private DataTypeDescriptor[] fetchResultTypes( ResultDescription desc )
- throws StandardException
+ private DataTypeDescriptor[] fetchResultTypes(ResultDescription desc)
{
int count = desc.getColumnCount();
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=809490&r1=809489&r2=809490&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Mon Aug 31 07:47:17 2009
@@ -68,6 +68,7 @@
suite.addTest(FloatTypesTest.suite());
suite.addTest(GrantRevokeTest.suite());
suite.addTest(GroupByExpressionTest.suite());
+ suite.addTest(InsertTest.suite());
suite.addTest(LangScripts.suite());
suite.addTest(MathTrigFunctionsTest.suite());
suite.addTest(PrepareExecuteDDL.suite());