[teiid-commits] teiid SVN: r4488 - in trunk: engine/src/main/java/org/teiid/query and 5 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sat Sep 29 15:07:42 EDT 2012


Author: shawkins
Date: 2012-09-29 15:07:41 -0400 (Sat, 29 Sep 2012)
New Revision: 4488

Added:
   trunk/api/src/main/java/org/teiid/metadata/MetadataException.java
   trunk/engine/src/main/java/org/teiid/query/parser/TeiidSQLParserTokenManager.java
Modified:
   trunk/api/src/main/java/org/teiid/metadata/DuplicateRecordException.java
   trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
   trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
   trunk/api/src/main/java/org/teiid/metadata/ParseException.java
   trunk/api/src/main/java/org/teiid/metadata/Parser.java
   trunk/api/src/main/java/org/teiid/metadata/Schema.java
   trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
   trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
   trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
   trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
   trunk/engine/src/main/resources/org/teiid/query/i18n.properties
   trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java
   trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
Log:
TEIID-2233 updating parse exceptions to provide more context and updating the functiontree validation

Modified: trunk/api/src/main/java/org/teiid/metadata/DuplicateRecordException.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/DuplicateRecordException.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/DuplicateRecordException.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -22,12 +22,14 @@
 
 package org.teiid.metadata;
 
-public class DuplicateRecordException extends AssertionError {
+import org.teiid.core.BundleUtil.Event;
 
+public class DuplicateRecordException extends MetadataException {
+
 	private static final long serialVersionUID = -1319489333975416115L;
 
-	public DuplicateRecordException(String msg) {
-		super(msg);
+	public DuplicateRecordException(Event e, String msg) {
+		super(e, msg);
 	}
 	
 }

Added: trunk/api/src/main/java/org/teiid/metadata/MetadataException.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataException.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataException.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata;
+
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.BundleUtil.Event;
+
+public class MetadataException extends TeiidRuntimeException {
+	private static final long serialVersionUID = -7889770730039591817L;
+
+	public MetadataException(Event event, Throwable cause) {
+		super(event, cause);
+	}
+	
+	public MetadataException(Throwable cause) {
+		super(cause);
+	}
+	
+	public MetadataException(Event event, String message) {
+		super(event, message);
+	}
+	
+	public MetadataException(String message) {
+		super(message);
+	}
+
+	public MetadataException(Event event,
+			Throwable e, String message) {
+		super(event, e, message);
+	}
+}
\ No newline at end of file


Property changes on: trunk/api/src/main/java/org/teiid/metadata/MetadataException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -151,7 +151,7 @@
 			 throw new TranslatorException(DataPlugin.Event.TEIID60008, DataPlugin.Util.gs(DataPlugin.Event.TEIID60008, name));
 		}
 		if (table.getColumnByName(name) != null) {
-			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60016, table.getFullName() + AbstractMetadataRecord.NAME_DELIM_CHAR + name));
+			throw new DuplicateRecordException(DataPlugin.Event.TEIID60016, DataPlugin.Util.gs(DataPlugin.Event.TEIID60016, table.getFullName() + AbstractMetadataRecord.NAME_DELIM_CHAR + name));
 		}
 		Column column = new Column();
 		column.setName(name);
@@ -276,11 +276,10 @@
 		return index;
 	}
 
-	private void assignColumn(Table table, ColumnSet<?> columns, String columnName)
-			throws TranslatorException {
+	private void assignColumn(Table table, ColumnSet<?> columns, String columnName) {
 		Column column = table.getColumnByName(columnName);
 		if (column == null) {
-			throw new TranslatorException(DataPlugin.Event.TEIID60011, DataPlugin.Util.gs(DataPlugin.Event.TEIID60011, columnName));				
+			throw new MetadataException(DataPlugin.Event.TEIID60011, DataPlugin.Util.gs(DataPlugin.Event.TEIID60011, columnName));				
 		}
 		columns.getColumns().add(column);
 	}
@@ -386,7 +385,7 @@
 	}
 
 	private void assignColumns(List<String> columnNames, Table table,
-			ColumnSet<?> columns) throws TranslatorException {
+			ColumnSet<?> columns) {
 		for (String columnName : columnNames) {
 			assignColumn(table, columns, columnName);
 		}
@@ -562,9 +561,9 @@
 	/**
 	 * Parses, but does not close, the given {@link Reader} into this {@link MetadataFactory}
 	 * @param ddl
-	 * @throws ParseException
+	 * @throws MetadataException
 	 */
-	public void parse(Reader ddl) throws ParseException {
+	public void parse(Reader ddl) throws MetadataException {
 		this.parser.parseDDL(this, ddl);
 	}
 	

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -51,7 +51,7 @@
 	
 	public void addSchema(Schema schema) {
 		if (this.schemas.put(schema.getName(), schema) != null) {
-			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60012, schema.getName()));
+			throw new DuplicateRecordException(DataPlugin.Event.TEIID60012, DataPlugin.Util.gs(DataPlugin.Event.TEIID60012, schema.getName()));
 		}		
 		this.schemaList.add(schema);
 	}

Modified: trunk/api/src/main/java/org/teiid/metadata/ParseException.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/ParseException.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/ParseException.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -22,13 +22,20 @@
 
 package org.teiid.metadata;
 
-import org.teiid.core.TeiidRuntimeException;
 import org.teiid.core.BundleUtil.Event;
 
-public class ParseException extends TeiidRuntimeException {
+public class ParseException extends MetadataException {
 	private static final long serialVersionUID = -7889770730039591817L;
 
 	public ParseException(Event event, Throwable cause) {
 		super(event, cause);
 	}
+	
+	public ParseException(Event event, String message) {
+		super(event, message);
+	}
+	
+	public ParseException(String message) {
+		super(message);
+	}
 }
\ No newline at end of file

Modified: trunk/api/src/main/java/org/teiid/metadata/Parser.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Parser.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/Parser.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -31,7 +31,7 @@
 	 * The {@link Reader} will not be closed by this call.
 	 * @param factory
 	 * @param ddl
-	 * @throws ParseException
+	 * @throws MetadataException
 	 */
-	void parseDDL(MetadataFactory factory, Reader ddl) throws ParseException;
+	void parseDDL(MetadataFactory factory, Reader ddl) throws MetadataException;
 }
\ No newline at end of file

Modified: trunk/api/src/main/java/org/teiid/metadata/Schema.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Schema.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/api/src/main/java/org/teiid/metadata/Schema.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -43,14 +43,14 @@
 	public void addTable(Table table) {
 		table.setParent(this);
 		if (this.tables.put(table.getName(), table) != null) {
-			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60013, table.getName())); 
+			throw new DuplicateRecordException(DataPlugin.Event.TEIID60013, DataPlugin.Util.gs(DataPlugin.Event.TEIID60013, table.getName())); 
 		}
 	}
 	
 	public void addProcedure(Procedure procedure) {
 		procedure.setParent(this);
 		if (this.procedures.put(procedure.getName(), procedure) != null) {
-			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60014, procedure.getName())); 
+			throw new DuplicateRecordException(DataPlugin.Event.TEIID60014, DataPlugin.Util.gs(DataPlugin.Event.TEIID60014, procedure.getName())); 
 		}
 	}
 	
@@ -58,7 +58,7 @@
 		function.setParent(this);
 		//TODO: ensure that all uuids are unique
 		if (this.functions.put(function.getUUID(), function) != null) {
-			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60015, function.getUUID()));
+			throw new DuplicateRecordException(DataPlugin.Event.TEIID60015, DataPlugin.Util.gs(DataPlugin.Event.TEIID60015, function.getUUID()));
 		}
 	}	
 

Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -535,6 +535,7 @@
     	TEIID31119, 
     	TEIID31120, 
     	TEIID31121, 
-    	TEIID31122,
+    	TEIID31122, 
+    	TEIID31123,
 	}
 }

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -36,7 +36,6 @@
 
 import org.teiid.UserDefinedAggregate;
 import org.teiid.core.CoreConstants;
-import org.teiid.core.TeiidRuntimeException;
 import org.teiid.core.types.DataTypeManager;
 import org.teiid.core.util.ReflectionHelper;
 import org.teiid.logging.LogConstants;
@@ -44,6 +43,7 @@
 import org.teiid.metadata.AbstractMetadataRecord;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.MetadataException;
 import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.function.metadata.FunctionCategoryConstants;
@@ -313,6 +313,9 @@
         boolean requiresContext = false;
         // Defect 20007 - Ignore the invocation method if pushdown is not required.
         if (validateClass && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) {
+        	if (method.getInvocationClass() == null || method.getInvocationMethod() == null) {
+        		throw new MetadataException(QueryPlugin.Event.TEIID31123, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31123, method.getName()));
+        	}
             try {
                 Class<?> methodClass = source.getInvocationClass(method.getInvocationClass(), method.getClassLoader()==null?Thread.currentThread().getContextClassLoader():method.getClassLoader());
                 ReflectionHelper helper = new ReflectionHelper(methodClass);
@@ -324,36 +327,36 @@
                 	requiresContext = true;
                 }
             } catch (ClassNotFoundException e) {
-            	 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30387, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30387, method.getName(), method.getInvocationClass()));
+            	 throw new MetadataException(QueryPlugin.Event.TEIID30387, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30387, method.getName(), method.getInvocationClass()));
             } catch (NoSuchMethodException e) {
-            	 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30388, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30388, method, method.getInvocationClass(), method.getInvocationMethod()));
+            	 throw new MetadataException(QueryPlugin.Event.TEIID30388, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30388, method, method.getInvocationClass(), method.getInvocationMethod()));
             } catch (Exception e) {                
-                 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30389, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30389, method, method.getInvocationClass(), method.getInvocationMethod()));
+                 throw new MetadataException(QueryPlugin.Event.TEIID30389, e,QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30389, method, method.getInvocationClass(), method.getInvocationMethod()));
             } 
             if (invocationMethod != null) {
             	// Check return type is non void
         		Class<?> methodReturn = invocationMethod.getReturnType();
         		if(method.getAggregateAttributes() == null && methodReturn.equals(Void.TYPE)) {
-        			 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30390, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30390, method.getName(), invocationMethod));
+        			 throw new MetadataException(QueryPlugin.Event.TEIID30390, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30390, method.getName(), invocationMethod));
         		}
 
         		// Check that method is public
         		int modifiers = invocationMethod.getModifiers();
         		if(! Modifier.isPublic(modifiers)) {
-        			 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30391, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30391, method.getName(), invocationMethod));
+        			 throw new MetadataException(QueryPlugin.Event.TEIID30391, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30391, method.getName(), invocationMethod));
         		}
 
         		// Check that method is static
         		if(! Modifier.isStatic(modifiers)) {
         			if (method.getAggregateAttributes() == null) {
-        				throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30392, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30392, method.getName(), invocationMethod));
+        				throw new MetadataException(QueryPlugin.Event.TEIID30392, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30392, method.getName(), invocationMethod));
         			}
         		} else if (method.getAggregateAttributes() != null) {
-        			throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30600, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30600, method.getName(), invocationMethod));
+        			throw new MetadataException(QueryPlugin.Event.TEIID30600, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30600, method.getName(), invocationMethod));
         		}
         		
         		if (method.getAggregateAttributes() != null && !(UserDefinedAggregate.class.isAssignableFrom(invocationMethod.getDeclaringClass()))) {
-    				throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30601, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30601, method.getName(), method.getInvocationClass(), UserDefinedAggregate.class.getName()));
+    				throw new MetadataException(QueryPlugin.Event.TEIID30601, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30601, method.getName(), method.getInvocationClass(), UserDefinedAggregate.class.getName()));
         		}
             }
         }

Modified: trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -28,6 +28,7 @@
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 
 import org.teiid.api.exception.query.QueryParserException;
@@ -60,14 +61,11 @@
         }
     };
 
-	// Used in parsing TokenMgrError message
-	private static final String LINE_MARKER = "line "; //$NON-NLS-1$
-	private static final String COL_MARKER = "column "; //$NON-NLS-1$
-    
     private static final String XQUERY_DECLARE = "declare"; //$NON-NLS-1$
     private static final String XML_OPEN_BRACKET = "<"; //$NON-NLS-1$
 
 	private SQLParser parser;
+	private TeiidSQLParserTokenManager tm;
     
 	/**
 	 * Construct a QueryParser - this may be reused.
@@ -87,9 +85,13 @@
 	
 	private SQLParser getSqlParser(Reader sql) {
 		if(parser == null) {
-			parser = new SQLParser(sql);
+			JavaCharStream jcs = new JavaCharStream(sql);
+			tm = new TeiidSQLParserTokenManager(new JavaCharStream(sql));
+			parser = new SQLParser(tm);
+			parser.jj_input_stream = jcs;
 		} else {
 			parser.ReInit(sql);	
+			tm.reinit();
 		}
 		return parser;		
 	}
@@ -117,8 +119,8 @@
             return result;
         } catch(ParseException pe) {
             throw convertParserException(pe);
-        } catch(TokenMgrError tme) {
-            throw handleTokenMgrError(tme);
+        } finally {
+        	tm.reinit();
         }
 	}
 	
@@ -157,11 +159,8 @@
             	 throw new QueryParserException(QueryPlugin.Event.TEIID30378, pe, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30378, sql));
             }
             throw convertParserException(pe);
-        } catch(TokenMgrError tme) {
-        	if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
-            	 throw new QueryParserException(QueryPlugin.Event.TEIID30378, tme, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30378, sql));
-            }
-            throw handleTokenMgrError(tme);
+        } finally {
+        	tm.reinit();
         }
 		return result;
 	}
@@ -194,25 +193,34 @@
 
         } catch(ParseException pe) {
             throw convertParserException(pe);
-
-        } catch(TokenMgrError tme) {
-            throw handleTokenMgrError(tme);
+        } finally {
+        	tm.reinit();
         }
         return result;
     }
 
     private QueryParserException convertParserException(ParseException pe) {
+    	if (pe.currentToken == null) {
+    		List<Token> preceeding = findPreceeding(parser.token, 1);
+    		if (!preceeding.isEmpty()) {
+    			pe.currentToken = preceeding.get(0);
+    		} else {
+    			pe.currentToken = parser.token;
+    		}
+        }
         QueryParserException qpe = new QueryParserException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31100, getMessage(pe, 1, 10)));
         qpe.setParseException(pe);
-        if (pe.currentToken == null) {
-        	pe.currentToken = parser.token;
-        }
         return qpe;
     }
         
-    public static String getMessage(ParseException pe, int maxTokenSequence, int maxExpansions) {
+    public String getMessage(ParseException pe, int maxTokenSequence, int maxExpansions) {
 		if (!pe.specialConstructor) {
-			return pe.getMessage();
+			if (pe.currentToken == null) {
+				return pe.getMessage();
+			}
+			StringBuilder sb = encountered(pe, 1);
+			sb.append(pe.getMessage());
+			return sb.toString();
 		}
 		StringBuffer expected = new StringBuffer();
 		int[][] expectedTokenSequences = pe.expectedTokenSequences;
@@ -227,21 +235,11 @@
 			}
 		});
 		int maxSize = expectedTokenSequences[0].length;
-		StringBuilder retval = new StringBuilder("Encountered \""); //$NON-NLS-1$
-		Token tok = currentToken.next;
-		for (int i = 0; i < maxSize; i++) {
-			if (i != 0)
-				retval.append(" "); //$NON-NLS-1$
-			if (tok.kind == 0) {
-				retval.append(tokenImage[0]);
-				break;
-			}
-			retval.append(pe.add_escapes(tok.image));
-			tok = tok.next;
+		StringBuilder retval = encountered(pe, maxSize);
+		if (currentToken.next.kind == -1) {
+			retval.append(QueryPlugin.Util.getString("QueryParser.lexicalError", currentToken.next.image)); //$NON-NLS-1$
+			return retval.toString();
 		}
-		retval.append("\" at line " + currentToken.next.beginLine + ", column " //$NON-NLS-1$ //$NON-NLS-2$
-				+ currentToken.next.beginColumn);
-		retval.append("." + eol); //$NON-NLS-1$
 		for (int i = 0; i < expectedTokenSequences.length; i++) {
 			boolean truncateStart = expectedTokenSequences[i].length == maxSize && maxSize > 1 && maxSize > maxTokenSequence;
 			int start = 0;
@@ -281,6 +279,118 @@
 		return retval.toString();
     }
 
+	private StringBuilder encountered(ParseException pe, int maxSize) {
+		StringBuilder retval = new StringBuilder("Encountered \""); //$NON-NLS-1$
+		Token currentToken = pe.currentToken;
+		List<Token> preceeding = findPreceeding(currentToken, 2);
+		if (!preceeding.isEmpty()) {
+			addTokenSequence(preceeding.size() + 1, retval, preceeding.get(0));
+		} else {
+			addTokenSequence(1, retval, currentToken);
+		}
+		if (currentToken.next.kind == -1) {
+			maxSize = 1;
+		}
+		retval.append(" [*]"); //$NON-NLS-1$
+		Token last = addTokenSequence(maxSize, retval, currentToken.next);
+		if (last.kind != 0) {
+			retval.append("[*]"); //$NON-NLS-1$
+			if (last.next == null) {
+				this.parser.getNextToken();
+			}
+			if (last.next != null) {
+				retval.append(" "); //$NON-NLS-1$
+				addTokenSequence(1, retval, last.next);
+			}
+		}
+		retval.append("\" at line ").append(currentToken.next.beginLine).append(", column ").append(currentToken.next.beginColumn); //$NON-NLS-1$ //$NON-NLS-2$
+		retval.append(".").append(pe.eol); //$NON-NLS-1$
+		return retval;
+	}
+
+	private List<Token> findPreceeding(Token currentToken, int count) {
+		LinkedList<Token> preceeding = new LinkedList<Token>();
+		Token tok = this.tm.head;
+		boolean found = false;
+		while (tok != null) {
+			if (tok == currentToken) {
+				found = true;
+				break;
+			}
+			preceeding.add(tok);
+			if (preceeding.size() > count) {
+				preceeding.removeFirst();
+			}
+			tok = tok.next;
+		}
+		if (!found) {
+			preceeding.clear();
+		}
+		return preceeding;
+	}
+
+	private Token addTokenSequence(int maxSize, StringBuilder retval,
+			Token tok) {
+		Token last = tok;
+		for (int i = 0; i < maxSize && tok != null; i++) {
+			if (i != 0)
+				retval.append(" "); //$NON-NLS-1$
+			if (tok.kind == 0) {
+				retval.append(SQLParserConstants.tokenImage[0]);
+				return tok;
+			}
+			last = tok;
+			add_escapes(tok.image, retval);
+			tok = tok.next;
+		}
+		return last;
+	}
+	
+	  /**
+	   * Used to convert raw characters to their escaped version
+	   * when these raw version cannot be used as part of an ASCII
+	   * string literal.  Also escapes double quotes.
+	   */
+	  protected void add_escapes(String str, StringBuilder retval) {
+	      for (int i = 0; i < str.length(); i++) {
+		      char ch = str.charAt(i); 
+	        switch (ch)
+	        {
+	           case 0 :
+	              continue;
+	           case '\b':
+	              retval.append("\\b"); //$NON-NLS-1$
+	              continue;
+	           case '\t':
+	              retval.append("\\t"); //$NON-NLS-1$
+	              continue;
+	           case '\n':
+	              retval.append("\\n"); //$NON-NLS-1$
+	              continue;
+	           case '\f':
+	              retval.append("\\f"); //$NON-NLS-1$
+	              continue;
+	           case '\r':
+	              retval.append("\\r"); //$NON-NLS-1$
+	              continue;
+	           case '\"':
+	              retval.append("\\\""); //$NON-NLS-1$
+	              continue;
+	           case '\\':
+	              retval.append("\\\\"); //$NON-NLS-1$
+	              continue;
+	           default:
+	              if (ch < 0x20 || ch > 0x7e) {
+	                 String s = "0000" + Integer.toString(ch, 16); //$NON-NLS-1$
+	                 retval.append("\\u" + s.substring(s.length() - 4, s.length())); //$NON-NLS-1$
+	              } else {
+	                 retval.append(ch);
+	              }
+	              continue;
+	        }
+	      }
+	   }
+
     /**
      * Takes a SQL string representing an SQL expression
      * and returns the object representation.
@@ -302,9 +412,8 @@
 
         } catch(ParseException pe) {
             throw convertParserException(pe);
-
-        } catch(TokenMgrError tme) {
-            throw handleTokenMgrError(tme);
+        } finally {
+        	tm.reinit();
         }
         return result;
     }
@@ -322,41 +431,12 @@
 
         } catch(ParseException pe) {
             throw convertParserException(pe);
-
-        } catch(TokenMgrError tme) {
-            throw handleTokenMgrError(tme);
+        } finally {
+        	tm.reinit();
         }
         return result;
     }
 
-    private QueryParserException handleTokenMgrError(TokenMgrError tme) {
-//            LogManager.logError( LogConstants.CTX_QUERY_PARSER, tme, new Object[] {"Exception parsing: ", sql} );
-
-        // From TokenMgrError, here is format of lexical error:
-        //
-        // "Lexical error at line " + errorLine + ", column " + errorColumn +
-        // ".  Encountered: " + (EOFSeen ? "<EOF> " : ("\"" +
-        // addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
-        // "after : \"" + addEscapes(errorAfter) + "\""
-
-        String msg = tme.getMessage();
-        int index = msg.indexOf(LINE_MARKER);
-        if(index > 0) {
-            index += LINE_MARKER.length();
-            int lastIndex = msg.indexOf(",", index); //$NON-NLS-1$
-            
-            index = msg.indexOf(COL_MARKER, lastIndex);
-            if(index > 0) {
-                index += COL_MARKER.length();
-                lastIndex = msg.indexOf(".", index); //$NON-NLS-1$
-                
-                return new QueryParserException(QueryPlugin.Util.getString("QueryParser.lexicalError", tme.getMessage())); //$NON-NLS-1$
-            }
-
-        }
-        return new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", tme.getMessage())); //$NON-NLS-1$
-    }
-    
     public void parseDDL(MetadataFactory factory, String ddl) {
     	parseDDL(factory, new StringReader(ddl));
     }
@@ -366,11 +446,13 @@
 			getSqlParser(ddl).parseMetadata(factory);
 		} catch (ParseException e) {
 			throw new org.teiid.metadata.ParseException(QueryPlugin.Event.TEIID30386, convertParserException(e));
-		}
+		} finally {
+        	tm.reinit();
+        }
     	HashSet<FunctionMethod> functions = new HashSet<FunctionMethod>();
     	for (FunctionMethod functionMethod : factory.getSchema().getFunctions().values()) {
 			if (!functions.add(functionMethod)) {
-				throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60015, functionMethod.getName()));
+				throw new DuplicateRecordException(DataPlugin.Event.TEIID60015, DataPlugin.Util.gs(DataPlugin.Event.TEIID60015, functionMethod.getName()));
 			}
 		}
     }

Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -34,7 +34,6 @@
 import org.teiid.core.util.PropertiesUtils;
 import org.teiid.core.util.StringUtil;
 import org.teiid.language.SQLConstants;
-import org.teiid.language.SQLConstants.Reserved;
 import org.teiid.metadata.*;
 import org.teiid.metadata.Column.SearchType;
 import org.teiid.metadata.ProcedureParameter.Type;
@@ -162,16 +161,7 @@
     	return true;
     }    
 
-    /**
-     * Check that this is a valid alias, remove quotes, and return updated
-     * alias string.
-     * @param id Metadata alias
-     */
-    String validateAlias(String id) throws ParseException {
-        return validateName(id, false);
-    }
-
-    private String validateName(String id, boolean element) throws ParseException {
+    String validateName(String id, boolean element) throws ParseException {
         if(id.indexOf('.') != -1) { 
             String key = "SQLParser.Invalid_alias"; //$NON-NLS-1$
             if (element) {
@@ -182,14 +172,6 @@
         return id;
     }
     
-    /**
-     * Check that this is a valid element name, remove quotes
-     * @param id Metadata alias
-     */
-    String validateElementName(String id) throws ParseException {
-        return validateName(id, true);
-    }
-    
     static String removeEscapeChars(String str, String tickChar) {
         return StringUtil.replaceAll(str, tickChar + tickChar, tickChar);
     }
@@ -304,38 +286,6 @@
     	return null;
     }
 
-    /**
-     * Helper for the FROM clause that takes the join type string and adds
-     * the join type to the From clause based on that type.
-     * @param groupID Left group ID
-     * @param rid Right group ID
-     * @param joinType Join type word from query
-     * @param from From clause to update
-     * @throws ParseException if parsing failed
-     */
-    JoinType getJoinType(Token joinTypeToken) throws ParseException {
-        if(joinTypeToken == null) { 
-            return JoinType.JOIN_INNER;
-        }   
-        String joinType = joinTypeToken.image;
-        if(joinType.equalsIgnoreCase(Reserved.INNER)) {
-            return JoinType.JOIN_INNER;
-        } else if(joinType.equalsIgnoreCase(Reserved.CROSS)) {
-            return JoinType.JOIN_CROSS;         
-        } else if(joinType.equalsIgnoreCase(Reserved.LEFT)) {
-            return JoinType.JOIN_LEFT_OUTER;
-        } else if(joinType.equalsIgnoreCase(Reserved.RIGHT)) {
-            return JoinType.JOIN_RIGHT_OUTER;
-        } else if(joinType.equalsIgnoreCase(Reserved.FULL)) {
-            return JoinType.JOIN_FULL_OUTER;
-        } else if(joinType.equalsIgnoreCase(Reserved.UNION)) {
-            return JoinType.JOIN_UNION;
-        } else {
-            Object[] params = new Object[] { joinType };
-            throw new ParseException(QueryPlugin.Util.getString("SQLParser.Unknown_join_type", params)); //$NON-NLS-1$
-        }
-    }
-    
     int getOperator(String opString) {
         if (opString.equals("=")) { //$NON-NLS-1$
             return CompareCriteria.EQ;
@@ -370,7 +320,7 @@
     	return new Block(stmt);
     }
     
-    void setColumnOptions(BaseColumn c)  throws ParseException {
+    void setColumnOptions(BaseColumn c)  throws MetadataException {
     	Map<String, String> props = c.getProperties();
 		setCommonProperties(c, props);
 		
@@ -384,7 +334,7 @@
     	}
     }
 
-	private void setColumnOptions(Column c, Map<String, String> props) throws ParseException {
+	private void setColumnOptions(Column c, Map<String, String> props) throws MetadataException {
 		String v = props.remove(DDLConstants.CASE_SENSITIVE); 
         if (v != null) {
         	c.setCaseSensitive(isTrue(v));
@@ -461,7 +411,7 @@
     			c.setScale(Integer.parseInt(matcher.group(4)));
     		}
     		else {
-    			throw new ParseException(QueryPlugin.Util.getString("udt_format_wrong", c.getName())); //$NON-NLS-1$
+    			throw new MetadataException(QueryPlugin.Util.getString("udt_format_wrong", c.getName())); //$NON-NLS-1$
     		}
     	}
     }
@@ -511,7 +461,7 @@
     }     
     
 	static void replaceProcedureWithFunction(MetadataFactory factory,
-			Procedure proc) throws ParseException {
+			Procedure proc) throws MetadataException {
 		FunctionMethod method = new FunctionMethod();
 		method.setName(proc.getName());
 		method.setPushdown(proc.isVirtual()?FunctionMethod.PushDown.CAN_PUSHDOWN:FunctionMethod.PushDown.MUST_PUSHDOWN);
@@ -519,7 +469,7 @@
 		ArrayList<FunctionParameter> ins = new ArrayList<FunctionParameter>();
 		for (ProcedureParameter pp:proc.getParameters()) {
 			if (pp.getType() == ProcedureParameter.Type.InOut || pp.getType() == ProcedureParameter.Type.Out) {
-				throw new ParseException(QueryPlugin.Util.getString("SQLParser.function_in", proc.getName())); //$NON-NLS-1$
+				throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_in", proc.getName())); //$NON-NLS-1$
 			}
 			
 			FunctionParameter fp = new FunctionParameter(pp.getName(), pp.getRuntimeType(), pp.getAnnotation());
@@ -533,7 +483,7 @@
 		method.setInputParameters(ins);
 		
 		if (proc.getResultSet() != null || method.getOutputParameter() == null) {
-			throw new ParseException(QueryPlugin.Util.getString("SQLParser.function_return", proc.getName())); //$NON-NLS-1$
+			throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_return", proc.getName())); //$NON-NLS-1$
 		}
 		
 		method.setAnnotation(proc.getAnnotation());
@@ -580,12 +530,12 @@
         return Boolean.valueOf(text);
     }    
 	
-	Column getColumn(String columnName, Table table) throws ParseException {
+	Column getColumn(String columnName, Table table) throws MetadataException {
 		Column c = table.getColumnByName(columnName);
 		if (c != null) {
 			return c;
 		}
-		throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_column", columnName, table.getName())); //$NON-NLS-1$
+		throw new MetadataException(QueryPlugin.Util.getString("SQLParser.no_column", columnName, table.getName())); //$NON-NLS-1$
 	}
 	
 	void createDDLTrigger(MetadataFactory schema, AlterTrigger trigger) {
@@ -603,9 +553,8 @@
 		}
 	}
 	
-	BaseColumn addProcColumn(MetadataFactory factory, Procedure proc, String name, ParsedDataType type, boolean rs) throws ParseException{
+	BaseColumn addProcColumn(MetadataFactory factory, Procedure proc, String name, ParsedDataType type, boolean rs) throws MetadataException {
 		try {
-			name = validateElementName(name);
 			BaseColumn column = null;
 			if (rs) {
 				column = factory.addProcedureResultSetColumn(name, type.type, proc);
@@ -615,7 +564,7 @@
 					if (pp.getType() == Type.ReturnValue) {
 						added = true;
 						if (pp.getDatatype() != factory.getDataTypes().get(type.type)) {
-							throw new ParseException(QueryPlugin.Util.getString("SQLParser.proc_type_conflict", proc.getName(), pp.getDatatype(), type.type)); //$NON-NLS-1$
+							throw new MetadataException(QueryPlugin.Util.getString("SQLParser.proc_type_conflict", proc.getName(), pp.getDatatype(), type.type)); //$NON-NLS-1$
 						}
 					}
 				}
@@ -626,7 +575,7 @@
 			setTypeInfo(type, column);
 			return column;
 		} catch (TranslatorException e){
-			throw new ParseException(e.getMessage());
+			throw new MetadataException(e.getMessage());
 		}	
 	}
 
@@ -655,7 +604,7 @@
 	 	return key;
 	}
 	
-	KeyRecord addFBI(MetadataFactory factory, List<Expression> expressions, Table table, String name) throws ParseException {
+	KeyRecord addFBI(MetadataFactory factory, List<Expression> expressions, Table table, String name) throws MetadataException {
 		List<String> columnNames = new ArrayList<String>(expressions.size());
 		List<Boolean> nonColumnExpressions = new ArrayList<Boolean>(expressions.size());
 		boolean fbi = false;
@@ -674,7 +623,7 @@
 			table.addAttchment(MetadataFactory.class, factory);
 	    	return factory.addFunctionBasedIndex(name != null?name:(SQLConstants.NonReserved.INDEX+(fbi?table.getFunctionBasedIndexes().size():table.getIndexes().size())), columnNames, nonColumnExpressions, table);
 	    }catch(TranslatorException e){
-			throw new ParseException(e.getMessage());
+			throw new MetadataException(e.getMessage());
 		}
 	}
 	

Added: trunk/engine/src/main/java/org/teiid/query/parser/TeiidSQLParserTokenManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/TeiidSQLParserTokenManager.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/parser/TeiidSQLParserTokenManager.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.parser;
+
+import java.io.IOException;
+
+/**
+ * A customized TokenManager to keep a token history and to treat lexical errors as invalid single character tokens
+ */
+class TeiidSQLParserTokenManager extends SQLParserTokenManager {
+
+	int tokenCount = 0;
+	Token head;
+	
+	public TeiidSQLParserTokenManager(JavaCharStream stream) {
+		super(stream);
+	}
+	
+	void reinit() {
+		tokenCount = 0;
+		head = null;
+	}
+	
+	@Override
+	public Token getNextToken() {
+		try {
+			Token t = super.getNextToken();
+			//if we're in the default lex state, keep track of a history of tokens
+			//this logic is not perfect as deep lookaheads can ruin the positioning
+			if (tokenCount == 0) {
+				head = t;
+			}
+			tokenCount++;
+			if (tokenCount > 10) {
+				head = head.next;
+			}
+			return t;
+		} catch (TokenMgrError err) {
+			Token t = new Token();
+			t.kind = -1;
+			t.beginColumn = this.input_stream.getBeginColumn();
+			t.beginLine = this.input_stream.getBeginLine();
+			t.endColumn = t.beginColumn+1;
+			t.endLine = t.beginLine;
+			t.image = new String(this.input_stream.buffer, this.input_stream.bufpos+1, 1);
+			try {
+				//mark the char a consumed
+				this.input_stream.readChar();
+			} catch (IOException e) {
+			}
+			return t;
+		}
+	}
+
+}


Property changes on: trunk/engine/src/main/java/org/teiid/query/parser/TeiidSQLParserTokenManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2012-09-29 19:07:41 UTC (rev 4488)
@@ -576,13 +576,17 @@
 description=Partial or full name of a single entity.
 example={code:sql}tbl.col{code}\n{code:sql}"tbl"."col"{code}
 */
-String id() :
+String id(Boolean validate) :
 {
 }
 {
   	(<ID>|nonReserved())
   	{
-  		return normalizeId(getToken(0).image);
+  		String id = normalizeId(getToken(0).image);
+  		if (validate != null) {
+  			return validateName(id, validate);
+  		}
+  		return id;
   	}
 }
 
@@ -637,7 +641,7 @@
   	
 }
 {
-	<CREATE> <TRIGGER> <ON> target = id() <INSTEAD> <OF> 
+	<CREATE> <TRIGGER> <ON> target = id(null) <INSTEAD> <OF> 
 	(event = <INSERT> | event = <UPDATE> | event = <DELETE>) 
 	<AS> triggerAction = forEachRowTriggerAction(info)
 	{
@@ -668,7 +672,7 @@
 {
 	<ALTER>
 	(
-	 	(<VIEW> target = id() <AS> { comment = getToken(1).specialToken; } command = queryExpression(info)) 
+	 	(<VIEW> target = id(null) <AS> { comment = getToken(1).specialToken; } command = queryExpression(info)) 
 	 	{
 	 	    if (comment != null) {
 		 	    command.setCacheHint(getQueryCacheOption(comment.image));
@@ -678,7 +682,7 @@
 	 		alterView.setDefinition(command);
 	 		return alterView;	
 	 	}
-		| (<PROCEDURE> target = id() <AS> { comment = getToken(1).specialToken; } stmt = statement(info)) 
+		| (<PROCEDURE> target = id(null) <AS> { comment = getToken(1).specialToken; } stmt = statement(info)) 
 		{
 			CreateProcedureCommand cup = new CreateProcedureCommand(asBlock(stmt));
 			if (comment != null) {
@@ -689,7 +693,7 @@
 			alterProc.setDefinition(cup);
 			return alterProc;
 		}
-		| (<TRIGGER> <ON> target = id() <INSTEAD> <OF> 
+		| (<TRIGGER> <ON> target = id(null) <INSTEAD> <OF> 
 		  (event = <INSERT> | event = <UPDATE> | event = <DELETE>) 
 		  ((<AS> triggerAction = forEachRowTriggerAction(info))
 		  |<ENABLED> {enabled=true;}| <DISABLED> {enabled=false;}))
@@ -796,7 +800,7 @@
 }
 {
 	<DROP> <TABLE> 
-	table = id()
+	table = id(null)
 	{
 		drop.setTable(new GroupSymbol(table));
 		return drop;
@@ -814,11 +818,11 @@
 	String table = null;
 	String pkId = null;
 	Column col = null;
-	List<String> columnNames = null;
+	List<ElementSymbol> pk = null;
 }
 {
 	<CREATE> <LOCAL> <TEMPORARY> <TABLE> 
-	table = id()
+	table = id(null)
 	<LPAREN>
 	{
 		create.setTable(new GroupSymbol(table));
@@ -834,11 +838,9 @@
       }
     )*	
 	[<COMMA> <PRIMARY> <KEY> 
-	  columnNames = getColumnNames()
+	  pk = columnList(true, true)
 	  {
-	  	for (String id : columnNames) {
-	  		create.getPrimaryKey().add(new ElementSymbol(validateElementName(id)));
-	  	}
+	  	create.getPrimaryKey().addAll(pk);
 	  }	  
 	]
 	<RPAREN>
@@ -861,7 +863,7 @@
 	boolean notNull = false;
 }
 {
-	 element = id()
+	 element = id(Boolean.TRUE)
 	 (
 	  type = parseDataType()
 	  |
@@ -875,7 +877,7 @@
 	 [<NOT> <NULL> { notNull = true; }]
 	 {
 	    Column c = new Column();
-	    c.setName(validateElementName(element));
+	    c.setName(element);
 	    c.setRuntimeType(type.type);
 	    c.setAutoIncremented(autoIncrement);
 	    c.setNullType(notNull?NullType.No_Nulls:NullType.Nullable);
@@ -933,7 +935,7 @@
 	Expression ex;
 }
 {
-	id = id() {return new ElementSymbol(id);}
+	id = id(null) {return new ElementSymbol(id);}
 	|
 	ex = exception(info)
 	{
@@ -982,7 +984,7 @@
 }
 {
     (
-	 LOOKAHEAD(2) ([label = id() <COLON>] 
+	 LOOKAHEAD(2) ([label = id(null) <COLON>] 
 	  (
 	   stmt = loopStatement(info) |
 	   stmt = whileStatement(info) |
@@ -1047,7 +1049,7 @@
 	    block.addStatement(stmt, false);            	                	    
 	  }
  	)*
- 	[<EXCEPTION> eId = id() {block.setExceptionGroup(validateAlias(eId));}
+ 	[<EXCEPTION> eId = id(Boolean.FALSE) {block.setExceptionGroup(eId);}
  	 (
        stmt = statement(info)
        {          
@@ -1078,10 +1080,10 @@
 {
  	(
  	 (
- 	  (mode = <BREAK> | mode = <CONTINUE>) [label = id()] 
+ 	  (mode = <BREAK> | mode = <CONTINUE>) [label = id(null)] 
  	 )
  	 | 
- 	 (mode = <LEAVE> label = id())
+ 	 (mode = <LEAVE> label = id(null))
  	)
  	{
  	    breakStmt.setMode(BranchingStatement.BranchingMode.valueOf(mode.image.toUpperCase()));
@@ -1132,7 +1134,7 @@
     query = queryExpression(info)
     <RPAREN>
     <AS>
-    cursor = id()
+    cursor = id(null)
     stmt = statement(info)
     {
         loopStmt = new LoopStatement(asBlock(stmt), query, cursor);   
@@ -1183,7 +1185,7 @@
 {
     <DECLARE>
     (type = parseDataType() | <EXCEPTION> {type = new ParsedDataType(getToken(0).image);})
-    var = id()
+    var = id(null)
     {
         variableID = new ElementSymbol(var);
     }
@@ -1215,7 +1217,7 @@
     boolean returnable=true;
 }
 {
-    var = id()
+    var = id(null)
     {
         elementID = new ElementSymbol(var);              
     } 
@@ -1355,7 +1357,7 @@
 	elements = createElementsWithTypes(info)
 
 	 [<INTO>
-      groupID = id()
+      groupID = id(null)
       {
          group = new GroupSymbol(groupID);
       }
@@ -1402,21 +1404,19 @@
 	Expression value = null;
 }
 {
-	element = id()
+	element = id(shortName?Boolean.TRUE:null)
     <EQ>
     value = expression(info)
     {
-    	String symbolName = shortName?validateElementName(element):element;
-        ElementSymbol symbol = new ElementSymbol(symbolName);
+        ElementSymbol symbol = new ElementSymbol(element);
         using.addClause(symbol, value);
     }
 	(<COMMA>
-	 element = id()
+	 element = id(null)
      <EQ>
      value = expression(info)
      {
-	      symbolName = shortName?validateElementName(element):element;
-          symbol = new ElementSymbol(symbolName);
+     	  symbol = new ElementSymbol(element);
           using.addClause(symbol, value);
      }
 	)*
@@ -1437,17 +1437,17 @@
 	List<TableFunctionReference.ProjectedColumn> elements = new ArrayList<TableFunctionReference.ProjectedColumn>();
 }
 {
-	 element = id()
+	 element = id(Boolean.TRUE)
 	 type = parseDataType()
 	 {
-	    TableFunctionReference.ProjectedColumn symbol = new TableFunctionReference.ProjectedColumn(validateElementName(element), type.type);
+	    TableFunctionReference.ProjectedColumn symbol = new TableFunctionReference.ProjectedColumn(element, type.type);
 		elements.add(symbol);
 	 }
 	 (LOOKAHEAD(2) <COMMA>
-		element = id()
+		element = id(Boolean.TRUE)
 		type = parseDataType()
 		{
-	      symbol = new TableFunctionReference.ProjectedColumn(validateElementName(element), type.type);
+	      symbol = new TableFunctionReference.ProjectedColumn(element, type.type);
 		  elements.add(symbol);
 		}
 	 )*
@@ -1481,7 +1481,7 @@
 	   storedProcedure.setCalledWithReturn(true);
 	 }
 	]
-	<CALL> procName = id()
+	<CALL> procName = id(null)
 	{
 		storedProcedure.setProcedureName(procName);
 	}
@@ -1519,7 +1519,7 @@
 {
 	(
 		(<EXEC> | <EXECUTE> | <CALL>)
-		procName = id()
+		procName = id(null)
 		{
 			storedProcedure.setProcedureName(procName);
 		}
@@ -1561,7 +1561,7 @@
 	{
 		storedProcedure.setDisplayNamedParameters(true);
 	}
-	(name=id()
+	(name=id(null)
 	 <EQ> [<GT>]
 	 value = expression(info)
 		{
@@ -1572,7 +1572,7 @@
 			parameter = null;
 		}
 		(	<COMMA>
-		 	name=id()
+		 	name=id(null)
 	 		<EQ> [<GT>]
 	 		value = expression(info)
 			{
@@ -1602,9 +1602,9 @@
 }
 {
 	<INSERT> <INTO>
-	group = id()
+	group = id(null)
 
-	[LOOKAHEAD(<LPAREN> id()) columns = columnList(false) {
+	[LOOKAHEAD(<LPAREN> id(null)) columns = columnList(false, true) {
 	  insert.setVariables(columns);
 	}]
 
@@ -1640,40 +1640,6 @@
 }
 
 /*
-name=column list
-description=A list of column references.
-example={code:sql}(col1, col2, ...){code}
-*/
-List<ElementSymbol> columnList(boolean validate) :
-{
-	String element = null;
-	List<ElementSymbol> symbols = new LinkedList<ElementSymbol>();
-}
-{
-   <LPAREN>
-	element = id()
-	{
-		if (validate) {
-			element = validateElementName(element);
-		}
-		symbols.add(new ElementSymbol(element));
-	}
-	(	<COMMA>
-		element = id()
-		{
-			if (validate) {
-				element = validateElementName(element);
-			}
-			symbols.add(new ElementSymbol(element));
-		}
-	)*
-	<RPAREN>
-	{
-		return symbols;
-	}
-}
-
-/*
 name=expression list
 description=A list of expressions.
 example={code:sql}col1, 'a', ...{code}
@@ -1714,7 +1680,7 @@
 }
 {
 	<UPDATE>
-	group = id()
+	group = id(null)
 	<SET>
 	setClauseList = setClauseList(false, info)
 	{
@@ -1753,7 +1719,7 @@
 }
 {
 	<DELETE> <FROM>
-	group = id()
+	group = id(null)
 	[criteria = where(info)]
 	[option = option(info)
 	  {
@@ -1811,11 +1777,11 @@
    QueryCommand queryExpression = null;
 }
 {
-	name = id()
-	[ columns = columnList(true)] 
+	name = id(Boolean.FALSE)
+	[ columns = columnList(true, true)] 
 	<AS> <LPAREN> queryExpression = queryExpression(info) <RPAREN>
 	{
-	    return new WithQueryCommand(new GroupSymbol(validateAlias(name)), columns, queryExpression);
+	    return new WithQueryCommand(new GroupSymbol(name), columns, queryExpression);
 	}
 }
 
@@ -1891,7 +1857,7 @@
 {
     (
         query=query(info) | 
-        (<TABLE> name=id() {
+        (<TABLE> name=id(null) {
            Query q = new Query();
            q.setSelect(new Select(Arrays.asList(new MultipleElementSymbol())));
            q.setFrom(new From(Arrays.asList(new UnaryFromClause(new GroupSymbol(name)))));
@@ -1953,7 +1919,7 @@
 }
 {	
 	<INTO>
-	(groupID=id())
+	(groupID=id(null))
 	{
     	into = new Into(new GroupSymbol(groupID));
 		return into;
@@ -2025,11 +1991,10 @@
 	(	
 		// Expression
 		expression=expression(info)	
-		[[<AS>] alias=id() ]
+		[[<AS>] alias=id(Boolean.FALSE) ]
 	)
 	{		
 		if(alias != null) {
-			alias = validateAlias(alias); 
 			return new AliasSymbol(alias, expression);
 		}
 		return expression;
@@ -2050,12 +2015,9 @@
 	(	
 		// Expression
 		expression=expression(info)	
-		[<AS> alias=id() ]
+		[<AS> alias=id(Boolean.FALSE) ]
 	)
 	{		
-		if(alias != null) {
-			alias = validateAlias(alias); 
-		}
 		return new DerivedColumn(alias, expression);
 	}
 }
@@ -2143,7 +2105,7 @@
 	]	
 	[
 	  <ENCODING>
-	  encoding = id() 
+	  encoding = id(null) 
 	]
 	[
 		orderBy = orderby(info)
@@ -2424,7 +2386,7 @@
 	[
 		<AS> (<STRING> | <VARCHAR> | <CLOB> | <VARBINARY> | <BLOB>) { t = getToken(0);}
 	]
-	[ <ENCODING> enc = id() ]
+	[ <ENCODING> enc = id(null) ]
 	[ <VERSION> ver = stringVal() ]
 	[ ( <INCLUDING> {declr = true;}| <EXCLUDING> {declr = false;}) <XMLDECLARATION> ]
 	<RPAREN>
@@ -2460,12 +2422,12 @@
  	<COLUMNS>
  	columns = createElementsWithTypes(info) 
  	<RPAREN>
- 	[<AS>] aliasID=id()
+ 	[<AS>] aliasID=id(Boolean.FALSE)
  	{
  		ArrayTable result = new ArrayTable();
  		result.setArrayValue(array);
  		result.setColumns(columns);
- 		result.setName(validateAlias(aliasID));
+ 		result.setName(aliasID);
  		return result;
  	}
 }
@@ -2537,7 +2499,7 @@
 	  skip = intVal()
 	]
  	<RPAREN>
- 	[<AS>] aliasID=id()
+ 	[<AS>] aliasID=id(Boolean.FALSE)
  	{
  		TextTable result = new TextTable();
  		result.setFile(file);
@@ -2546,7 +2508,7 @@
  		result.setEscape(escape);
  		result.setHeader(header);
  		result.setSkip(skip);
- 		result.setName(validateAlias(aliasID));
+ 		result.setName(aliasID);
  		result.setQuote(quote);
  		result.setUsingRowDelimiter(useRowDelimiter);
  		result.setSelector(selector);
@@ -2569,7 +2531,7 @@
 	Integer position = null;
 }
 {
-	name = id()
+	name = id(Boolean.TRUE)
 	datatype = parseDataType()
 	[ 
 	  	<WIDTH>
@@ -2587,7 +2549,7 @@
 	  	position = intVal() 
 	]
 	{
-		TextTable.TextColumn result = new TextTable.TextColumn(validateElementName(name), datatype.type, width, noTrim);
+		TextTable.TextColumn result = new TextTable.TextColumn(name, datatype.type, width, noTrim);
 		result.setSelector(selector);
 		result.setPosition(position);
 		return result;
@@ -2699,14 +2661,14 @@
       }
     )*
  	<RPAREN>
- 	[<AS>] aliasID=id()
+ 	[<AS>] aliasID=id(Boolean.FALSE)
  	{
  		ObjectTable result = new ObjectTable();
  		result.setScriptingLanguage(lang);
  		result.setRowScript(rowScript);
  		result.setPassing(passingValues);
  		result.setColumns(columns);
- 		result.setName(validateAlias(aliasID));
+ 		result.setName(aliasID);
  		return result;
  	}
 }
@@ -2724,7 +2686,7 @@
 	Expression defaultExpr = null;
 }
 {
-	name = id()
+	name = id(null)
     datatype = parseDataType()
 	path = stringVal()    
     [
@@ -2784,14 +2746,14 @@
  	  )*
  	]
  	<RPAREN>
- 	[<AS>] aliasID=id()
+ 	[<AS>] aliasID=id(Boolean.FALSE)
  	{
  		XMLTable result = new XMLTable();
  		result.setXquery(xquery);
  		result.setNamespaces(xmlNamespaces);
  		result.setPassing(passingValues);
  		result.setColumns(columns);
- 		result.setName(validateAlias(aliasID));
+ 		result.setName(aliasID);
  		return result;
  	}
 }
@@ -2809,7 +2771,7 @@
 	Expression defaultExpr = null;
 }
 {
-	name = id()
+	name = id(null)
 	
 	((
 	  <FOR> <ORDINALITY> 
@@ -2871,10 +2833,10 @@
       command = storedProcedure(info, 1) )
 	<RPAREN>
 	[<AS>]
-	aliasID = id()
+	aliasID = id(Boolean.FALSE)
 	
 	{
-		SubqueryFromClause clause = new SubqueryFromClause(validateAlias(aliasID), command);
+		SubqueryFromClause clause = new SubqueryFromClause(aliasID, command);
         setFromClauseOptions(lparen, clause);
         clause.setTable(table);
         return clause;
@@ -2895,10 +2857,10 @@
 	UnaryFromClause clause = null;
 }
 {	
-	(groupID=id() {groupToken = getToken(0);} [[<AS>] aliasID=id()])
+	(groupID=id(null) {groupToken = getToken(0);} [[<AS>] aliasID=id(Boolean.FALSE)])
 	{
     	if(aliasID != null) {		
-            group = new GroupSymbol(validateAlias(aliasID), groupID);
+            group = new GroupSymbol(aliasID, groupID);
         } else {
 			group = new GroupSymbol(groupID);
         }
@@ -3551,35 +3513,35 @@
 	<OPTION>
 	(
 		<MAKEDEP>		
-		id=id()
+		id=id(null)
 		{
             option.addDependentGroup(id);
 		}
 		(<COMMA>
-			id=id()
+			id=id(null)
 			{
                 option.addDependentGroup(id);
 	        }
 		)* |
 		<MAKENOTDEP>		
-		id=id()
+		id=id(null)
 		{
             option.addNotDependentGroup(id);
 		}
 		(<COMMA>
-			id=id()
+			id=id(null)
 			{
                 option.addNotDependentGroup(id);
 	        }
 		)* |
 		
 		nocache	= <NOCACHE>		
-		[id=id()
+		[id=id(null)
 		{
             option.addNoCacheGroup(id);
 		}
 		(<COMMA>
-			id=id()
+			id=id(null)
 			{
                 option.addNoCacheGroup(id);
 	        }
@@ -3844,7 +3806,11 @@
 	OrderBy orderBy = null;
 }
 {
-	<OVER> 
+	<OVER> { 
+	if (!(agg instanceof AggregateSymbol)) {
+	   		throw new ParseException(QueryPlugin.Util.getString("SQLParser.invalid_window", agg)); //$NON-NLS-1$
+    	}
+    }
     <LPAREN> 
     [<PARTITION> <BY> partitionList = expressionList(info)]
     [orderBy = orderby(info)]
@@ -3852,9 +3818,6 @@
     {
     	WindowFunction result = new WindowFunction();
     	WindowSpecification ws = new WindowSpecification();
-    	if (!(agg instanceof AggregateSymbol)) {
-	   		throw new ParseException(QueryPlugin.Util.getString("SQLParser.invalid_window", agg)); //$NON-NLS-1$
-    	}
     	result.setFunction((AggregateSymbol)agg);
     	ws.setPartition(partitionList);
     	ws.setOrderBy(orderBy);
@@ -4122,7 +4085,7 @@
 	| ( funcToken = <XMLPI>
 		<LPAREN>
 		(
-		 [LOOKAHEAD(1) <NAME>] literal = id()
+		 [LOOKAHEAD(1) <NAME>] literal = id(null)
 		)
 		{
 			args.add(new Constant(literal));	
@@ -4148,7 +4111,7 @@
 			return expression;
 		}
 	|   
-	(	funcName = id()
+	(	funcName = id(null)
 		<LPAREN>
 		[<ALL> { distinct = false; } | <DISTINCT> {distinct = true;} ]
 		[ args = expressionList(info) ]
@@ -4241,7 +4204,7 @@
 {
 	<XMLELEMENT> <LPAREN>
 	(
-	 [LOOKAHEAD(1) <NAME>] name = id()
+	 [LOOKAHEAD(1) <NAME>] name = id(null)
 	)
 	[
 		LOOKAHEAD(2) <COMMA> xmlNamespaces = xmlNamespaces(info)
@@ -4362,7 +4325,7 @@
 }
 {
 	(
-		uri = stringVal() <AS> prefix = id()
+		uri = stringVal() <AS> prefix = id(null)
 		{
 			return new XMLNamespaces.NamespaceItem(uri, prefix);
 		}
@@ -4602,9 +4565,9 @@
 	String prefix = null;
 }
 { 
-	<SET> <NAMESPACE> uri = stringVal() <AS> prefix = id()
+	<SET> <NAMESPACE> uri = stringVal() <AS> prefix = id(Boolean.FALSE)
 	{
-		factory.addNamespace(validateAlias(prefix), uri);
+		factory.addNamespace(prefix, uri);
 	}
 }
 
@@ -4627,12 +4590,12 @@
 {
 	<CREATE> [<VIRTUAL> | <FOREIGN> {virtual = false;}] (<PROCEDURE> | <FUNCTION> {function = true;})
 	//the below is optional beacuse to allow the designer based metadata
-	(	procName = id()
+	(	procName = id(null)
 		{
 			try {
 				proc = factory.addProcedure(procName);
 			} catch(TranslatorException e){
-				throw new ParseException(e.getMessage());
+				throw new MetadataException(e);
 			}		
 		}
 	
@@ -4660,7 +4623,7 @@
 			proc.setFunction(function);
 			if (stmt != null){
 			    if (function || !virtual) {
-			         throw new ParseException(QueryPlugin.Util.getString("SQLParser.function_def", procName));
+			         throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_def", procName));
 			    }
 				proc.setQueryPlan((comment != null?comment.image+" ":"") + stmt.toString());
 			}
@@ -4695,7 +4658,7 @@
 	 |(<OUT> {ppType = ProcedureParameter.Type.Out;})
 	 |(<INOUT> {ppType = ProcedureParameter.Type.InOut;})
 	 |(<VARIADIC> {ppType = ProcedureParameter.Type.In ; vararg = true;}))]
-	name = id()
+	name = id(Boolean.TRUE)
 	type = parseDataType()
 	[<NOT> <NULL> {notNull = true;}]
 	[<RESULT>
@@ -4708,7 +4671,7 @@
 	]
 	{
 		try {
-			param = factory.addProcedureParameter(validateElementName(name), type.type, ppType, proc);
+			param = factory.addProcedureParameter(name, type.type, ppType, proc);
 			setTypeInfo(type, param);
 			if (notNull) {
 				param.setNullType(Column.NullType.No_Nulls);
@@ -4717,7 +4680,7 @@
 				param.setVarArg(vararg);
 			}			
 		} catch (TranslatorException e){
-			throw new ParseException(e.getMessage());
+			throw new MetadataException(e);
 		}
 	}
 	[<DEFAULT_KEYWORD> defaultValue = stringVal() {param.setDefaultValue(defaultValue);}]
@@ -4741,7 +4704,7 @@
 	BaseColumn column = null; 
 }
 {
-      name = id()
+      name = id(Boolean.TRUE)
 	  type = parseDataType()
 	  {
 	  	column = addProcColumn(factory, proc, name, type, true);
@@ -4771,13 +4734,13 @@
 }
 {
 	<CREATE> (<FOREIGN> <TABLE> | [<VIRTUAL>] <VIEW> {view = true;}) 
-	tableName = id()
+	tableName = id(null)
 	{
 		try{
 		    table = factory.addTable(tableName);
 		    table.setVirtual(view);
 	    } catch(TranslatorException e){
-	    	throw new ParseException(e.getMessage());
+	    	throw new MetadataException(e);
 	    }
 	}
 	[<LPAREN>
@@ -4785,7 +4748,7 @@
     (LOOKAHEAD(3) <COMMA>
       createColumn(factory, table)
     )*	
-    (<COMMA>{name=null;} [<CONSTRAINT> name = id()] (constraint = primaryKey(factory, table, name) | constraint = constraint(factory, table, name, ParseInfo.DEFAULT_INSTANCE) | constraint = foreignKey(factory, table, name))
+    (<COMMA>{name=null;} [<CONSTRAINT> name = id(null)] (constraint = primaryKey(factory, table, name) | constraint = constraint(factory, table, name, ParseInfo.DEFAULT_INSTANCE) | constraint = foreignKey(factory, table, name))
        [optionsClause(constraint, factory)
 	   {
 	      setCommonProperties(constraint, constraint.getProperties());
@@ -4802,7 +4765,7 @@
 	{
 		if (query != null){
 		   if (!view) {
-     		   throw new ParseException(QueryPlugin.Util.getString("SQLParser.view_def", tableName));
+     		   throw new MetadataException(QueryPlugin.Util.getString("SQLParser.view_def", tableName));
 		   }
 		   table.setSelectTransformation((comment != null?comment.image+" ":"") + query.toString());	
 		}
@@ -4833,20 +4796,15 @@
 }
 {
 	<FOREIGN> <KEY>
-	columnNames = getColumnNames()
-    {
-	    for (String col: columnNames) {
-	    	column = getColumn(col, table);
-	    }  
-    }
+	columnNames = columnList(true, false)
     <REFERENCES>
-    viewName = id()
-    [pkColumnNames = getColumnNames()]
+    viewName = id(null)
+    [pkColumnNames = columnList(true, false)]
     {
 	    try{
 		    return factory.addForiegnKey(name != null?name:("FK"+table.getForeignKeys().size()), columnNames, pkColumnNames, viewName, table);   
 	    } catch (TranslatorException e){
-	    	throw new ParseException(e.getMessage());
+	    	throw new MetadataException(e);
 	    }
     }
 }
@@ -4864,18 +4822,15 @@
 }
 {
 	<PRIMARY> <KEY>
-	columnNames = getColumnNames()
+	columnNames = columnList(true, false)
     {
-	    for (String col: columnNames) {
-	    	column = getColumn(col, table);
-	    }
 	    if (table.getPrimaryKey() != null){
-	    	throw new ParseException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
+	    	throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
 	 	}
 	 	try{
 	 		return factory.addPrimaryKey(name!=null?name:"PK", columnNames, table);
 	 	} catch(TranslatorException e){
-	 		throw new ParseException(e.getMessage());
+	 		throw new MetadataException(e);
 	 	}
     }
 }
@@ -4896,11 +4851,8 @@
 }
 {
 	(( type = <UNIQUE> | type = <ACCESSPATTERN>)
-	columnNames = getColumnNames()	    
+	columnNames = columnList(true, false)	    
 	{
-	    for (String col: columnNames) {
-	    	column = getColumn(col, table);
-	    }
 	    try{
 			if (type.image.equalsIgnoreCase("UNIQUE")) { 
 	    		return factory.addIndex(name != null?name:("UNIQUE"+table.getUniqueKeys().size()), false, columnNames, table);
@@ -4908,7 +4860,7 @@
 	    		return factory.addAccessPattern(name != null?name:("AP"+table.getAccessPatterns().size()), columnNames, table);
 	    	}
     	}catch(TranslatorException e){
-    		throw new ParseException(e.getMessage());
+    		throw new MetadataException(e);
     	}	    
     }) | (
     type = <INDEX>
@@ -4922,24 +4874,32 @@
 }
 
 /*
-name=column name list
+name=column list
 description=A list of column names.
 example={code:sql}(a, b){code}
 */
-ArrayList<String> getColumnNames() :
+List columnList(boolean validate, boolean asElementSymbols) :
 {
-	ArrayList list = new ArrayList<String>();
+	ArrayList list = new ArrayList();
 	String id = null;
 }
 {
 	<LPAREN>
-	  id = id()
+	  id = id(validate?Boolean.TRUE:null)
 	  {
-	  	list.add(id);
+		if (asElementSymbols) {
+			list.add(new ElementSymbol(id));
+		} else {
+	  		list.add(id);
+	  	}
 	  }
-	  (<COMMA> id = id()
+	  (<COMMA> id = id(validate?Boolean.TRUE:null)
 	   {
-		list.add(id);
+		if (asElementSymbols) {
+			list.add(new ElementSymbol(id));
+		} else {
+	  		list.add(id);
+	  	}
 	   }
 	  )*
 	 <RPAREN> 
@@ -4968,17 +4928,17 @@
 	Token word = null;
 }
 {
-	 element = id()
+	 element = id(Boolean.TRUE)
 	 (
 	  type = parseDataType()
 	  {
 	  	try{
-    		column = factory.addColumn(validateElementName(element), type.type, table);
+    		column = factory.addColumn(element, type.type, table);
     		column.setUpdatable(true);
 		    setTypeInfo(type, column);		    	
     		columnName.add(element);
     	}catch(TranslatorException e){
-    		throw new ParseException(e.getMessage());
+    		throw new MetadataException(e);
     	}
 	  }
 	 )
@@ -5004,12 +4964,12 @@
 		 		factory.addIndex("UNIQUE"+table.getIndexes().size(), false, columnName, table);
 		 	} else if (pk) {
 		    	if (table.getPrimaryKey() != null) {
-		    		throw new ParseException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
+		    		throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
 		    	}
 		 		factory.addPrimaryKey("PK", columnName, table);
 		 	}
     	}catch(TranslatorException e){
-    		throw new ParseException(e.getMessage());
+    		throw new MetadataException(e);
     	}	 	
 	     	 	
 	    column.setAutoIncremented(autoIncrement);
@@ -5043,7 +5003,7 @@
 	String strVal = null;
 }
 {
-	 key = id()
+	 key = id(null)
 	 (value = nonNumericLiteral()
 	 | [strVal = plusMinus()] value = unsignedNumericLiteral(strVal))
 	 { 

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-09-29 19:07:41 UTC (rev 4488)
@@ -64,7 +64,7 @@
 # parser (005)
 TEIID31100=Parsing error: {0}
 QueryParser.nullSqlCrit=Parser cannot parse a null sql criteria.
-QueryParser.lexicalError=Lexical error: {0}
+QueryParser.lexicalError=Lexical error. Character is not a valid token: {0} 
 QueryParser.nullSqlExpr=Parser cannot parse a null sql expression.
 TEIID30378=Direct usage of XQuery is no longer supported, use XMLQUERY instead.
 
@@ -245,7 +245,6 @@
 ERR.015.009.0002= Error translating criteria on the user''s command, the criteria translated to {0} is not valid
 TEIID30373=Error simplifying mathematical expression: {0}
 
-SQLParser.Unknown_join_type=Unknown join type: {0}
 SQLParser.Aggregate_only_top_level=Aggregate functions are only allowed HAVING/SELECT/ORDER BY clauses.  Window functions are only allowed in the SELECT/ORDER BY clauses: {0}.  Both require a FROM clause to be present.
 SQLParser.window_only_top_level=Window functions are not allowed in the HAVING clause: {0}
 SQLParser.Unknown_agg_func=Unknown aggregate function: {0}
@@ -1032,6 +1031,7 @@
 TEIID31120=An exception may only be chained to another exception. {0} is not valid.
 TEIID31121=The expected result set of the procedure {0} does not match the result set from returnable statement {1} use WITHOUT RETURN to indicate the statement should not be returned - {2}
 TEIID31122=Null exception reference.
+TEIID31123=Could not load non-FOREIGN UDF "{0}", since both invocation class and invocation method are required.  
 
 SQLParser.proc_type_conflict=Result type {1} conflicts with return type {2} for procedure {0}
 SQLParser.param_out=Procedure {0} RESULT param {1} must be of type OUT.

Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -31,7 +31,6 @@
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.api.exception.query.QueryParserException;
 import org.teiid.metadata.*;
-import org.teiid.metadata.ParseException;
 import org.teiid.metadata.BaseColumn.NullType;
 import org.teiid.query.metadata.MetadataValidator;
 import org.teiid.query.metadata.SystemMetadata;
@@ -118,7 +117,7 @@
 		assertEquals("hello", e6.getDefaultValue());
 	}
 	
-	@Test(expected=ParseException.class)
+	@Test(expected=MetadataException.class)
 	public void testDuplicatePrimarykey() throws Exception {
 		String ddl = "CREATE FOREIGN TABLE G1( e1 integer primary key, e2 varchar primary key)";
 		MetadataStore mds = new MetadataStore();
@@ -216,7 +215,7 @@
 		assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
 	}	
 	
-	@Test(expected=ParseException.class)
+	@Test(expected=MetadataException.class)
 	public void testWrongPrimarykey() throws Exception {
 		String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, PRIMARY KEY (e3))";
 
@@ -341,7 +340,7 @@
 		assertEquals(fk.getPrimaryKey().getColumns(), s.getSchema("model").getTable("G1").getColumns());
 	}	
 	
-	@Test(expected=ParseException.class)
+	@Test(expected=MetadataException.class)
 	public void testTableWithPlan() throws Exception {
 		String ddl = "CREATE foreign table G1 as select 1";
 		MetadataStore mds = new MetadataStore();
@@ -515,7 +514,7 @@
 		assertEquals("boolean", fm.getInputParameters().get(0).getType());
 	}
 	
-	@Test(expected=ParseException.class) public void testInvalidFunctionBody() throws Exception {
+	@Test(expected=MetadataException.class) public void testInvalidFunctionBody() throws Exception {
 		String ddl = "CREATE FUNCTION SourceFunc(flag boolean) RETURNS varchar AS SELECT 'a';";
 
 		Schema s = helpParse(ddl, "model").getSchema();
@@ -524,7 +523,7 @@
 		assertTrue( fm.getInputParameters().get(0).isVarArg());
 	}
 	
-	@Test(expected=ParseException.class) public void testInvalidProcedureBody() throws Exception {
+	@Test(expected=MetadataException.class) public void testInvalidProcedureBody() throws Exception {
 		String ddl = "CREATE FOREIGN PROCEDURE SourceFunc(flag boolean) RETURNS varchar AS SELECT 'a';";
 
 		Schema s = helpParse(ddl, "model").getSchema();

Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2012-09-28 16:09:37 UTC (rev 4487)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2012-09-29 19:07:41 UTC (rev 4488)
@@ -2649,7 +2649,7 @@
 	}
 	
     @Test public void testLikeWithEscapeException(){
-        helpException("SELECT a from db.g where b like '#String' escape '#1'", "TEIID31100 Parsing error: TEIID30398 LIKE/SIMILAR TO ESCAPE value must be a single character: [#1].");  //$NON-NLS-1$ //$NON-NLS-2$
+        helpException("SELECT a from db.g where b like '#String' escape '#1'", "TEIID31100 Parsing error: Encountered \"like '#String' escape [*]'#1'[*] <EOF>\" at line 1, column 50.\nTEIID30398 LIKE/SIMILAR TO ESCAPE value must be a single character: [#1].");  //$NON-NLS-1$ //$NON-NLS-2$
     }   
 
 	/** SELECT "date"."time" from db.g */
@@ -2696,7 +2696,7 @@
 	
 	/** SELECT xx.yy%.a from xx.yy */
 	@Test public void testFailsWildcardInSelect(){
-		helpException("SELECT xx.yy%.a from xx.yy");		 //$NON-NLS-1$
+		helpException("SELECT xx.yy%.a from xx.yy", "TEIID31100 Parsing error: Encountered \"SELECT xx.yy [*]%[*] .\" at line 1, column 13.\nLexical error. Character is not a valid token: % ");		 //$NON-NLS-1$
 	}
 
 	/** SELECT a or b from g */
@@ -3236,7 +3236,7 @@
     
     //using clause should use short names
     @Test public void testDynamicCommandStatement3(){
-        helpException("create virtual procedure begin execute string z as a1 string, a2 integer into #g using variables.x=variables.y; end", "TEIID31100 Parsing error: Invalid simple identifier format: [variables.x]"); //$NON-NLS-1$ //$NON-NLS-2$       
+        helpException("create virtual procedure begin execute string z as a1 string, a2 integer into #g using variables.x=variables.y; end", "TEIID31100 Parsing error: Encountered \"into #g using [*]variables.x[*] =\" at line 1, column 88.\nInvalid simple identifier format: [variables.x]"); //$NON-NLS-1$ //$NON-NLS-2$       
     }
     
     //into clause requires as clause
@@ -4738,7 +4738,7 @@
         try {
             QueryParser.getQueryParser().parseCommand("SELECT FROM"); //$NON-NLS-1$
         } catch(QueryParserException e) {
-            assertTrue(e.getMessage().startsWith("TEIID31100 Parsing error: Encountered \"FROM\" at line 1, column 8.")); //$NON-NLS-1$
+            assertTrue(e.getMessage(), e.getMessage().startsWith("TEIID31100 Parsing error: Encountered \"SELECT [*]FROM[*]\" at line 1, column 8.")); //$NON-NLS-1$
         }
     }
     
@@ -4787,7 +4787,7 @@
     }
         
     @Test public void testCreateTempTable7() {
-        helpException("Create local TEMPORARY table tempTable (c1.x boolean, c2 byte)" ,"TEIID31100 Parsing error: Invalid simple identifier format: [c1.x]"); //$NON-NLS-1$ //$NON-NLS-2$ 
+        helpException("Create local TEMPORARY table tempTable (c1.x boolean, c2 byte)" ,"TEIID31100 Parsing error: Encountered \"table tempTable ( [*]c1.x[*] boolean\" at line 1, column 41.\nInvalid simple identifier format: [c1.x]"); //$NON-NLS-1$ //$NON-NLS-2$ 
     }
     
     @Test public void testCreateTempTableWithPrimaryKey() {
@@ -4833,7 +4833,7 @@
     @Test public void testBadAlias() {
         String sql = "select a as a.x from foo"; //$NON-NLS-1$
         
-        helpException(sql, "TEIID31100 Parsing error: Invalid alias format: [a.x]"); //$NON-NLS-1$
+        helpException(sql, "TEIID31100 Parsing error: Encountered \"select a as [*]a.x[*] from\" at line 1, column 13.\nInvalid alias format: [a.x]"); //$NON-NLS-1$
     }
     
     @Test public void testNameSpacedFunctionName() {



More information about the teiid-commits mailing list