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 2014/05/06 11:41:09 UTC
svn commit: r1592695 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile:
CreateTriggerNode.java sqlgrammar.jj
Author: kahatlen
Date: Tue May 6 09:41:09 2014
New Revision: 1592695
URL: http://svn.apache.org/r1592695
Log:
DERBY-6370: dblook doesn't schema-qualify identifiers in trigger actions
Remove no longer needed offset fields in CreateTriggerNode.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?rev=1592695&r1=1592694&r2=1592695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java Tue May 6 09:41:09 2014
@@ -71,8 +71,6 @@ class CreateTriggerNode extends DDLState
private String actionText;
private String originalWhenText;
private String originalActionText;
- private final int whenOffset;
- private final int actionOffset;
private ProviderInfo[] providerInfo;
private SchemaDescriptor triggerSchemaDescriptor;
@@ -262,10 +260,8 @@ class CreateTriggerNode extends DDLState
* @param refClause the referencing clause
* @param whenClause the WHEN clause tree
* @param whenText the text of the WHEN clause
- * @param whenOffset offset of start of WHEN clause
* @param actionNode the trigger action tree
* @param actionText the text of the trigger action
- * @param actionOffset offset of start of action clause
* @param cm context manager
*
* @exception StandardException Thrown on error
@@ -282,10 +278,8 @@ class CreateTriggerNode extends DDLState
List<TriggerReferencingStruct> refClause,
ValueNode whenClause,
String whenText,
- int whenOffset,
StatementNode actionNode,
String actionText,
- int actionOffset,
ContextManager cm
) throws StandardException
{
@@ -302,11 +296,9 @@ class CreateTriggerNode extends DDLState
this.whenClause = whenClause;
this.originalWhenText = whenText;
this.whenText = (whenText == null) ? null : whenText.trim();
- this.whenOffset = whenOffset;
this.actionNode = actionNode;
this.originalActionText = actionText;
this.actionText = (actionText == null) ? null : actionText.trim();
- this.actionOffset = actionOffset;
this.implicitCreateSchema = true;
}
@@ -643,7 +635,7 @@ class CreateTriggerNode extends DDLState
originalActionText,
referencedColInts,
referencedColsInTriggerAction,
- actionOffset,
+ actionNode.getBeginOffset(),
triggerTableDescriptor,
triggerEventMask,
true,
@@ -655,7 +647,8 @@ class CreateTriggerNode extends DDLState
getDataDictionary().getTriggerActionString(
whenClause, oldTableName, newTableName,
originalWhenText, referencedColInts,
- referencedColsInTriggerAction, whenOffset,
+ referencedColsInTriggerAction,
+ whenClause.getBeginOffset(),
triggerTableDescriptor, triggerEventMask, true,
whenClauseTransformations);
}
@@ -672,11 +665,10 @@ class CreateTriggerNode extends DDLState
{
//This is a table level trigger
transformedActionText = transformStatementTriggerText(
- actionNode, originalActionText, actionOffset,
- actionTransformations);
+ actionNode, originalActionText, actionTransformations);
if (whenClause != null) {
transformedWhenText = transformStatementTriggerText(
- whenClause, originalWhenText, whenOffset,
+ whenClause, originalWhenText,
whenClauseTransformations);
}
}
@@ -884,8 +876,6 @@ class CreateTriggerNode extends DDLState
* SQL statement
* @param originalText the original text of the WHEN clause or the
* triggered SQL statement
- * @param offset the offset of the WHEN clause or the triggered SQL
- * statement within the CREATE TRIGGER statement
* @param replacements list that will be populated with int arrays that
* describe how the original text was transformed. The int arrays
* contain the begin (inclusive) and end (exclusive) positions of the
@@ -898,10 +888,10 @@ class CreateTriggerNode extends DDLState
* transformation
*/
private String transformStatementTriggerText(
- Visitable node, String originalText, int offset,
- List<int[]> replacements)
+ QueryTreeNode node, String originalText, List<int[]> replacements)
throws StandardException
{
+ final int offset = node.getBeginOffset();
int start = 0;
StringBuilder newText = new StringBuilder();
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1592695&r1=1592694&r2=1592695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Tue May 6 09:41:09 2014
@@ -11249,16 +11249,16 @@ triggerDefinition() throws StandardExcep
statementSQLText, actionBegin, actionEnd, false);
String whenText = null;
- int whenOffset = 0;
if (whenClause != null) {
// The WHEN clause is only supported if the dictionary version is
// 10.11 or higher.
checkVersion(DataDictionary.DD_VERSION_DERBY_10_11, "WHEN");
- whenOffset = whenOpen.endOffset + 1;
+ int whenOffset = whenOpen.endOffset + 1;
+ int whenEnd = whenClose.beginOffset - 1;
whenClause.setBeginOffset(whenOffset);
- whenClause.setEndOffset(whenClose.beginOffset - 1);
+ whenClause.setEndOffset(whenEnd);
whenText = StringUtil.slice(statementSQLText,
- whenOffset, whenClose.beginOffset - 1, false);
+ whenOffset, whenEnd, false);
}
return new CreateTriggerNode(
@@ -11272,10 +11272,8 @@ triggerDefinition() throws StandardExcep
refClause, // referencing clause
whenClause, // when clause node
whenText, // when clause text
- whenOffset,
actionNode,
actionText,
- actionBegin,
getContextManager());
}
}