db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1548128 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: TableName.java sqlgrammar.jj
Date Thu, 05 Dec 2013 13:17:54 GMT
Author: kahatlen
Date: Thu Dec  5 13:17:54 2013
New Revision: 1548128

URL: http://svn.apache.org/r1548128
Log:
DERBY-6362: CHECK constraint uses wrong schema for unqualified routine invocations

Part 2: Fix offset of qualified table names. Their begin offset
pointed to the beginning of the table name token, but should point to
the beginning of the schema name token if they have one.

Also leave begin and end offset unspecified (-1 implied) for some
synthetic table name nodes that previously set the offsets to 0
explicitly. This makes it easier to tell whether they are synthetic
later.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.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/TableName.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java?rev=1548128&r1=1548127&r2=1548128&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java Thu Dec
 5 13:17:54 2013
@@ -81,10 +81,7 @@ public class TableName extends QueryTree
         int tokEndOffset,
         ContextManager cm)
 	{
-        super(cm);
-        hasSchema = schemaName != null;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this(schemaName, tableName, cm);
         this.setBeginOffset(tokBeginOffset);
         this.setEndOffset(tokEndOffset);
 	}

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=1548128&r1=1548127&r2=1548128&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 Thu Dec
 5 13:17:54 2013
@@ -179,6 +179,7 @@ public class SQLParser
 	*/	
 	private Token	lastIdentifierToken;
 	private Token	nextToLastIdentifierToken;
+    private Token   thirdToLastIdentifierToken;
 
 	static final String SINGLEQUOTES = "\'\'";
 	static final String DOUBLEQUOTES = "\"\"";
@@ -4902,6 +4903,7 @@ qualifiedName(int id_length_limit) throw
 	String	qualifiedId;
 	String	firstName = null;
 	String	secondName = null;
+    Token firstNameToken = null;
 }
 {
 	firstName = identifier(Limits.MAX_IDENTIFIER_LENGTH, false)
@@ -4918,11 +4920,13 @@ qualifiedName(int id_length_limit) throw
 		if (secondName == null)
 		{
 			qualifiedId = firstName;
+            firstNameToken = lastIdentifierToken;
 		}
 		else
 		{
 			schemaName = firstName;
 			qualifiedId = secondName;
+            firstNameToken = nextToLastIdentifierToken;
 		}
 
 		//limit the qualifiedId to the id length limit passed to this method
@@ -4933,7 +4937,7 @@ qualifiedName(int id_length_limit) throw
         return new TableName(
             schemaName,
             qualifiedId,
-            lastIdentifierToken.beginOffset,
+            firstNameToken.beginOffset,
             lastIdentifierToken.endOffset,
             getContextManager());
 	}
@@ -6257,8 +6261,6 @@ escapedSYSFUNFunction() throws StandardE
         TableName functionName = new TableName(
                                 SchemaDescriptor.IBM_SYSTEM_FUN_SCHEMA_NAME,
 								sysFunName,
-                                Integer.valueOf(0),
-                                Integer.valueOf(0),
 								getContextManager());
 	   
         MethodCallNode methodNode = new StaticMethodCallNode(
@@ -7980,8 +7982,10 @@ columnNameForInvocation() throws Standar
             tabName = new TableName(
                     schemaName,
                     tableName,
-                    Integer.valueOf(nextToLastIdentifierToken.beginOffset),
-                    Integer.valueOf(nextToLastIdentifierToken.endOffset),
+                    (thirdName == null
+                         ? nextToLastIdentifierToken
+                         : thirdToLastIdentifierToken).beginOffset,
+                    nextToLastIdentifierToken.endOffset,
                     getContextManager());
 		}
 
@@ -8068,8 +8072,10 @@ columnReference() throws StandardExcepti
             tabName = new TableName(
                 schemaName,
                 tableName,
-                Integer.valueOf(nextToLastIdentifierToken.beginOffset),
-                Integer.valueOf(nextToLastIdentifierToken.endOffset),
+                (thirdName == null
+                     ? nextToLastIdentifierToken
+                     : thirdToLastIdentifierToken).beginOffset,
+                nextToLastIdentifierToken.endOffset,
                 getContextManager());
 		}
 
@@ -14374,6 +14380,7 @@ internalIdentifier( int id_length_limit,
 		// Remember whether last token was a delimited identifier
 		nextToLastTokenDelimitedIdentifier = lastTokenDelimitedIdentifier;
         lastTokenDelimitedIdentifier = false;
+        thirdToLastIdentifierToken = nextToLastIdentifierToken;
 		nextToLastIdentifierToken = lastIdentifierToken;
 		lastIdentifierToken = tok;
 		return str;
@@ -14423,6 +14430,7 @@ delimitedIdentifier() :
 		// Remember whether last token was a delimited identifier
 		nextToLastTokenDelimitedIdentifier = lastTokenDelimitedIdentifier;
         lastTokenDelimitedIdentifier = true;
+        thirdToLastIdentifierToken = nextToLastIdentifierToken;
 		nextToLastIdentifierToken = lastIdentifierToken;
 		lastIdentifierToken = tok;
 
@@ -14869,6 +14877,7 @@ nonReservedKeyword()  :
 		// Remember whether last token was a delimited identifier
 		nextToLastTokenDelimitedIdentifier = lastTokenDelimitedIdentifier;
         lastTokenDelimitedIdentifier = false;
+        thirdToLastIdentifierToken = nextToLastIdentifierToken;
 		nextToLastIdentifierToken = lastIdentifierToken;
 		lastIdentifierToken = tok;
 		return tok.image;



Mime
View raw message