[teiid-commits] teiid SVN: r4404 - in trunk: engine/src/main/java/org/teiid/query/validator and 4 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Sep 6 10:20:34 EDT 2012
Author: shawkins
Date: 2012-09-06 10:20:33 -0400 (Thu, 06 Sep 2012)
New Revision: 4404
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected
trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected
Log:
TEIID-2166 corrected for multi-column and added pg_class/attribute entries for indexes
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -49,6 +49,10 @@
this.groupingColsUsed = groupingColsUsed;
}
+ public AggregateStopNavigator(LanguageVisitor visitor) {
+ super(visitor, PreOrPostOrderNavigator.PRE_ORDER, true);
+ }
+
public void visit(AggregateSymbol obj) {
// Visit aggregate symbol but do not dive into it's expression
preVisitVisitor(obj);
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -67,7 +67,6 @@
import org.teiid.query.sql.lang.ObjectTable.ObjectColumn;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
-import org.teiid.query.sql.navigator.PreOrPostOrderNavigator;
import org.teiid.query.sql.navigator.PreOrderNavigator;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.BranchingStatement;
@@ -85,6 +84,7 @@
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor.AggregateStopNavigator;
import org.teiid.query.validator.UpdateValidator.UpdateInfo;
import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
import org.teiid.translator.SourceSystemFunctions;
@@ -623,7 +623,8 @@
}
}
};
- PreOrPostOrderNavigator.doVisit(object, ecv, PreOrPostOrderNavigator.PRE_ORDER, true);
+ AggregateStopNavigator asn = new AggregateStopNavigator(ecv);
+ object.acceptVisitor(asn);
}
private void validateNoAggsInClause(LanguageObject clause) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -152,7 +152,21 @@
"false as atthasdef " + //$NON-NLS-1$
"FROM SYS.Columns as t1 LEFT OUTER JOIN " + //$NON-NLS-1$
"SYS.Tables st ON (st.Name = t1.TableName AND st.SchemaName = t1.SchemaName) LEFT OUTER JOIN " + //$NON-NLS-1$
- "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name";//$NON-NLS-1$
+ "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name " +//$NON-NLS-1$
+ "UNION ALL SELECT kc.OID + (SELECT MAX(oid) FROM SYS.Columns) as oid, " + //$NON-NLS-1$
+ "k.oid + (SELECT MAX(OID) FROM SYS.Tables) as attrelid, " + //$NON-NLS-1$
+ "t1.Name as attname, " + //$NON-NLS-1$
+ "pt.oid as atttypid," + //$NON-NLS-1$
+ "pt.typlen as attlen, " + //$NON-NLS-1$
+ "convert(kc.Position, short) as attnum, " + //$NON-NLS-1$
+ "(CASE WHEN (t1.DataType = 'bigdecimal' OR t1.DataType = 'biginteger' OR t1.DataType = 'float' OR t1.DataType='double') THEN (4+(65536*t1.Precision)+t1.Scale) " + //$NON-NLS-1$
+ "ELSE (4+t1.Length) END) as atttypmod, " + //$NON-NLS-1$
+ "CASE WHEN (t1.NullType = 'No Nulls') THEN true ELSE false END as attnotnull, " + //$NON-NLS-1$
+ "false as attisdropped, " + //$NON-NLS-1$
+ "false as atthasdef " + //$NON-NLS-1$
+ "FROM (SYS.Keys as k INNER JOIN SYS.KeyColumns as kc ON k.uid = kc.uid INNER JOIN SYS.Columns as t1 ON kc.SchemaName = t1.SchemaName AND kc.TableName = t1.TableName AND kc.Name = t1.Name INNER JOIN " + //$NON-NLS-1$
+ "SYS.Tables as st ON st.Name = t1.TableName AND st.SchemaName = t1.SchemaName) LEFT OUTER JOIN " + //$NON-NLS-1$
+ "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
@@ -200,7 +214,15 @@
"0 as relpages, " + //$NON-NLS-1$
"false as relhasrules, " + //$NON-NLS-1$
"false as relhasoids " + //$NON-NLS-1$
- "FROM SYS.Tables t1"; //$NON-NLS-1$
+ "FROM SYS.Tables t1 UNION ALL SELECT t1.OID + (SELECT MAX(oid) as max from sys.tables) as oid, t1.name as relname, " + //$NON-NLS-1$
+ "(SELECT OID FROM SYS.Schemas WHERE Name = t1.SchemaName) as relnamespace, " + //$NON-NLS-1$
+ "convert('i', char) as relkind," + //$NON-NLS-1$
+ "0 as relam, " + //$NON-NLS-1$
+ "convert(0, float) as reltuples, " + //$NON-NLS-1$
+ "0 as relpages, " + //$NON-NLS-1$
+ "false as relhasrules, " + //$NON-NLS-1$
+ "false as relhasoids " + //$NON-NLS-1$
+ "FROM SYS.Keys t1 WHERE t1.type in ('Primary', 'Unique', 'Index')"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
@@ -235,16 +257,16 @@
addPrimaryKey("pk_pg_index", Arrays.asList("oid"), t); //$NON-NLS-1$ //$NON-NLS-2$
- String transformation = "SELECT min(t1.OID) as oid, " + //$NON-NLS-1$
- "min(t1.OID) as indexrelid, " + //$NON-NLS-1$
+ String transformation = "SELECT k.oid as oid, " + //$NON-NLS-1$
+ "k.oid + (SELECT MAX(oid) as max from sys.tables) as indexrelid, " + //$NON-NLS-1$
"(SELECT OID FROM SYS.Tables WHERE SchemaName = t1.SchemaName AND Name = t1.TableName) as indrelid, " + //$NON-NLS-1$
"cast(count(t1.OID) as short) as indnatts, " + //$NON-NLS-1$
"false indisclustered, " + //$NON-NLS-1$
- "(CASE t1.KeyType WHEN 'Unique' THEN true ELSE false END) as indisunique, " + //$NON-NLS-1$
+ "(CASE WHEN t1.KeyType in ('Unique', 'Primary') THEN true ELSE false END) as indisunique, " + //$NON-NLS-1$
"(CASE t1.KeyType WHEN 'Primary' THEN true ELSE false END) as indisprimary, " + //$NON-NLS-1$
"'' as indexprs, asPGVector(" + //$NON-NLS-1$
arrayAgg("(select at.attnum FROM pg_attribute as at WHERE at.attname = t1.Name AND at.attrelid = (SELECT OID FROM SYS.Tables WHERE SchemaName = t1.SchemaName AND Name = t1.TableName))", "t1.position") +") as indkey " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "FROM SYS.KeyColumns as t1 GROUP BY t1.uid, t1.KeyType, t1.SchemaName, t1.TableName, t1.Name"; //$NON-NLS-1$
+ "FROM SYS.Keys as k, Sys.KeyColumns as t1 WHERE k.uid = t1.uid GROUP BY k.oid, t1.KeyType, t1.SchemaName, t1.TableName, t1.KeyName"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -2,7 +2,10 @@
import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
@@ -12,6 +15,7 @@
@SuppressWarnings("nls")
public class TestODBCSchema extends AbstractMMQueryTestCase {
private static final String VDB = "PartsSupplier"; //$NON-NLS-1$
+ private static FakeServer server;
public TestODBCSchema() {
// this is needed because the result files are generated
@@ -19,11 +23,24 @@
super.DELIMITER = "\t"; //$NON-NLS-1$
}
- @Before public void setUp() throws Exception {
- FakeServer server = new FakeServer(true);
+ @BeforeClass public static void oneTimeSetUp() throws Exception {
+ server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
- this.internalConnection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ @AfterClass public static void oneTimeTearDown() {
+ server.stop();
+ }
+
+ @Before public void setUp() throws Exception {
+ this.internalConnection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @After public void tearDown() throws Exception {
+ if (this.internalConnection != null) {
+ this.internalConnection.close();
+ }
+ }
@Test public void test_PG_AM() throws Exception {
execute("select * FROM pg_am"); //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -1,20 +1,20 @@
string short string string string
attname attnum relname nspname relname
-PART_ID 1 PARTSSUPPLIER.PARTS PartsSupplier PARTSSUPPLIER.PARTS
-SHIPPER_ID 1 PARTSSUPPLIER.SHIP_VIA PartsSupplier PARTSSUPPLIER.SHIP_VIA
-STATUS_ID 1 PARTSSUPPLIER.STATUS PartsSupplier PARTSSUPPLIER.STATUS
-SUPPLIER_ID 1 PARTSSUPPLIER.SUPPLIER PartsSupplier PARTSSUPPLIER.SUPPLIER
-SUPPLIER_ID 1 Columns PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
-PART_ID 1 DataTypes PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
-oid 1 ProcedureParams pg_catalog matpg_datatype
-name 1 Procedures pg_catalog matpg_datatype
-attname 1 Schemas pg_catalog matpg_relatt
-relname 1 Tables pg_catalog matpg_relatt
-nspname 1 VirtualDatabases pg_catalog matpg_relatt
-oid 1 matpg_datatype pg_catalog pg_attribute
-oid 1 matpg_relatt pg_catalog pg_class
-oid 1 pg_am pg_catalog pg_index
-oid 1 pg_attrdef pg_catalog pg_proc
+PART_ID 1 PK_PARTS PartsSupplier PARTSSUPPLIER.PARTS
+SHIPPER_ID 1 PK_SHIP_VIA PartsSupplier PARTSSUPPLIER.SHIP_VIA
+STATUS_ID 1 PK_STATUS PartsSupplier PARTSSUPPLIER.STATUS
+SUPPLIER_ID 1 PK_SUPPLIER PartsSupplier PARTSSUPPLIER.SUPPLIER
+SUPPLIER_ID 1 PK_SUPPLIER_PARTS PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
+oid 1 matpg_datatype_names pg_catalog matpg_datatype
+attname 1 pk_matpg_relatt_names pg_catalog matpg_relatt
+oid 1 pk_pg_attr pg_catalog pg_attribute
+oid 1 pk_pg_class pg_catalog pg_class
+oid 1 pk_pg_index pg_catalog pg_index
+oid 1 pk_pg_proc pg_catalog pg_proc
+PART_ID 2 PK_SUPPLIER_PARTS PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
+name 2 matpg_datatype_names pg_catalog matpg_datatype
+relname 2 pk_matpg_relatt_names pg_catalog matpg_relatt
+nspname 3 pk_matpg_relatt_names pg_catalog matpg_relatt
Row Count : 15
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
attname 12 PartsSupplier java.lang.String attname string pg_catalog pg_attribute 4000 4000 0 false true false false 1 true true false false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -255,7 +255,29 @@
253 31 usename 1043 -1 2 4004 false false false
254 31 usecreatedb 16 1 3 5 false false false
255 31 usesuper 16 1 4 5 false false false
-Row Count : 255
+256 32 PART_ID 1043 -1 1 8 true false false
+257 33 SHIPPER_ID 21 2 1 4 true false false
+258 34 STATUS_ID 21 2 1 4 true false false
+259 35 SUPPLIER_ID 1043 -1 1 14 true false false
+260 36 SUPPLIER_STATUS 21 2 1 4 false false false
+261 37 SUPPLIER_ID 1043 -1 1 14 true false false
+262 37 PART_ID 1043 -1 2 8 true false false
+263 38 PART_ID 1043 -1 1 8 true false false
+264 39 SUPPLIER_ID 1043 -1 1 14 true false false
+265 40 oid 23 4 1 8 false false false
+266 40 name 1043 -1 2 4004 false false false
+267 41 typname 1043 -1 1 4004 false false false
+268 41 oid 23 4 2 8 false false false
+269 42 attname 1043 -1 1 4004 false false false
+270 42 relname 1043 -1 2 4004 false false false
+271 42 nspname 1043 -1 3 4004 false false false
+272 43 attrelid 23 4 1 8 false false false
+273 43 attnum 21 2 2 6 false false false
+274 44 oid 23 4 1 8 false false false
+275 45 oid 23 4 1 8 false false false
+276 46 oid 23 4 1 8 false false false
+277 47 oid 23 4 1 8 false false false
+Row Count : 277
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_attribute 11 10 0 false false false false 1 true true true false
attrelid 4 PartsSupplier java.lang.Integer attrelid integer pg_catalog pg_attribute 11 10 0 false false false false 1 true true true false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -31,7 +31,20 @@
29 pg_trigger 4 v 0 0.0 0 false false
30 pg_type 4 v 0 0.0 0 false false
31 pg_user 4 v 0 0.0 0 false false
-Row Count : 31
+32 PK_PARTS 1 i 0 0.0 0 false false
+33 PK_SHIP_VIA 1 i 0 0.0 0 false false
+34 PK_STATUS 1 i 0 0.0 0 false false
+35 PK_SUPPLIER 1 i 0 0.0 0 false false
+37 PK_SUPPLIER_PARTS 1 i 0 0.0 0 false false
+40 matpg_datatype_names 4 i 0 0.0 0 false false
+41 matpg_datatype_ids 4 i 0 0.0 0 false false
+42 pk_matpg_relatt_names 4 i 0 0.0 0 false false
+43 idx_matpg_relatt_ids 4 i 0 0.0 0 false false
+44 pk_pg_attr 4 i 0 0.0 0 false false
+45 pk_pg_class 4 i 0 0.0 0 false false
+46 pk_pg_index 4 i 0 0.0 0 false false
+47 pk_pg_proc 4 i 0 0.0 0 false false
+Row Count : 44
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_class 11 10 0 false false false false 1 true true true false
relname 12 PartsSupplier java.lang.String relname string pg_catalog pg_class 4000 4000 0 false true false false 1 true true false false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -1,28 +1,22 @@
integer integer integer short boolean boolean boolean string short[]
oid indexrelid indrelid indnatts indisclustered indisunique indisprimary indexprs indkey
-1 1 1 1 false false true [1]
-2 2 2 1 false false true [1]
-3 3 3 1 false false true [1]
-4 4 4 1 false false true [1]
-5 5 4 1 false false false [3]
-6 6 5 1 false false true [1]
-7 7 5 1 false false true [2]
-8 8 5 1 false false false [2]
-9 9 5 1 false false false [1]
-10 10 19 1 false false true [1]
-11 11 19 1 false false true [3]
-12 12 19 1 false false false [2]
-13 13 19 1 false false false [1]
-14 14 20 1 false false true [3]
-15 15 20 1 false false true [4]
-16 16 20 1 false false true [5]
-17 17 20 1 false false false [1]
-18 18 20 1 false false false [2]
-19 19 23 1 false false true [1]
-20 20 24 1 false false true [1]
-21 21 26 1 false false true [1]
-22 22 28 1 false false true [1]
-Row Count : 22
+1 32 1 1 false true true [1]
+2 33 2 1 false true true [1]
+3 34 3 1 false true true [1]
+4 35 4 1 false true true [1]
+5 36 4 1 false false false [3]
+6 37 5 2 false true true [1, 2]
+7 38 5 1 false false false [2]
+8 39 5 1 false false false [1]
+9 40 19 2 false true true [1, 3]
+10 41 19 2 false false false [2, 1]
+11 42 20 3 false true true [3, 4, 5]
+12 43 20 2 false false false [1, 2]
+13 44 23 1 false true true [1]
+14 45 24 1 false true true [1]
+15 46 26 1 false true true [1]
+16 47 28 1 false true true [1]
+Row Count : 16
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_index 11 10 0 false false false false 1 true true true false
indexrelid 4 PartsSupplier java.lang.Integer indexrelid integer pg_catalog pg_index 11 10 0 false false false false 1 true true true false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -5,23 +5,17 @@
1
1
3
-1
+1 2
2
-2
1
+1 3
+2 1
+3 4 5
+1 2
1
-3
-2
1
-3
-4
-5
1
-2
1
-1
-1
-1
-Row Count : 22
+Row Count : 16
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
indkey 1111 java.lang.Object indkey int2vector 2147483647 2147483647 0 false true false false 1 false true false true
More information about the teiid-commits
mailing list