[teiid-commits] teiid SVN: r3995 - in trunk/engine/src/main: javacc/org/teiid/query/parser and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Apr 11 16:36:56 EDT 2012


Author: shawkins
Date: 2012-04-11 16:36:55 -0400 (Wed, 11 Apr 2012)
New Revision: 3995

Modified:
   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
Log:
TEIID-1280 removing the possibility for now of dealing with default namespace concepts and externalizing messages

Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2012-04-11 18:52:57 UTC (rev 3994)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2012-04-11 20:36:55 UTC (rev 3995)
@@ -531,13 +531,13 @@
         return Boolean.valueOf(text);
     }    
 	
-	Column getColumn(String columnName, Table table) {
+	Column getColumn(String columnName, Table table) throws ParseException {
 		for (Column col:table.getColumns()) {
 			if (col.getName().equalsIgnoreCase(columnName)) {
 				return col;
 			}
 		}
-		return null;
+		throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_column", columnName, table.getName())); //$NON-NLS-1$
 	}
 	
 	void createDDLTrigger(MetadataFactory schema, AlterTrigger trigger) {

Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2012-04-11 18:52:57 UTC (rev 3994)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2012-04-11 20:36:55 UTC (rev 3995)
@@ -4094,12 +4094,13 @@
 
 void createNameSpace(MetadataFactory factory) :
 {
-	XMLNamespaces.NamespaceItem item = null; 
+	String uri = null;
+	String prefix = null;
 }
 { 
-	<SET> nonReserved ("NAMESPACE") item = namespaceItem()
+	<SET> nonReserved ("NAMESPACE") uri = stringVal() <AS> prefix = id()
 	{
-		factory.addNamespace(item.getPrefix(), item.getUri());
+		factory.addNamespace(prefix, uri);
 	}
 }
 
@@ -4130,11 +4131,11 @@
 		}
 	
 		<LPAREN>
-		[readProcedureParameter(factory, proc)]
-		(<COMMA> readProcedureParameter(factory, proc))*	
+		[procedureParameter(factory, proc)]
+		(<COMMA> procedureParameter(factory, proc))*	
 		<RPAREN>
 		
-		<RETURNS> (readProcedureReturn(factory, proc) | returnDataType = parseDataType())
+		<RETURNS> (procedureReturn(factory, proc) | returnDataType = parseDataType())
 		
 	    [ optionsClause(proc, factory)
 		   {
@@ -4151,7 +4152,7 @@
 			}
 			
 			if (virtual && !function && stmt == null){
-				throw new ParseException("Virtual procedure " + procName + " must define the procedure block after 'AS' keyword");
+				throw new ParseException(QueryPlugin.Util.getString("SQLParser.virtual_proc_def", procName));
 			}
 			
 	        if (returnDataType != null){
@@ -4161,35 +4162,20 @@
 		}
 }
 
-void readProcedureParameter(MetadataFactory factory, Procedure proc) :
+void procedureParameter(MetadataFactory factory, Procedure proc) :
 {
 	String name = null;
 	ParsedDataType type = null;
-	Token direction = null;
+	ProcedureParameter.Type ppType = ProcedureParameter.Type.In;
 	ProcedureParameter param = null;
 }
 {
-	[((direction = <IN>)|(direction=<OUT>)|(direction=<INOUT>))]
+	[((<IN> {ppType = ProcedureParameter.Type.In ;})
+	 |(<OUT> {ppType = ProcedureParameter.Type.Out;})
+	 |(<INOUT> {ppType = ProcedureParameter.Type.InOut;}))]
 	name = id()
 	type = parseDataType()
 	{
-		ProcedureParameter.Type ppType = ProcedureParameter.Type.In;
-		
-		if (direction == null){
-			ppType = ProcedureParameter.Type.In;
-		}
-		else if (direction.image.equalsIgnoreCase("in")){
-			ppType = ProcedureParameter.Type.In ;
-		}
-		else if (direction.image.equalsIgnoreCase("out")){
-			ppType = ProcedureParameter.Type.Out;
-		}
-		else if (direction.image.equalsIgnoreCase("inout")){
-			ppType = ProcedureParameter.Type.InOut;
-		}
-		else {
-			throw new ParseException("Unknown type of parameter on procedure "+ proc.getName());
-		}
 		try {
 			param = factory.addProcedureParameter(name, type.type, ppType, proc);
 			if (type.length != null){
@@ -4207,7 +4193,7 @@
 	}	
 }
 
-void readProcedureReturn(MetadataFactory factory, Procedure proc) :
+void procedureReturn(MetadataFactory factory, Procedure proc) :
 {
 	String name = null;
 	ParsedDataType type = null;
@@ -4252,9 +4238,9 @@
     (LOOKAHEAD(2) <COMMA>
       createColumn(factory, table)
     )*	
-    [<CONSTRAINT> (readPrimaryKeys(factory, table) | readConstraints(factory, table) | readForeignKeys(factory, table))
+    [<CONSTRAINT> (primaryKeys(factory, table) | constraints(factory, table) | foreignKeys(factory, table))
         (<COMMA>
-         (readConstraints(factory, table)|readForeignKeys(factory, table))
+         (primaryKeys(factory, table) | constraints(factory, table)|foreignKeys(factory, table))
         )*
     ]    
     <RPAREN>]    
@@ -4265,17 +4251,16 @@
 	]
 	[<AS> query = queryExpression(new ParseInfo())]
 	{
-		if (view && query == null){
-			throw new ParseException("View definition must have query plan defined");
-		}
-		
 		if (view){
-			table.setSelectTransformation(query.toString());
-		}
+		   if (query == null) {
+		      throw new ParseException(QueryPlugin.Util.getString("SQLParser.view_def", tableName));
+		   }
+		   table.setSelectTransformation(query.toString());	
+		}		
 	}
 }
 
-void readForeignKeys(MetadataFactory factory, Table table) :
+void foreignKeys(MetadataFactory factory, Table table) :
 {
 	List<String> columnNames = null;
 	String viewName = null;
@@ -4290,9 +4275,6 @@
     {
 	    for (String col: columnNames) {
 	    	column = getColumn(col, table);
-	    	if (column == null) {
-	    		throw new ParseException("Column name "+ col + " not found in table "+ table.getName());
-	    	}
 	    }  
     }
     <REFERENCES>
@@ -4307,7 +4289,7 @@
     }
 }
 
-void readPrimaryKeys(MetadataFactory factory, Table table) :
+void primaryKeys(MetadataFactory factory, Table table) :
 {
 	List<String> columnNames = null;
 	Column column = null;
@@ -4318,12 +4300,9 @@
     	columnNames = getColumnNames();
 	    for (String col: columnNames) {
 	    	column = getColumn(col, table);
-	    	if (column == null) {
-	    		throw new ParseException("Column name "+ col + " not found in table "+ table.getName());
-	    	}
 	    }
 	    if (table.getPrimaryKey() != null){
-	    	throw new ParseException("Primary Key is already defined on "+ table.getName());
+	    	throw new ParseException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
 	 	}
 	 	try{
 	 		factory.addPrimaryKey("PK", columnNames, table);
@@ -4333,7 +4312,7 @@
     }
 }
 
-void readConstraints(MetadataFactory factory, Table table) :
+void constraints(MetadataFactory factory, Table table) :
 {
 	KeyRecord keyrecord = null;
 	Column column = null;
@@ -4346,9 +4325,6 @@
 	    columnNames = getColumnNames();	    
 	    for (String col: columnNames) {
 	    	column = getColumn(col, table);
-	    	if (column == null) {
-	    		throw new ParseException("Column name "+ col + " not found in table "+ table.getName());
-	    	}
 	    }
 	    try{
 	    	if (type.equalsIgnoreCase("INDEX")) { 
@@ -4450,7 +4426,7 @@
 		 	
 		    if (pk) {
 		    	if (table.getPrimaryKey() != null) {
-		    		throw new ParseException("Primary Key is already defined on "+ table.getName());
+		    		throw new ParseException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
 		    	}
 		 		factory.addPrimaryKey(element, columnName, table);
 		 	}

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-04-11 18:52:57 UTC (rev 3994)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-04-11 20:36:55 UTC (rev 3995)
@@ -275,6 +275,10 @@
 SQLParser.Invalid_char={0} value must be a single character: [{1}].
 SQLParser.expected_non_reserved=Expected non-reserved word {0}, but was {1}.
 SQLParser.invalid_window=Cannot window a non-aggregate expression {0}.
+SQLParser.virtual_proc_def=Virtual procedure {0} must define the procedure block after 'AS' keyword
+SQLParser.view_def=Virtual view {0} must be defined with a query expression.
+SQLParser.pk_exists=Primary Key is already defined on {0}
+SQLParser.no_column=Column name {0} not found on table {1}
 SystemSource.array_length_desc=Get the length of the given array value
 SystemSource.array_param1=Array
 SystemSource.array_length_result=The array length



More information about the teiid-commits mailing list