db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r478031 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/
Date Wed, 22 Nov 2006 04:44:36 GMT
Author: djd
Date: Tue Nov 21 20:44:35 2006
New Revision: 478031

URL: http://svn.apache.org/viewvc?view=rev&rev=478031
Log:
DERBY-2096 (partial) Change the main return type from parsing a statement to a StatementNode.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java
    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/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java Tue Nov
21 20:44:35 2006
@@ -27,7 +27,7 @@
  * but this is work in progress.
  * manish - Wed Mar 28 13:05:19 PST 2001
  */
-import	org.apache.derby.impl.sql.compile.QueryTreeNode;
+import org.apache.derby.impl.sql.compile.StatementNode;
 
 /**
  * The Parser interface is intended to work with Jack-generated parsers (now JavaCC).
@@ -57,12 +57,12 @@
 	 *
 	 * @exception StandardException		Thrown on failure
 	 */
-	public QueryTreeNode	parseStatement(String statementSQLText,
+	public StatementNode	parseStatement(String statementSQLText,
 		Object[] paramDefaults) 
 		throws StandardException;
 
 
-	public QueryTreeNode parseStatement(String statementSQLText)
+	public StatementNode parseStatement(String statementSQLText)
 		throws StandardException;
 
 	/**

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?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- 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 Nov 21 20:44:35 2006
@@ -492,7 +492,7 @@
 				newText.append(originalActionText.substring(start));
 			}
 			actionText = newText.toString();
-			actionNode = (StatementNode)reparseTriggerText();
+			actionNode = parseStatement(actionText, true);
 		}
 
 		return regenNode;
@@ -543,29 +543,6 @@
 		return sorted;
 	}
 
-	/*
-	** Parse the text and return the tree.
-	*/
-	private QueryTreeNode reparseTriggerText() throws StandardException
-	{
-		/*
-		** Get a new compiler context, so the parsing of the text
-		** doesn't mess up anything in the current context 
-		*/
-		LanguageConnectionContext lcc = getLanguageConnectionContext();
-		CompilerContext newCC = lcc.pushCompilerContext();
-		newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
-
-		try
-		{
-			return QueryTreeNode.parseQueryText(newCC, actionText, (Object[])null, lcc);
-		}
-
-		finally
-		{
-			lcc.popCompilerContext(newCC);
-		}
-	}
 	/*
 	** Make sure the given column name is found in the trigger
 	** target table.  Generate the appropriate SQL to get it.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Tue
Nov 21 20:44:35 2006
@@ -2172,20 +2172,8 @@
 						"vd not expected to be null for " + tableName);
 				}
 	
-				/*
-				** Push a compiler context to parse the query text so that
-				** it won't clobber the current context.
-				*/
-				LanguageConnectionContext lcc = getLanguageConnectionContext();
-				CompilerContext newCC = lcc.pushCompilerContext();
-				cvn = (CreateViewNode) 
-                    QueryTreeNode.parseQueryText( 
-                        newCC,
-                        vd.getViewText(),
-                        (DataValueDescriptor[])null,	// default params
-                        lcc);
-
-				lcc.popCompilerContext(newCC);
+				cvn = (CreateViewNode)
+				          parseStatement(vd.getViewText(), false);
 
 				rsn = cvn.getParsedQueryExpression();
 	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java Tue
Nov 21 20:44:35 2006
@@ -56,7 +56,7 @@
 	static final int LARGE_TOKEN_SIZE = 128;
 
         /* Don't ever access these objects directly, call getParser(), and getTokenManager()
*/
-        protected Object cachedParser; 
+        private SQLParser cachedParser; 
 	protected Object cachedTokenManager;
 
 	protected CharStream charStream;
@@ -73,7 +73,7 @@
 		this.cc = cc;
 	}
 
-	public QueryTreeNode parseStatement(String statementSQLText) 
+	public StatementNode parseStatement(String statementSQLText) 
 		throws StandardException
 	{
 		return parseStatement(statementSQLText, (Object[])null);
@@ -96,10 +96,10 @@
 	    return tm;
 	}
 
-        /**
+     /**
 	 * new parser, appropriate for the ParserImpl object.
 	 */
-        protected Object getParser()
+     private SQLParser getParser()
         {
 	    SQLParserTokenManager tm = (SQLParserTokenManager) getTokenManager();
 	    /* returned a cached Parser if already exists, otherwise create */
@@ -126,7 +126,7 @@
 	 * @exception StandardException	Thrown on error
 	 */
 
-	public QueryTreeNode parseStatement(String statementSQLText, Object[] paramDefaults) 
+	public StatementNode parseStatement(String statementSQLText, Object[] paramDefaults) 
 		throws StandardException
 	{
 
@@ -148,7 +148,7 @@
 		/* Parse the statement, and return the QueryTree */
 		try
 		{
-		    return parseGoalProduction( statementSQLText, paramDefaults);
+		    return getParser().Statement(statementSQLText, paramDefaults);
 		}
 		catch (ParseException e)
 		{
@@ -159,26 +159,6 @@
 		    throw StandardException.newException(SQLState.LANG_LEXICAL_ERROR, e.getMessage());
 		}
 	}
-
-        /**
-	 * Parse the goal production, e.g. "statement" for the normal SQL parser.
-	 *
-	 * @param statementSQLText The Statement to parse
-	 * @param paramDefaults	parameter defaults.  Passed around as an array
-	 *						of objects, but is really an array of StorableDataValues
-         *
-	 * @return	A QueryTree representing the parsed statement
-	 *
-	 * @exception ParseException
-         * @exception TokenMgrError
-         */
-        protected QueryTreeNode parseGoalProduction( String statementSQLText,
-                                                   Object[] paramDefaults)
-            throws ParseException, TokenMgrError, StandardException
-        {
-	    SQLParser p = (SQLParser) getParser();
-	    return p.Statement( statementSQLText, paramDefaults);
-	} // End of parseGoalProduction
 
 	/**
 	 * Returns the current SQL text string that is being parsed.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Tue
Nov 21 20:44:35 2006
@@ -824,44 +824,33 @@
 		}
 		return intVal;
 	}
-
+	
 	/**
-	 * Parse some query text and return a parse tree.
-	 *
-	 * @param compilerContext	The CompilerContext to use
-	 * @param queryText	Query text to parse.
-	 * @param paramDefaults		array of parameter defaults used to
-	 *							initialize parameter nodes, and ultimately
-	 *							for the optimization of statements with
-	 *							parameters.
-	 * @param lcc				Current LanguageConnectionContext
-	 *
-	 * @return	ResultSetNode	The parse tree.
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-	public static QueryTreeNode
-	parseQueryText
-	(
-		CompilerContext		compilerContext,
-		String				queryText,
-		Object[]			paramDefaults,
-		LanguageConnectionContext lcc
-    )
-		 throws StandardException
+	** Parse the a SQL statement from the body
+	* of another SQL statement. Pushes and pops a
+	* separate CompilerContext to perform the compilation.
+	*/
+	StatementNode parseStatement(String sql, boolean internalSQL) throws StandardException
 	{
-		LanguageConnectionFactory	lcf;
-		Parser						p;
-		QueryTreeNode			    qtn;
+		/*
+		** Get a new compiler context, so the parsing of the text
+		** doesn't mess up anything in the current context 
+		*/
+		LanguageConnectionContext lcc = getLanguageConnectionContext();
+		CompilerContext newCC = lcc.pushCompilerContext();
+		if (internalSQL)
+		    newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
 
-		p = compilerContext.getParser();
-		
-		/* Get a Statement to pass to the parser */
-		lcf = lcc.getLanguageConnectionFactory();
+		try
+		{
+			Parser p = newCC.getParser();
+			return p.parseStatement(sql);
+		}
 
-		/* Finally, we can call the parser */
-		qtn = (QueryTreeNode)p.parseStatement(queryText, paramDefaults);
-		return	qtn;
+		finally
+		{
+			lcc.popCompilerContext(newCC);
+		}
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java?view=diff&rev=478031&r1=478030&r2=478031
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java Tue
Nov 21 20:44:35 2006
@@ -26,6 +26,8 @@
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.compile.Parser;
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 
 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
@@ -151,7 +153,7 @@
 		optimizeStatement();
 		return this;
 	}
-
+	
 	/**
 	 * create the outer shell class builder for the class we will
 	 * be generating, generate the expression to stuff in it,



Mime
View raw message