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 my...@apache.org on 2014/10/06 23:51:21 UTC
svn commit: r1629771 - in /db/derby/code/branches/10.10: ./
java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Author: myrnavl
Date: Mon Oct 6 21:51:21 2014
New Revision: 1629771
URL: http://svn.apache.org/r1629771
Log:
DERBY-6543; Syntax error when reference to transition variable has whitespace around it
merge of revision 1589036 from trunk
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1589036
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1629771&r1=1629770&r2=1629771&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Mon Oct 6 21:51:21 2014
@@ -5093,14 +5093,12 @@ public final class DataDictionaryImpl
}
int tokBeginOffset = tableName.getBeginOffset();
- int tokEndOffset = tableName.getEndOffset();
if (tokBeginOffset == -1)
{
continue;
}
String colName = ref.getColumnName();
- int columnLength = ref.getEndOffset() - ref.getBeginOffset() + 1;
newText.append(triggerDefinition.substring(start, tokBeginOffset-actionOffset));
int colPositionInRuntimeResultSet = -1;
@@ -5156,7 +5154,8 @@ public final class DataDictionaryImpl
tableName.getTableName(),
tableName.getTableName().equals(oldReferencingName),
colPositionInRuntimeResultSet));
- start = tokEndOffset- actionOffset + columnLength + 2;
+
+ start = ref.getEndOffset() + 1 - actionOffset;
}
//By this point, we are finished transforming the trigger action if
//it has any references to old/new transition variables.
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=1629771&r1=1629770&r2=1629771&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java Mon Oct 6 21:51:21 2014
@@ -2121,4 +2121,28 @@ public class TriggerTest extends BaseJDB
JDBC.assertSingleValueResultSet(
s.executeQuery("select * from t2"), "2");
}
+
+ /**
+ * DERBY-6543: If a reference to a transition variable had blanks around
+ * the period sign that separated the transition variable and the column
+ * name, such as {@code NEW . X} instead of {@code NEW.X}, it would fail
+ * with a syntax error.
+ */
+ public void testDerby6543() throws SQLException {
+ setAutoCommit(false);
+ Statement s = createStatement();
+ s.execute("create table d6543_1(x int)");
+ s.execute("create table d6543_2(x int)");
+
+ // Used to fail with syntax error.
+ s.execute("create trigger d6543_tr after insert on d6543_1 "
+ + "referencing new as new for each row insert into d6543_2 "
+ + "select x from d6543_1 where new . x = x");
+
+ // Verify trigger works.
+ assertUpdateCount(s, 4, "insert into d6543_1 values 1, 2, 2, 3");
+ JDBC.assertFullResultSet(
+ s.executeQuery("select * from d6543_2 order by x"),
+ new String[][] { {"1"}, {"2"}, {"2"}, {"2"}, {"2"}, {"3"} });
+ }
}