teiid SVN: r3103 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-19 16:22:03 -0400 (Tue, 19 Apr 2011)
New Revision: 3103
Modified:
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
Log:
TEIID-1507 removing cost gathering logic from 7.4. there's not enough time to get it in properly
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-04-19 19:46:20 UTC (rev 3102)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-04-19 20:22:03 UTC (rev 3103)
@@ -42,13 +42,9 @@
import org.teiid.language.SetQuery;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.Column;
-import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.metadata.Table;
-import org.teiid.metadata.TableStats;
@@ -809,14 +805,6 @@
}
- public boolean updateTableStats(Table table, TableStats stats, C conn) throws TranslatorException {
- return false;
- }
-
- public boolean updateColumnStats(Column column, ColumnStats stats, C conn) throws TranslatorException {
- return false;
- }
-
/**
* Indicates if LOBs are usable after the execution is closed.
* @return true if LOBs can be used after close
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-04-19 19:46:20 UTC (rev 3102)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-04-19 20:22:03 UTC (rev 3103)
@@ -24,10 +24,7 @@
*/
package org.teiid.translator.jdbc.oracle;
-import java.sql.CallableStatement;
-import java.sql.Connection;
import java.sql.PreparedStatement;
-import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
@@ -55,10 +52,7 @@
import org.teiid.language.SetQuery.Operation;
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.metadata.Column;
-import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.Table;
-import org.teiid.metadata.TableStats;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -74,7 +68,6 @@
@Translator(name="oracle", description="A translator for Oracle 9i Database or later")
public class OracleExecutionFactory extends JDBCExecutionFactory {
-
private static final String TIME_FORMAT = "HH24:MI:SS"; //$NON-NLS-1$
private static final String DATE_FORMAT = "YYYY-MM-DD"; //$NON-NLS-1$
@@ -86,33 +79,33 @@
public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
- private static final String NUMBER = "number"; //$NON-NLS-1$
- private static final char escape = '"';
- private static final char delim = '.';
-
- private final static Map<Class<?>, String> type_to_raw_mapping = new HashMap<Class<?>, String>();
private final static Map<Class<?>, Integer> type_to_jdbc_mapping = new HashMap<Class<?>, Integer>();
private final static Map<String, String> native_to_raw_mapping = new TreeMap<String, String>();
static {
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.BYTE, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.SHORT, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.INTEGER, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.LONG, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.FLOAT, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.DOUBLE, NUMBER);
- type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.STRING, "varchar2"); //$NON-NLS-1$
-
+ native_to_raw_mapping.put("number", "number"); //$NON-NLS-1$ //$NON-NLS-2$
native_to_raw_mapping.put("varchar2", "varchar2"); //$NON-NLS-1$ //$NON-NLS-2$
native_to_raw_mapping.put("nvarchar2", "nvarchar2"); //$NON-NLS-1$ //$NON-NLS-2$
native_to_raw_mapping.put("binary_float", "binary_float"); //$NON-NLS-1$ //$NON-NLS-2$
native_to_raw_mapping.put("binary_integer", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("natural", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("positive", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("naturaln", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("postiven", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("signtype", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
native_to_raw_mapping.put("binary_double", "binary_double"); //$NON-NLS-1$ //$NON-NLS-2$
type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.DATE, Types.DATE);
type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.TIME, Types.DATE);
type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, Types.DATE);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.BYTE, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.SHORT, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.INTEGER, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.LONG, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.FLOAT, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.DOUBLE, Types.NUMERIC);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.STRING, Types.VARCHAR);
}
public void start() throws TranslatorException {
@@ -547,156 +540,4 @@
return true;
}
- @Override
- public boolean updateTableStats(Table table, TableStats stats, Connection conn)
- throws TranslatorException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- String qualifiedTableName = table.getNameInSource();
- if (qualifiedTableName == null) {
- return false;
- }
- if (DUAL.equalsIgnoreCase(qualifiedTableName)) {
- stats.setCardinality(1);
- return false;
- }
- List<String> nameParts = JDBCExecutionFactory.parseName(qualifiedTableName, escape, delim);
- if (nameParts.size() < 2) {
- return false;
- }
- String schemaName = nameParts.get(nameParts.size() - 2);
- String tableName = nameParts.get(nameParts.size() - 1);
- try {
- try {
- stmt = conn.prepareStatement("select num_rows from ALL_TABLES where owner = ? AND table_name = ?"); //$NON-NLS-1$
- stmt.setString(1, schemaName);
- stmt.setString(2, tableName);
- rs = stmt.executeQuery();
- if(rs.next()) {
- stats.setCardinality(rs.getInt(1));
- return true;
- }
- } finally {
- if(rs != null) {
- rs.close();
- }
- if(stmt != null) {
- stmt.close();
- }
- }
- } catch (SQLException e) {
- throw new TranslatorException(e);
- }
- return false;
- }
-
- @Override
- public boolean updateColumnStats(Column column, ColumnStats stats,
- Connection conn) throws TranslatorException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- String columnName = column.getNameInSource();
- if (columnName == null) {
- columnName = column.getName();
- }
- String qualifiedTableName = column.getParent().getNameInSource();
- if (qualifiedTableName == null) {
- return false;
- }
- if (DUAL.equalsIgnoreCase(qualifiedTableName)) {
- return false;
- }
- List<String> nameParts = JDBCExecutionFactory.parseName(qualifiedTableName, escape, delim);
- if (nameParts.size() < 2) {
- return false;
- }
- String schemaName = nameParts.get(nameParts.size() - 2);
- String tableName = nameParts.get(nameParts.size() - 1);
- try {
- try {
- String sql = "select num_distinct, num_nulls"; //$NON-NLS-1$
- boolean knownType = true;
- String type = null;
- Integer jdbcType = null;
- if (column.getNativeType() != null) {
- type = native_to_raw_mapping.get(column.getNativeType());
- }
- Class<?> clazzType = TypeFacility.getDataTypeClass(column.getRuntimeType());
- if (type == null) {
- type = type_to_raw_mapping.get(clazzType);
- }
- if (type != null) {
- //TODO: could split into two queries to ensure that we at least get the ndv/nnv
- sql += ", utl_raw.cast_to_"+type+"(low_value), utl_raw.cast_to_"+type+"(high_value)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- //TODO could get type from the databasemetadata or store the type in the extension metadata
- sql += ", low_value, high_value"; //$NON-NLS-1$
- knownType = false;
- jdbcType = type_to_jdbc_mapping.get(clazzType);
- }
-
- sql += " from ALL_TAB_COL_STATISTICS where owner=? and TABLE_NAME = ? and COLUMN_NAME = ?"; //$NON-NLS-1$
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, schemaName);
- stmt.setString(2, tableName);
- stmt.setString(3, columnName);
- rs = stmt.executeQuery();
- if(rs.next()) {
- stats.setNumDistinctValues(rs.getInt(1));
- stats.setNumNullValues(rs.getInt(2));
-
- if (jdbcType != null) {
- byte[] bytes = rs.getBytes(3);
- String val = getRawAsString(conn, bytes, jdbcType);
- stats.setMin(val);
- bytes = rs.getBytes(4);
- val = getRawAsString(conn, bytes, jdbcType);
- stats.setMax(val);
- } else if (knownType) {
- stats.setMin(rs.getString(3));
- stats.setMax(rs.getString(4));
- }
- //if not a known conversion type (rowid, char, etc.), then we could choose to compensate
- }
- } finally {
- if(rs != null) {
- rs.close();
- }
- if(stmt != null) {
- stmt.close();
- }
- }
- } catch (SQLException e) {
- throw new TranslatorException(e);
- }
- return true;
- }
-
- /**
- * @param colStat
- * @param bytes
- * @return
- * @throws SQLException
- */
- private String getRawAsString( Connection conn, byte[] bytes, int type ) {
- CallableStatement cs = null;
- try {
- cs = conn.prepareCall("{call dbms_stats.convert_raw_value(?, ?)}"); //$NON-NLS-1$
- cs.registerOutParameter(2, type);
- cs.setBytes(1, bytes);
- cs.execute();
- String val = cs.getString(2);
- return val;
- } catch (SQLException e) {
- return null; //TODO
- } finally {
- if (cs != null) {
- try {
- cs.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
}
13 years, 9 months
teiid SVN: r3102 - in trunk/engine/src/main: resources/org/teiid/query and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-19 15:46:20 -0400 (Tue, 19 Apr 2011)
New Revision: 3102
Modified:
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
removing an unused exception and fixing a message that was backwards
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2011-04-19 17:42:06 UTC (rev 3101)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2011-04-19 19:46:20 UTC (rev 3102)
@@ -364,7 +364,7 @@
eventWriter.add(eventFactory.createEndElement("", null, name)); //$NON-NLS-1$
}
- public static XMLType xmlConcat(CommandContext context, final XMLType xml, final Object... other) throws TeiidComponentException, TeiidProcessingException {
+ public static XMLType xmlConcat(CommandContext context, final XMLType xml, final Object... other) throws TeiidProcessingException {
//determine if there is just a single xml value and return it
XMLType singleValue = xml;
XMLType.Type type = null;
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-19 17:42:06 UTC (rev 3101)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-19 19:46:20 UTC (rev 3102)
@@ -852,8 +852,8 @@
# services (003)
Request.Invalid_character_in_query=Bind variables (represented as "?") were found but are allowed only in prepared or callable statements.
-Request.no_result_set=The query does not return an update count.
-Request.result_set=The query does not return a result set.
+Request.no_result_set=The query does not return a result set.
+Request.result_set=The query does not return an update count.
ProcessWorker.wrongdata=Wrong type of data found or no data found; expecting streamable object from the buffer manager.
ProcessWorker.LobError=An error occurred during streaming of Lob Chunks to Client.
13 years, 9 months
teiid SVN: r3101 - in trunk: runtime/src/main/java/org/teiid/deployers and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-19 13:42:06 -0400 (Tue, 19 Apr 2011)
New Revision: 3101
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-1559 adding a missing log message and fixing jdbcmetadata processor messages
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-04-18 21:28:18 UTC (rev 3100)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-04-19 17:42:06 UTC (rev 3101)
@@ -35,6 +35,7 @@
import java.util.TreeMap;
import org.teiid.core.util.StringUtil;
+import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.BaseColumn;
@@ -132,7 +133,7 @@
private void getProcedures(MetadataFactory metadataFactory,
DatabaseMetaData metadata) throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing procedures"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing procedures"); //$NON-NLS-1$
ResultSet procedures = metadata.getProcedures(catalog, schemaPattern, procedureNamePattern);
int rsColumns = procedures.getMetaData().getColumnCount();
while (procedures.next()) {
@@ -199,7 +200,7 @@
private Map<String, TableInfo> getTables(MetadataFactory metadataFactory,
DatabaseMetaData metadata) throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing tables"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing tables"); //$NON-NLS-1$
ResultSet tables = metadata.getTables(catalog, schemaPattern, tableNamePattern, tableTypes);
Map<String, TableInfo> tableMap = new HashMap<String, TableInfo>();
while (tables.next()) {
@@ -224,7 +225,7 @@
private void getColumns(MetadataFactory metadataFactory,
DatabaseMetaData metadata, Map<String, TableInfo> tableMap)
throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing columns"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing columns"); //$NON-NLS-1$
ResultSet columns = metadata.getColumns(catalog, schemaPattern, tableNamePattern, null);
int rsColumns = columns.getMetaData().getColumnCount();
while (columns.next()) {
@@ -301,7 +302,7 @@
private void getPrimaryKeys(MetadataFactory metadataFactory,
DatabaseMetaData metadata, Map<String, TableInfo> tableMap)
throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing primary keys"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing primary keys"); //$NON-NLS-1$
for (TableInfo tableInfo : tableMap.values()) {
ResultSet pks = metadata.getPrimaryKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
TreeMap<Short, String> keyColumns = null;
@@ -329,7 +330,7 @@
private void getForeignKeys(MetadataFactory metadataFactory,
DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing foreign keys"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing foreign keys"); //$NON-NLS-1$
for (TableInfo tableInfo : tableMap.values()) {
ResultSet fks = metadata.getImportedKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
TreeMap<Short, String> keyColumns = null;
@@ -373,7 +374,7 @@
private void getIndexes(MetadataFactory metadataFactory,
DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, TranslatorException {
- LogManager.logDetail("JDBCMetadataProcessor - Importing index info"); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing index info"); //$NON-NLS-1$
for (TableInfo tableInfo : tableMap.values()) {
ResultSet indexInfo = metadata.getIndexInfo(tableInfo.catalog, tableInfo.schema, tableInfo.name, false, importApproximateIndexes);
TreeMap<Short, String> indexColumns = null;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-04-18 21:28:18 UTC (rev 3100)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-04-19 17:42:06 UTC (rev 3101)
@@ -322,7 +322,7 @@
* @return true if loaded, null if not loaded - but a cm is available, else false
*/
private Boolean loadMetadata(VDBMetaData vdb, ModelMetaData model, boolean cache, File cacheFile, MetadataStoreGroup vdbStore, ConnectorManagerRepository cmr) {
- String msg = RuntimePlugin.Util.getString("model_metadata_loading", vdb.getName()+"-"+vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$
+ String msg = RuntimePlugin.Util.getString("model_metadata_loading", vdb.getName(), vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date())); //$NON-NLS-1$
model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
@@ -359,13 +359,14 @@
synchronized (vdb) {
if (loaded == null || !loaded) {
vdb.setStatus(VDB.Status.INACTIVE);
- String failed_msg = RuntimePlugin.Util.getString(loaded==null?"failed_to_retrive_metadata":"nosources_to_retrive_metadata", vdb.getName()+"-"+vdb.getVersion(), model.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String failed_msg = RuntimePlugin.Util.getString(loaded==null?"failed_to_retrive_metadata":"nosources_to_retrive_metadata", vdb.getName(), vdb.getVersion(), model.getName()); //$NON-NLS-1$ //$NON-NLS-2$
model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), failed_msg);
if (exceptionMessage != null) {
model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), exceptionMessage);
}
LogManager.logWarning(LogConstants.CTX_RUNTIME, failed_msg);
} else {
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("metadata_loaded",vdb.getName(), vdb.getVersion(), model.getName())); //$NON-NLS-1$
model.clearErrors();
if (vdb.isValid()) {
this.vdbRepository.updateVDB(vdb.getName(), vdb.getVersion());
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-04-18 21:28:18 UTC (rev 3100)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-04-19 17:42:06 UTC (rev 3101)
@@ -58,8 +58,8 @@
vdb_undeployed=VDB "{0}" undeployed.
system_vdb_load_error=System.vdb needs to be loaded before any other VDBs.
fail_to_deploy="{0}" Can not be active because model "{1}" is not fully configured.
-failed_to_retrive_metadata="{0}" is now "incomplete", because model "{1}" can not retrieve metadata. Please fix any errors and re-deploy relevant DataSources and/or the VDB.
-nosources_to_retrive_metadata="{0}" is now "incomplete", because model "{1}" can not retrieve metadata. Please deploy the necessary DataSources.
+failed_to_retrive_metadata={0}.{1} is now "incomplete", because model "{2}" can not retrieve metadata. Please fix any errors and re-deploy relevant DataSources and/or the VDB.
+nosources_to_retrive_metadata={0}.{1} is now "incomplete", because model "{2}" can not retrieve metadata. Please deploy the necessary DataSources.
invalid_metadata_file=Invalid metadata file found at {0}; delete this file and restart server.
udf_model_not_found=User Defined Function (UDF) model "{0}" not found in the VDB
duplicate_vdb=VDB with given name and version already exists! {0}.{1}
@@ -87,7 +87,8 @@
not_bound=No bound statement found with name {0}
no_stmt_found=No prepared statement found with name {0}
error_closing_stmt=Error closing portal statement {0}
-model_metadata_loading=VDB "{0}" - "{1}" model metadata is currently being loaded. Start Time: {2}
+model_metadata_loading=VDB {0}.{1} model {2} metadata is currently being loaded. Start Time: {3}
+metadata_loaded=VDB {0}.{1} model {2} metadata is currently being loaded.
ambigious_name=Ambiguous VDB name specified. Only single occurrence of the "." is allowed in the VDB name. Also, when version based vdb name is specified, then a separate "version" connection option is not allowed:{0}.{1}
lo_not_supported=LO functions are not supported
SSLConfiguration.no_anonymous=The anonymous cipher suite TLS_DH_anon_WITH_AES_128_CBC_SHA is not available. Please change the transport to be non-SSL or use non-anonymous SSL.
\ No newline at end of file
13 years, 9 months
teiid SVN: r3100 - trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-18 17:28:18 -0400 (Mon, 18 Apr 2011)
New Revision: 3100
Modified:
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
Log:
TEIID-1558 fix for npe using an id based query
Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java 2011-04-18 14:55:32 UTC (rev 3099)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java 2011-04-18 21:28:18 UTC (rev 3100)
@@ -336,8 +336,12 @@
try {
List<SObject> objects = sfSoap.retrieve(fieldList, sObjectType, ids, sh);
QueryResult result = new QueryResult();
- result.getRecords().addAll(objects);
- result.setSize(objects.size());
+ for (SObject sObject : objects) {
+ if (sObject != null) {
+ result.getRecords().add(sObject);
+ }
+ }
+ result.setSize(result.getRecords().size());
result.setDone(true);
return result;
} catch (InvalidFieldFault e) {
13 years, 9 months
teiid SVN: r3099 - in trunk/engine/src/main: resources/org/teiid/query and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-18 10:55:32 -0400 (Mon, 18 Apr 2011)
New Revision: 3099
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
TEIID-1539 updating the warn logic to happen only based upon time in queue
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java 2011-04-15 21:22:51 UTC (rev 3098)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java 2011-04-18 14:55:32 UTC (rev 3099)
@@ -228,6 +228,7 @@
return result;
}
});
+ private long warnWaitTime = 500;
public ThreadReuseExecutor(String name, int maximumPoolSize) {
this.maximumPoolSize = maximumPoolSize;
@@ -252,7 +253,6 @@
private void executeDirect(final PrioritizedRunnable command) {
boolean atMaxThreads = false;
- boolean newMaxQueueSize = false;
synchronized (poolLock) {
checkForTermination();
submittedCount++;
@@ -261,7 +261,6 @@
queue.add(command);
int queueSize = queue.size();
if (queueSize > highestQueueSize) {
- newMaxQueueSize = true;
highestQueueSize = queueSize;
}
} else {
@@ -270,9 +269,6 @@
}
}
if (atMaxThreads) {
- if (newMaxQueueSize && maximumPoolSize > 1) {
- LogManager.logWarning(LogConstants.CTX_RUNTIME, QueryPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
- }
return;
}
tpe.execute(new Runnable() {
@@ -285,7 +281,7 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.TRACE)) {
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
}
- Runnable r = command;
+ PrioritizedRunnable r = command;
while (r != null) {
boolean success = false;
try {
@@ -305,6 +301,11 @@
}
}
}
+ long warnTime = warnWaitTime;
+ if (r != null && System.currentTimeMillis() - r.getCreationTime() > warnTime) {
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, QueryPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize, warnTime)); //$NON-NLS-1$
+ warnWaitTime*=2; //we don't really care if this is synchronized
+ }
t.setName(name);
}
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-15 21:22:51 UTC (rev 3098)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-18 14:55:32 UTC (rev 3099)
@@ -737,7 +737,7 @@
SetClause.resolvingError=Cannot set symbol ''{1}'' with expected type {2} to expression ''{0}''
NewCalculateCostUtil.badCost=Unexpected format encountered for max or min value
-WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}". To avoid queuing of work you may consider increasing of "maxThreads" property in "teiid-jboss-beans.xml" file in the "RuntimeEngineDeployer" section.
+WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size high of "{2}". Queued work waited {3} ms prior to executing. To avoid queuing of work you may consider increasing "RuntimeEngineDeployer.maxThreads" or decreasing the "RuntimeEngineDeployer.maxActivePlans" in the "teiid-jboss-beans.xml" file.
WorkerPool.uncaughtException=Uncaught exception processing work
13 years, 9 months
teiid SVN: r3098 - in trunk/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-15 17:22:51 -0400 (Fri, 15 Apr 2011)
New Revision: 3098
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
Log:
TEIID-1550 adding support for permission checks against functions
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-04-15 21:19:47 UTC (rev 3097)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-04-15 21:22:51 UTC (rev 3098)
@@ -187,7 +187,7 @@
}
} else if (!allowFunctionCallsByDefault) {
String schema = obj.getFunctionDescriptor().getSchema();
- if (schema != null && !CoreConstants.SYSTEM_MODEL.equals(schema)) {
+ if (schema != null && !isSystemSchema(schema)) {
Map<String, Function> map = new HashMap<String, Function>();
map.put(schema + '.' + obj.getFunctionDescriptor().getName(), obj);
validateEntitlements(PermissionType.READ, Context.FUNCTION, map);
@@ -309,7 +309,7 @@
fullName = getMetadata().getFullName(metadataID);
Object modelId = getMetadata().getModelID(metadataID);
String modelName = getMetadata().getFullName(modelId);
- if (CoreConstants.SYSTEM_MODEL.equals(modelName) || CoreConstants.ODBC_MODEL.equals(modelName)) {
+ if (isSystemSchema(modelName)) {
continue;
}
nameToSymbolMap.put(fullName, symbol);
@@ -323,6 +323,10 @@
validateEntitlements(actionCode, auditContext, nameToSymbolMap);
}
+ private boolean isSystemSchema(String modelName) {
+ return CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(modelName) || CoreConstants.ODBC_MODEL.equalsIgnoreCase(modelName);
+ }
+
private void validateEntitlements(DataPolicy.PermissionType actionCode,
Context auditContext, Map<String, ? extends LanguageObject> nameToSymbolMap) {
if (nameToSymbolMap.isEmpty()) {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-04-15 21:19:47 UTC (rev 3097)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-04-15 21:22:51 UTC (rev 3098)
@@ -193,8 +193,8 @@
@Test public void testFunction() throws Exception {
FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
- //helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1 FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest(exampleAuthSvc2(), "SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible() throws Exception {
13 years, 9 months
teiid SVN: r3097 - in trunk: build/kits/jboss-container/deploy/teiid and 5 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-15 17:19:47 -0400 (Fri, 15 Apr 2011)
New Revision: 3097
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
Log:
TEIID-1550 adding support for permission checks against functions
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-04-15 21:19:47 UTC (rev 3097)
@@ -119,8 +119,10 @@
<property name="lobChunkSizeInKB">100</property>
<!-- Turn on role checking based upon the data roles defined in VDBs. (default true) -->
<property name="useDataRoles">true</property>
- <!-- Sets whether temporary table usage is enabled by default (default true) -->
+ <!-- Sets whether temporary table usage is allowed by default with data roles enabled. If false, the user must have a role that grants creates temporary table rights to use temporary tables. (default true) -->
<property name="allowCreateTemporaryTablesByDefault">true</property>
+ <!-- Sets whether functions may be called by default with data roles enabled. If false, a specific permission must exist to call the function. (default true) -->
+ <property name="allowFunctionCallsByDefault">true</property>
<!-- Long running query threshold, after which a alert can be generated by tooling if configured-->
<property name="queryThresholdInSecs">600</property>
<!-- Maximum rows allowed from a source query. -1 indicates no limit. (default -1)-->
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-04-15 21:19:47 UTC (rev 3097)
@@ -51,7 +51,8 @@
<LI><B>Cost based back-off</B> - for cost based dependent joins if the number of independent values is too large, then the join will be performed as normal.
</UL>
<LI><B>Enhanced Sort Join</B> - the partitioned merge join was replaced with an enhanced sort join. The enhanced sort join will use the actual row counts from each side of the relation to perform a index based join if one side is small enough, a partial sort of the larger side and a repeated merge join if the tuples are unbalanced but one side is not small enough to form an index, or a standard sort merge join if the tuples are balanced.
- <LI><B>JDK1.5 JDBC Client JAR</B> - A retro-translated Teiid client JDBC jar now available to use with JDK 1.5 VM. Note only JDBC API supported, not Admin API.
+ <LI><B>JDK1.5 JDBC Client JAR</B> - A retro-translated Teiid client JDBC jar now available to use with JDK 1.5 VM. Note only the JDBC API is supported, not the Admin API, or retrieving query plans as XML.
+ <LI><B>Security Improvements</B> - UDF and pushdown functions can now be protected with data roles. Also the CommandContext can provide the Subject for custom security checks in UDFs.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -122,6 +123,7 @@
<LI>SocketConfiguration.maxSocketThreads will interpret a setting of 0 to mean use the system default of max available processors. Both the ODBC and JDBC transports now default to the 0 setting.
<LI>maxReserveBatchColumns and maxProcessingBatchesColumns will interpret a setting of -1 to mean auto-calculate acceptable values given the max heap and other information. See the admin guide for more.
<LI>The default for org.teiid.useValueCache has changed to false, since typical installations will not greatly benefit from the additional lookup cost.
+ <LI>The property RuntimeEngineDeployer.allowFunctionCallsByDefault was added so that Teiid 7.4 behavior is compatible with Teiid 7.3. Set this property to false to require permissions for function calls when data roles are enabled.
</ul>
<h4>from 7.2</h4>
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2011-04-15 21:19:47 UTC (rev 3097)
@@ -174,7 +174,7 @@
</listitem>
</itemizedlist>
<para>You may optionally add an additional <code>org.teiid.CommandContext</code> argument as the first parameter.
- The <code>CommandContext</code> interface provides access to information about the current command, such as the executing user, the vdb, the session id, etc.
+ The <code>CommandContext</code> interface provides access to information about the current command, such as the executing user, Subject, the vdb, the session id, etc.
This <code>CommandContext</code> parameter does not need to be delared in the function metadata.</para>
<example>
<title>Sample code</title>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml 2011-04-15 21:19:47 UTC (rev 3097)
@@ -76,6 +76,13 @@
<para>To process a <emphasis>EXEC</emphasis> statement, the user account requires the following access rights:</para>
<listitem> <para><emphasis>READ</emphasis> - on the Procedure being executed.</para></listitem>
</orderedlist>
+
+ <orderedlist>
+ <para>To process any function, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>READ</emphasis> - on the Function being called.</para> </listitem>
+ <note><para>For backwards compatibility RuntimeEngineDeployer.allowFunctionCallsByDefault located in the &jboss-beans; file in the <code>RuntimeEngineDeployer</code> section defaults to true.
+ This means that to actually require permissions for functions, you need to set this property to false.</para></note>
+ </orderedlist>
</section>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -35,6 +35,7 @@
import java.util.Set;
import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.DataPolicy.PermissionType;
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.CoreConstants;
@@ -49,6 +50,7 @@
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.lang.Delete;
import org.teiid.query.sql.lang.Drop;
@@ -75,12 +77,14 @@
INSERT,
UPDATE,
DELETE,
+ FUNCTION,
STORED_PROCEDURE;
}
private HashMap<String, DataPolicy> allowedPolicies;
private String userName;
private boolean allowCreateTemporaryTablesDefault = true;
+ private boolean allowFunctionCallsByDefault = true;
public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, String user) {
this.allowedPolicies = policies;
@@ -91,6 +95,10 @@
boolean allowCreateTemporaryTablesDefault) {
this.allowCreateTemporaryTablesDefault = allowCreateTemporaryTablesDefault;
}
+
+ public void setAllowFunctionCallsByDefault(boolean allowFunctionCallsDefault) {
+ this.allowFunctionCallsByDefault = allowFunctionCallsDefault;
+ }
// ############### Visitor methods for language objects ##################
@@ -123,7 +131,7 @@
logResult(resources, context, allowed);
if (!allowed) {
handleValidationError(
- QueryPlugin.Util.getString("ERR.018.005.0095", userName, "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$
+ QueryPlugin.Util.getString("ERR.018.005.0095", userName, "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$ //$NON-NLS-2$
symbols);
}
}
@@ -177,6 +185,13 @@
} catch (TeiidProcessingException e) {
handleException(e, obj);
}
+ } else if (!allowFunctionCallsByDefault) {
+ String schema = obj.getFunctionDescriptor().getSchema();
+ if (schema != null && !CoreConstants.SYSTEM_MODEL.equals(schema)) {
+ Map<String, Function> map = new HashMap<String, Function>();
+ map.put(schema + '.' + obj.getFunctionDescriptor().getName(), obj);
+ validateEntitlements(PermissionType.READ, Context.FUNCTION, map);
+ }
}
}
@@ -273,9 +288,9 @@
* @param actionCode The actions to validate for
* @param auditContext The {@link AuthorizationService} to use when resource auditing is done.
*/
- protected void validateEntitlements(Collection<? extends Symbol> symbols, DataPolicy.PermissionType actionCode, Context auditContext) {
- Map<String, Symbol> nameToSymbolMap = new HashMap<String, Symbol>();
- for (Symbol symbol : symbols) {
+ protected void validateEntitlements(Collection<? extends LanguageObject> symbols, DataPolicy.PermissionType actionCode, Context auditContext) {
+ Map<String, LanguageObject> nameToSymbolMap = new HashMap<String, LanguageObject>();
+ for (LanguageObject symbol : symbols) {
try {
String fullName = null;
Object metadataID = null;
@@ -305,24 +320,31 @@
}
}
- if (!nameToSymbolMap.isEmpty()) {
- Collection<String> inaccessibleResources = getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
- if(inaccessibleResources.size() > 0) {
- List<Symbol> inaccessibleSymbols = new ArrayList<Symbol>(inaccessibleResources.size());
- for (String name : inaccessibleResources) {
- inaccessibleSymbols.add(nameToSymbolMap.get(name));
- }
-
- // CASE 2362 - do not include the names of the elements for which the user
- // is not authorized in the exception message
-
- handleValidationError(
- QueryPlugin.Util.getString("ERR.018.005.0095", userName, actionCode), //$NON-NLS-1$
- inaccessibleSymbols);
- }
- }
+ validateEntitlements(actionCode, auditContext, nameToSymbolMap);
}
+ private void validateEntitlements(DataPolicy.PermissionType actionCode,
+ Context auditContext, Map<String, ? extends LanguageObject> nameToSymbolMap) {
+ if (nameToSymbolMap.isEmpty()) {
+ return;
+ }
+ Collection<String> inaccessibleResources = getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
+ if(inaccessibleResources.isEmpty()) {
+ return;
+ }
+ List<LanguageObject> inaccessibleSymbols = new ArrayList<LanguageObject>(inaccessibleResources.size());
+ for (String name : inaccessibleResources) {
+ inaccessibleSymbols.add(nameToSymbolMap.get(name));
+ }
+
+ // CASE 2362 - do not include the names of the elements for which the user
+ // is not authorized in the exception message
+
+ handleValidationError(
+ QueryPlugin.Util.getString("ERR.018.005.0095", userName, actionCode), //$NON-NLS-1$
+ inaccessibleSymbols);
+ }
+
/**
* Out of resources specified, return the subset for which the specified not have authorization to access.
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -59,6 +59,7 @@
private transient AuthorizationValidator authorizationValidator;
private transient MetadataProvider metadataProvider;
+ private boolean allowFunctionCallsByDefault;
@ManagementProperty(description="Max active plans (default 20). Increase this value, and max threads, on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts.")
public int getMaxActivePlans() {
@@ -147,7 +148,7 @@
* Whether temporary table usage is enabled by default.
* @return <code>true</code> if temporary table usage is enabled by default.
*/
- @ManagementProperty(description="Sets whether temporary table usage is enabled by default. (default true)")
+ @ManagementProperty(description="Sets whether temporary table usage is allowed by default with data roles enabled. If false, the user must have a role that grants creates temporary table rights to use temporary tables. (default true)")
public boolean isAllowCreateTemporaryTablesByDefault() {
return allowCreateTemporaryTablesByDefault;
}
@@ -157,6 +158,19 @@
this.allowCreateTemporaryTablesByDefault = allowCreateTemporaryTablesByDefault;
}
+ /**
+ * Whether functions are callable by default
+ * @return <code>true</code> if function usage is enabled by default.
+ */
+ @ManagementProperty(description="Sets whether functions may be called by default with data roles enabled. If false, a specific permission must exist to call the function. (default true)")
+ public boolean isAllowFunctionCallsByDefault() {
+ return allowFunctionCallsByDefault;
+ }
+
+ public void setAllowFunctionCallsByDefault(boolean allowFunctionCallsDefault) {
+ this.allowFunctionCallsByDefault = allowFunctionCallsDefault;
+ }
+
@ManagementProperty(description="Long running query threshold, after which a alert can be generated by tooling if configured")
public int getQueryThresholdInSecs() {
return queryThresholdInSecs;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -670,7 +670,7 @@
this.config = config;
this.authorizationValidator = config.getAuthorizationValidator();
if (this.authorizationValidator == null) {
- this.authorizationValidator = new DataRoleAuthorizationValidator(config.getUseDataRoles(), config.isAllowCreateTemporaryTablesByDefault());
+ this.authorizationValidator = new DataRoleAuthorizationValidator(config.getUseDataRoles(), config.isAllowCreateTemporaryTablesByDefault(), config.isAllowFunctionCallsByDefault());
}
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -34,11 +34,13 @@
private boolean useEntitlements;
private boolean allowCreateTemporaryTablesByDefault;
+ private boolean allowFunctionCallsByDefault;
public DataRoleAuthorizationValidator(boolean useEntitlements,
- boolean allowCreateTemporaryTablesByDefault) {
+ boolean allowCreateTemporaryTablesByDefault, boolean allowFunctionCallsByDefault) {
this.useEntitlements = useEntitlements;
this.allowCreateTemporaryTablesByDefault = allowCreateTemporaryTablesByDefault;
+ this.allowFunctionCallsByDefault = allowFunctionCallsByDefault;
}
@Override
@@ -46,6 +48,7 @@
if (useEntitlements && !workContext.getVDB().getDataPolicies().isEmpty()) {
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(workContext.getAllowedDataPolicies(), workContext.getUserName());
visitor.setAllowCreateTemporaryTablesDefault(allowCreateTemporaryTablesByDefault);
+ visitor.setAllowFunctionCallsByDefault(allowFunctionCallsByDefault);
Request.validateWithVisitor(visitor, metadata, command);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -52,6 +52,7 @@
private Class<?> returnType;
private boolean requiresContext;
private FunctionMethod method;
+ private String schema; //TODO: remove me - we need to create a proper schema for udf and system functions
// This is transient as it would be useless to invoke this method in
// a different VM. This function descriptor can be used to look up
@@ -70,7 +71,15 @@
this.requiresContext = requiresContext;
this.method = method;
}
-
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
public String getName() {
return this.method.getName();
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -223,6 +223,7 @@
}
FunctionDescriptor descriptor = createFunctionDescriptor(source, method, inputTypes, types);
+ descriptor.setSchema(schema);
// Store this path in the function tree
int index = -1;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -27,7 +27,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.junit.Ignore;
@@ -41,11 +40,16 @@
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.FakeFunctionMetadataSource;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorFailure;
@@ -121,8 +125,8 @@
svc.addPermission(addResource(DataPolicy.PermissionType.DELETE, "pm1.g4.e1")); //$NON-NLS-1$
svc.addPermission(addResource(DataPolicy.PermissionType.DELETE, "pm1.g4.e2")); //$NON-NLS-1$
- // pm1.sq2
svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm1.sq1")); //$NON-NLS-1$
+ svc.addPermission(addResource(DataPolicy.PermissionType.READ, "foo.xyz")); //$NON-NLS-1$
return svc;
}
@@ -157,18 +161,21 @@
policies.put(policy.getName(), policy);
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, "test"); //$NON-NLS-1$
+ visitor.setAllowFunctionCallsByDefault(false);
ValidatorReport report = Validator.validate(command, metadata, visitor);
if(report.hasItems()) {
- ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
+ ValidatorFailure firstFailure = report.getItems().iterator().next();
// strings
- Set expected = new HashSet(Arrays.asList(expectedInaccesible));
+ Set<String> expected = new HashSet<String>(Arrays.asList(expectedInaccesible));
// elements
- Set actual = new HashSet();
- Iterator iter = firstFailure.getInvalidObjects().iterator();
- while(iter.hasNext()) {
- Symbol symbol = (Symbol) iter.next();
- actual.add(symbol.getName());
+ Set<String> actual = new HashSet<String>();
+ for (LanguageObject obj : firstFailure.getInvalidObjects()) {
+ if (obj instanceof ElementSymbol) {
+ actual.add(((ElementSymbol)obj).getName());
+ } else {
+ actual.add(obj.toString());
+ }
}
assertEquals(expected, actual);
} else if(expectedInaccesible.length > 0) {
@@ -183,6 +190,13 @@
helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", FakeMetadataFactory.example1Cached(), new String[] {"x"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
+ @Test public void testFunction() throws Exception {
+ FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+ //helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest(exampleAuthSvc2(), "SELECT e1 FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ }
+
@Test public void testEverythingAccessible() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -243,7 +243,7 @@
serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, workContext, prepPlanCache);
serverRequest.setMetadata(capFinder, metadata, null);
- serverRequest.setAuthorizationValidator(new DataRoleAuthorizationValidator(false, true));
+ serverRequest.setAuthorizationValidator(new DataRoleAuthorizationValidator(false, true, true));
serverRequest.processRequest();
assertNotNull(serverRequest.processPlan);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-04-15 21:17:56 UTC (rev 3096)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-04-15 21:19:47 UTC (rev 3097)
@@ -79,7 +79,7 @@
request.initialize(message, null, null,new FakeTransactionService(),null, workContext, null);
request.initMetadata();
- request.setAuthorizationValidator(new DataRoleAuthorizationValidator(true, true));
+ request.setAuthorizationValidator(new DataRoleAuthorizationValidator(true, true, true));
request.validateAccess(command);
}
@@ -133,7 +133,7 @@
request.initialize(message, Mockito.mock(BufferManager.class),
new FakeDataManager(), new FakeTransactionService(), null, workContext, null);
- request.setAuthorizationValidator(new DataRoleAuthorizationValidator(false, true));
+ request.setAuthorizationValidator(new DataRoleAuthorizationValidator(false, true, true));
request.processRequest();
return request;
}
13 years, 9 months
teiid SVN: r3096 - trunk/engine/src/main/resources/org/teiid/query.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-15 17:17:56 -0400 (Fri, 15 Apr 2011)
New Revision: 3096
Modified:
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
TEIID-1539
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-15 20:44:09 UTC (rev 3095)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-04-15 21:17:56 UTC (rev 3096)
@@ -737,7 +737,7 @@
SetClause.resolvingError=Cannot set symbol ''{1}'' with expected type {2} to expression ''{0}''
NewCalculateCostUtil.badCost=Unexpected format encountered for max or min value
-WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}".
+WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}". To avoid queuing of work you may consider increasing of "maxThreads" property in "teiid-jboss-beans.xml" file in the "RuntimeEngineDeployer" section.
WorkerPool.uncaughtException=Uncaught exception processing work
13 years, 9 months
teiid SVN: r3095 - in trunk: api/src/main/java/org/teiid/metadata and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-15 16:44:09 -0400 (Fri, 15 Apr 2011)
New Revision: 3095
Added:
trunk/api/src/main/java/org/teiid/events/EventDistributorFactory.java
trunk/api/src/main/java/org/teiid/metadata/ColumnStats.java
trunk/api/src/main/java/org/teiid/metadata/TableStats.java
trunk/api/src/main/java/org/teiid/metadata/ViewDefinition.java
Modified:
trunk/api/src/main/java/org/teiid/events/EventDistributor.java
trunk/api/src/main/java/org/teiid/metadata/MetadataProvider.java
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1507 further refining cache invalidation, adding the initial runtime costing logic, and removing the concept of user specific views.
Modified: trunk/api/src/main/java/org/teiid/events/EventDistributor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/events/EventDistributor.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/api/src/main/java/org/teiid/events/EventDistributor.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -24,41 +24,48 @@
import java.util.List;
+import org.teiid.metadata.ColumnStats;
+import org.teiid.metadata.TableStats;
+
/**
* Distributes events across the Teiid cluster
*/
public interface EventDistributor {
/**
- * Update the given materialized view row using the internal mat view name #MAT_VIEWFQN.
+ * Update the given materialized view row.
* The tuple is expected to be in table order, which has the primary key first.
* Deletes need to only send the key, not the entire row contents.
*
* @param vdbName
* @param vdbVersion
- * @param matViewFqn
+ * @param schema
+ * @param viewName
* @param tuple
* @param delete
*/
- void updateMatViewRow(String vdbName, int vdbVersion, String matViewFqn, List<?> tuple, boolean delete);
+ void updateMatViewRow(String vdbName, int vdbVersion, String schema, String viewName, List<?> tuple, boolean delete);
/**
- * Notify that the metadata has been changed for the given fqns.
- * A fqn has the form schema.entityname.
- * This typically implies that the costing metadata has changed, but may also indicate
- * a view definition has changed.
+ * Notify that the metadata has been changed for the given table or view.
* @param vdbName
* @param vdbVersion
- * @param fqns
+ * @param schema
+ * @param objectNames
*/
- void schemaModification(String vdbName, int vdbVersion, String... fqns);
+ void schemaModification(String vdbName, int vdbVersion, String schema, String... objectNames);
/**
* Notify that the table data has changed.
- * A table fqn has the form schema.tablename.
* @param vdbName
* @param vdbVersion
- * @param tableFqns
+ * @param schema
+ * @param tableNames
*/
- void dataModification(String vdbName, int vdbVersion, String... tableFqns);
+ void dataModification(String vdbName, int vdbVersion, String schema, String... tableNames);
+
+ void setTableStats(String vdbName, int vdbVersion, String schemaName, String tableName, TableStats stats);
+
+ void setColumnStats(String vdbName, int vdbVersion, String schemaName, String tableName, String columnName, ColumnStats stats);
+
}
Added: trunk/api/src/main/java/org/teiid/events/EventDistributorFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/events/EventDistributorFactory.java (rev 0)
+++ trunk/api/src/main/java/org/teiid/events/EventDistributorFactory.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -0,0 +1,34 @@
+/*
+ * 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.events;
+
+public interface EventDistributorFactory {
+
+ /**
+ * Get an {@link EventDistributor} that will distribute events to
+ * all members.
+ * @return
+ */
+ EventDistributor getEventDistributor();
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/events/EventDistributorFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/api/src/main/java/org/teiid/metadata/ColumnStats.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/ColumnStats.java (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/ColumnStats.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+public class ColumnStats {
+
+ private int numDistinctValues = -1;
+ private int numNullValues = -1;
+ private String min;
+ private String max;
+
+ public int getNumDistinctValues() {
+ return numDistinctValues;
+ }
+
+ public void setNumDistinctValues(int numDistinctValues) {
+ this.numDistinctValues = numDistinctValues;
+ }
+
+ public int getNumNullValues() {
+ return numNullValues;
+ }
+
+ public void setNumNullValues(int numNullValues) {
+ this.numNullValues = numNullValues;
+ }
+
+ public String getMin() {
+ return min;
+ }
+
+ public void setMin(String min) {
+ this.min = min;
+ }
+
+ public String getMax() {
+ return max;
+ }
+
+ public void setMax(String max) {
+ this.max = max;
+ }
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/metadata/ColumnStats.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataProvider.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataProvider.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataProvider.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -29,35 +29,6 @@
*/
public interface MetadataProvider {
- public enum Scope {
- /**
- * The {@link ViewDefinition} applies only to the calling user
- */
- USER,
- /**
- * The {@link ViewDefinition} applies to all users
- */
- VDB
- }
-
- public static class ViewDefinition {
- private String sql;
- private Scope scope = Scope.VDB;
-
- public ViewDefinition(String sql, Scope scope) {
- this.sql = sql;
- this.scope = scope;
- }
-
- public String getSql() {
- return sql;
- }
-
- public Scope getScope() {
- return scope;
- }
- }
-
/**
* Returns an updated {@link ViewDefinition} or null if the default view definition
* should be used.
Added: trunk/api/src/main/java/org/teiid/metadata/TableStats.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/TableStats.java (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/TableStats.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+public class TableStats {
+
+ private int cardinality;
+
+ public int getCardinality() {
+ return cardinality;
+ }
+
+ public void setCardinality(int cardinality) {
+ this.cardinality = cardinality;
+ }
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/metadata/TableStats.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/api/src/main/java/org/teiid/metadata/ViewDefinition.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/ViewDefinition.java (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/ViewDefinition.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+public class ViewDefinition {
+ private String sql;
+
+ public ViewDefinition(String sql) {
+ this.sql = sql;
+ }
+
+ public String getSql() {
+ return sql;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/api/src/main/java/org/teiid/metadata/ViewDefinition.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -42,9 +42,13 @@
import org.teiid.language.SetQuery;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.TableStats;
@@ -805,6 +809,14 @@
}
+ public boolean updateTableStats(Table table, TableStats stats, C conn) throws TranslatorException {
+ return false;
+ }
+
+ public boolean updateColumnStats(Column column, ColumnStats stats, C conn) throws TranslatorException {
+ return false;
+ }
+
/**
* Indicates if LOBs are usable after the execution is closed.
* @return true if LOBs can be used after close
Modified: trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -197,9 +197,9 @@
* @param splitter Characters to split on
* @return List of String pieces from full string
*/
- public static List split(String str, String splitter) {
+ public static List<String> split(String str, String splitter) {
StringTokenizer tokens = new StringTokenizer(str, splitter);
- ArrayList l = new ArrayList(tokens.countTokens());
+ ArrayList<String> l = new ArrayList<String>(tokens.countTokens());
while(tokens.hasMoreTokens()) {
l.add(tokens.nextToken());
}
@@ -213,8 +213,8 @@
* @param delimiter The sub-string which is used to break the target.
* @return List of String from the target.
*/
- public static List splitOnEntireString(String target, String delimiter) {
- ArrayList result = new ArrayList();
+ public static List<String> splitOnEntireString(String target, String delimiter) {
+ ArrayList<String> result = new ArrayList<String>();
if (delimiter.length() > 0) {
int index = 0;
int indexOfNextMatch = target.indexOf(delimiter);
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -37,6 +37,7 @@
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@@ -60,8 +61,12 @@
import org.teiid.language.SetQuery.Operation;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.TableStats;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ProcedureExecution;
@@ -1084,5 +1089,67 @@
*/
public boolean useSelectLimit() {
return false;
- }
+ }
+
+ public static List<String> parseName(String tableName, char escape, char delim) {
+ boolean quoted = false;
+ boolean escaped = false;
+ List<String> nameParts = new LinkedList<String>();
+ StringBuilder current = new StringBuilder();
+ for (int i = 0; i < tableName.length(); i++) {
+ char c = tableName.charAt(i);
+ if (quoted) {
+ if (c == escape) {
+ if (escaped) {
+ current.append(c);
+ }
+ escaped = !escaped;
+ } else if (c == delim) {
+ if (escaped) {
+ escaped = false;
+ quoted = false;
+ nameParts.add(current.toString());
+ current = new StringBuilder();
+ } else {
+ current.append(c);
+ }
+ } else {
+ current.append(c);
+ }
+ } else {
+ if (c == escape) {
+ if (current.length() == 0) {
+ quoted = true;
+ } else {
+ current.append(c);
+ }
+ } else if (c == delim) {
+ quoted = false;
+ nameParts.add(current.toString());
+ current = new StringBuilder();
+ } else {
+ current.append(c);
+ }
+ }
+ }
+ if (current.length() > 0) {
+ nameParts.add(current.toString());
+ }
+ return nameParts;
+ }
+
+ @Override
+ public boolean updateColumnStats(Column column, ColumnStats stats,
+ Connection conn) throws TranslatorException {
+ // TODO Auto-generated method stub
+ return super.updateColumnStats(column, stats, conn);
+ }
+
+
+ @Override
+ public boolean updateTableStats(Table table, TableStats stats,
+ Connection conn) throws TranslatorException {
+ return super.updateTableStats(table, stats, conn);
+ }
+
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -84,7 +84,6 @@
private boolean widenUnsingedTypes = true;
private boolean quoteNameInSource = true;
private boolean useProcedureSpecificName;
- //TODO add an option to not fully qualify name in source
private Set<String> unsignedTypes = new HashSet<String>();
private String quoteString;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -24,14 +24,20 @@
*/
package org.teiid.translator.jdbc.oracle;
+import java.sql.CallableStatement;
+import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import org.teiid.language.ColumnReference;
import org.teiid.language.Command;
@@ -49,7 +55,10 @@
import org.teiid.language.SetQuery.Operation;
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.TableStats;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -77,6 +86,35 @@
public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
+ private static final String NUMBER = "number"; //$NON-NLS-1$
+ private static final char escape = '"';
+ private static final char delim = '.';
+
+ private final static Map<Class<?>, String> type_to_raw_mapping = new HashMap<Class<?>, String>();
+ private final static Map<Class<?>, Integer> type_to_jdbc_mapping = new HashMap<Class<?>, Integer>();
+ private final static Map<String, String> native_to_raw_mapping = new TreeMap<String, String>();
+
+ static {
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.BYTE, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.SHORT, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.INTEGER, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.LONG, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.FLOAT, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.DOUBLE, NUMBER);
+ type_to_raw_mapping.put(TypeFacility.RUNTIME_TYPES.STRING, "varchar2"); //$NON-NLS-1$
+
+ native_to_raw_mapping.put("varchar2", "varchar2"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("nvarchar2", "nvarchar2"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("binary_float", "binary_float"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("binary_integer", "binary_integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ native_to_raw_mapping.put("binary_double", "binary_double"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.DATE, Types.DATE);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.TIME, Types.DATE);
+ type_to_jdbc_mapping.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, Types.DATE);
+ }
+
public void start() throws TranslatorException {
super.start();
@@ -508,4 +546,157 @@
public boolean supportsAggregatesEnhancedNumeric() {
return true;
}
+
+ @Override
+ public boolean updateTableStats(Table table, TableStats stats, Connection conn)
+ throws TranslatorException {
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String qualifiedTableName = table.getNameInSource();
+ if (qualifiedTableName == null) {
+ return false;
+ }
+ if (DUAL.equalsIgnoreCase(qualifiedTableName)) {
+ stats.setCardinality(1);
+ return false;
+ }
+ List<String> nameParts = JDBCExecutionFactory.parseName(qualifiedTableName, escape, delim);
+ if (nameParts.size() < 2) {
+ return false;
+ }
+ String schemaName = nameParts.get(nameParts.size() - 2);
+ String tableName = nameParts.get(nameParts.size() - 1);
+ try {
+ try {
+ stmt = conn.prepareStatement("select num_rows from ALL_TABLES where owner = ? AND table_name = ?"); //$NON-NLS-1$
+ stmt.setString(1, schemaName);
+ stmt.setString(2, tableName);
+ rs = stmt.executeQuery();
+ if(rs.next()) {
+ stats.setCardinality(rs.getInt(1));
+ return true;
+ }
+ } finally {
+ if(rs != null) {
+ rs.close();
+ }
+ if(stmt != null) {
+ stmt.close();
+ }
+ }
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean updateColumnStats(Column column, ColumnStats stats,
+ Connection conn) throws TranslatorException {
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String columnName = column.getNameInSource();
+ if (columnName == null) {
+ columnName = column.getName();
+ }
+ String qualifiedTableName = column.getParent().getNameInSource();
+ if (qualifiedTableName == null) {
+ return false;
+ }
+ if (DUAL.equalsIgnoreCase(qualifiedTableName)) {
+ return false;
+ }
+ List<String> nameParts = JDBCExecutionFactory.parseName(qualifiedTableName, escape, delim);
+ if (nameParts.size() < 2) {
+ return false;
+ }
+ String schemaName = nameParts.get(nameParts.size() - 2);
+ String tableName = nameParts.get(nameParts.size() - 1);
+ try {
+ try {
+ String sql = "select num_distinct, num_nulls"; //$NON-NLS-1$
+ boolean knownType = true;
+ String type = null;
+ Integer jdbcType = null;
+ if (column.getNativeType() != null) {
+ type = native_to_raw_mapping.get(column.getNativeType());
+ }
+ Class<?> clazzType = TypeFacility.getDataTypeClass(column.getRuntimeType());
+ if (type == null) {
+ type = type_to_raw_mapping.get(clazzType);
+ }
+ if (type != null) {
+ //TODO: could split into two queries to ensure that we at least get the ndv/nnv
+ sql += ", utl_raw.cast_to_"+type+"(low_value), utl_raw.cast_to_"+type+"(high_value)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ //TODO could get type from the databasemetadata or store the type in the extension metadata
+ sql += ", low_value, high_value"; //$NON-NLS-1$
+ knownType = false;
+ jdbcType = type_to_jdbc_mapping.get(clazzType);
+ }
+
+ sql += " from ALL_TAB_COL_STATISTICS where owner=? and TABLE_NAME = ? and COLUMN_NAME = ?"; //$NON-NLS-1$
+ stmt = conn.prepareStatement(sql);
+ stmt.setString(1, schemaName);
+ stmt.setString(2, tableName);
+ stmt.setString(3, columnName);
+ rs = stmt.executeQuery();
+ if(rs.next()) {
+ stats.setNumDistinctValues(rs.getInt(1));
+ stats.setNumNullValues(rs.getInt(2));
+
+ if (jdbcType != null) {
+ byte[] bytes = rs.getBytes(3);
+ String val = getRawAsString(conn, bytes, jdbcType);
+ stats.setMin(val);
+ bytes = rs.getBytes(4);
+ val = getRawAsString(conn, bytes, jdbcType);
+ stats.setMax(val);
+ } else if (knownType) {
+ stats.setMin(rs.getString(3));
+ stats.setMax(rs.getString(4));
+ }
+ //if not a known conversion type (rowid, char, etc.), then we could choose to compensate
+ }
+ } finally {
+ if(rs != null) {
+ rs.close();
+ }
+ if(stmt != null) {
+ stmt.close();
+ }
+ }
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ }
+ return true;
+ }
+
+ /**
+ * @param colStat
+ * @param bytes
+ * @return
+ * @throws SQLException
+ */
+ private String getRawAsString( Connection conn, byte[] bytes, int type ) {
+ CallableStatement cs = null;
+ try {
+ cs = conn.prepareCall("{call dbms_stats.convert_raw_value(?, ?)}"); //$NON-NLS-1$
+ cs.registerOutParameter(2, type);
+ cs.setBytes(1, bytes);
+ cs.execute();
+ String val = cs.getString(2);
+ return val;
+ } catch (SQLException e) {
+ return null; //TODO
+ } finally {
+ if (cs != null) {
+ try {
+ cs.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -23,7 +23,6 @@
package org.teiid.dqp.internal.process;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
@@ -57,6 +56,7 @@
import org.teiid.dqp.internal.process.DQPCore.FutureWork;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.events.EventDistributor;
import org.teiid.metadata.Table;
import org.teiid.query.function.source.XMLSystemFunctions;
import org.teiid.query.processor.relational.RelationalNodeUtil;
@@ -223,21 +223,17 @@
//check for update events
if (index == 0 && this.dtm.detectChangeEvents()) {
Command command = aqr.getCommand();
- ArrayList<String> updates = new ArrayList<String>();
int commandIndex = 0;
if (RelationalNodeUtil.isUpdate(command)) {
long ts = System.currentTimeMillis();
- checkForUpdates(results, command, updates, commandIndex, ts);
+ checkForUpdates(results, command, dtm.getEventDistributor(), commandIndex, ts);
} else if (command instanceof BatchedUpdateCommand) {
long ts = System.currentTimeMillis();
BatchedUpdateCommand bac = (BatchedUpdateCommand)command;
for (Command uc : bac.getUpdateCommands()) {
- checkForUpdates(results, uc, updates, commandIndex++, ts);
+ checkForUpdates(results, uc, dtm.getEventDistributor(), commandIndex++, ts);
}
}
- if (this.dtm.getEventDistributor() != null && !updates.isEmpty()) {
- this.dtm.getEventDistributor().dataModification(this.workItem.getDqpWorkContext().getVdbName(), this.workItem.getDqpWorkContext().getVdbVersion(), updates.toArray(new String[updates.size()]));
- }
}
} catch (TranslatorException e) {
results = exceptionOccurred(e, true);
@@ -268,7 +264,7 @@
}
private void checkForUpdates(AtomicResultsMessage results, Command command,
- ArrayList<String> updates, int commandIndex, long ts) {
+ EventDistributor distributor, int commandIndex, long ts) {
if (!RelationalNodeUtil.isUpdate(command) || !(command instanceof ProcedureContainer)) {
return;
}
@@ -286,8 +282,10 @@
return;
}
Table t = (Table)metadataId;
- updates.add(t.getFullName());
t.setLastDataModification(ts);
+ if (distributor != null) {
+ distributor.dataModification(this.workItem.getDqpWorkContext().getVdbName(), this.workItem.getDqpWorkContext().getVdbVersion(), t.getParent().getName(), t.getName());
+ }
}
private AtomicResultsMessage asynchGet()
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -60,8 +60,8 @@
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.metadata.MetadataProvider;
+import org.teiid.metadata.ViewDefinition;
import org.teiid.metadata.FunctionMethod.Determinism;
-import org.teiid.metadata.MetadataProvider.ViewDefinition;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -136,9 +136,6 @@
ViewDefinition vd = metadataProvider.getViewDefinition(schema, viewName, context);
if (vd != null) {
result = new QueryNode(DataTypeManager.getCanonicalString(vd.getSql()));
- if (vd.getScope() == MetadataProvider.Scope.USER) {
- result.setUser(context.getUserName());
- }
}
qnodes.put(groupID, result);
return result;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -44,7 +44,6 @@
// Initial state
private String query;
private List<String> bindings; // optional - construct if needed
- private String user;
// After parsing and resolution
private Command command;
private UpdateInfo updateInfo;
@@ -126,14 +125,6 @@
return query;
}
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
public UpdateInfo getUpdateInfo() {
return updateInfo;
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -434,9 +434,6 @@
QueryValidatorException {
qmi = qmi.getDesignTimeMetadata();
cacheString = "transformation/" + cacheString; //$NON-NLS-1$
- if (qnode.getUser() != null) {
- cacheString += "/" + qnode.getUser(); //$NON-NLS-1$
- }
QueryNode cachedNode = (QueryNode)qmi.getFromMetadataCache(virtualGroup.getMetadataID(), cacheString);
if (cachedNode == null
|| (qnode.getQuery() != null && !cachedNode.getQuery().equals(qnode.getQuery()))
@@ -474,7 +471,6 @@
}
cachedNode = new QueryNode(qnode.getQuery());
cachedNode.setCommand((Command)result.clone());
- cachedNode.setUser(qnode.getUser());
if(isView(virtualGroup, qmi)) {
String updatePlan = qmi.getUpdatePlan(virtualGroup.getMetadataID());
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -361,7 +361,7 @@
}
List<?> result = updateMatViewRow(globalStore, matTableName, tuple, delete);
if (result != null && eventDistributor != null) {
- this.eventDistributor.updateMatViewRow(context.getVdbName(), context.getVdbVersion(), matTableName, tuple, delete);
+ this.eventDistributor.updateMatViewRow(context.getVdbName(), context.getVdbVersion(), metadata.getName(metadata.getModelID(groupID)), metadata.getName(groupID), tuple, delete);
}
return CollectionTupleSource.createUpdateCountTupleSource(result != null ? 1 : 0);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -51,6 +51,7 @@
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.dqp.service.BufferService;
import org.teiid.metadata.MetadataProvider;
+import org.teiid.metadata.ViewDefinition;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -335,10 +336,10 @@
public ViewDefinition getViewDefinition(String schema,
String viewName, CommandContext context) {
if (callCount++ > 0) {
- ViewDefinition vd = new ViewDefinition("SELECT 'something else'", Scope.USER);
+ ViewDefinition vd = new ViewDefinition("SELECT 'something else'");
return vd;
}
- ViewDefinition vd = new ViewDefinition("SELECT 'hello world'", Scope.USER);
+ ViewDefinition vd = new ViewDefinition("SELECT 'hello world'");
return vd;
}
});
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-04-15 18:12:29 UTC (rev 3094)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-04-15 20:44:09 UTC (rev 3095)
@@ -70,6 +70,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.adminapi.jboss.AdminProvider;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.cache.CacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
@@ -95,15 +96,21 @@
import org.teiid.dqp.service.SessionServiceException;
import org.teiid.dqp.service.TransactionService;
import org.teiid.events.EventDistributor;
+import org.teiid.events.EventDistributorFactory;
import org.teiid.jboss.IntegrationPlugin;
import org.teiid.logging.Log4jListener;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnStats;
+import org.teiid.metadata.Schema;
import org.teiid.metadata.Table;
+import org.teiid.metadata.TableStats;
import org.teiid.net.TeiidURL;
import org.teiid.query.QueryPlugin;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.security.SecurityHelper;
import org.teiid.transport.ClientServiceRegistry;
@@ -116,7 +123,7 @@
@ManagementObject(name="RuntimeEngineDeployer", isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
-public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry, EventDistributor {
+public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry, EventDistributor, EventDistributorFactory {
private static final long serialVersionUID = -4676205340262775388L;
private transient SocketConfiguration jdbcSocketConfiguration;
@@ -641,8 +648,8 @@
}
@Override
- public void updateMatViewRow(String vdbName, int vdbVersion, String matViewFqn, List<?> tuple,
- boolean delete) {
+ public void updateMatViewRow(String vdbName, int vdbVersion, String schema,
+ String viewName, List<?> tuple, boolean delete) {
VDBMetaData vdb = this.vdbRepository.getVDB(vdbName, vdbVersion);
if (vdb == null) {
return;
@@ -652,14 +659,26 @@
return;
}
try {
- this.dqpCore.getDataTierManager().updateMatViewRow(globalStore, matViewFqn, tuple, delete);
+ this.dqpCore.getDataTierManager().updateMatViewRow(globalStore, RelationalPlanner.MAT_PREFIX + (schema + '.' + viewName).toUpperCase(), tuple, delete);
} catch (TeiidException e) {
LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
}
}
@Override
- public void dataModification(String vdbName, int vdbVersion, String... tableFqns) {
+ public void dataModification(String vdbName, int vdbVersion, String schema,
+ String... tableNames) {
+ updateModified(true, vdbName, vdbVersion, schema, tableNames);
+ }
+
+ @Override
+ public void schemaModification(String vdbName, int vdbVersion,
+ String schema, String... objectNames) {
+ updateModified(false, vdbName, vdbVersion, schema, objectNames);
+ }
+
+ private void updateModified(boolean data, String vdbName, int vdbVersion, String schema,
+ String... objectNames) {
VDBMetaData vdb = this.vdbRepository.getVDB(vdbName, vdbVersion);
if (vdb == null) {
return;
@@ -668,33 +687,80 @@
if (tm == null) {
return;
}
- for (String tableFqn:tableFqns) {
- try {
- Table table = tm.getGroupID(tableFqn);
- table.setLastDataModification(System.currentTimeMillis());
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
+ try {
+ Schema s = tm.getMetadataStore().getSchema(schema.toUpperCase());
+ long ts = System.currentTimeMillis();
+ for (String name:objectNames) {
+ Table table = s.getTables().get(name);
+ if (table == null) {
+ continue;
+ }
+ if (data) {
+ table.setLastDataModification(ts);
+ } else {
+ table.setLastModified(ts);
+ }
}
+ } catch (TeiidException e) {
+ LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
}
}
@Override
- public void schemaModification(String vdbName, int vdbVersion, String... fqns) {
+ public void setColumnStats(String vdbName, int vdbVersion,
+ String schemaName, String tableName, String columnName,
+ ColumnStats stats) {
+ Table t = getTable(vdbName, vdbVersion, schemaName, tableName);
+ if (t == null) {
+ return;
+ }
+ for (Column c : t.getColumns()) {
+ if (c.getName().equalsIgnoreCase(columnName)) {
+ c.setDistinctValues(stats.getNumDistinctValues());
+ c.setNullValues(stats.getNumNullValues());
+ c.setMaximumValue(stats.getMax());
+ c.setMinimumValue(stats.getMin());
+ t.setLastModified(System.currentTimeMillis());
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void setTableStats(String vdbName, int vdbVersion,
+ String schemaName, String tableName, TableStats stats) {
+ Table t = getTable(vdbName, vdbVersion, schemaName, tableName);
+ if (t == null) {
+ return;
+ }
+ t.setCardinality(stats.getCardinality());
+ t.setLastModified(System.currentTimeMillis());
+ }
+
+ private Table getTable(String vdbName, int vdbVersion, String schemaName,
+ String tableName) {
VDBMetaData vdb = this.vdbRepository.getVDB(vdbName, vdbVersion);
if (vdb == null) {
- return;
+ return null;
}
TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
if (tm == null) {
- return;
+ return null;
}
- for (String fqn:fqns) {
- try {
- Table table = tm.getGroupID(fqn);
- table.setLastModified(System.currentTimeMillis());
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
- }
+ Schema s;
+ try {
+ s = tm.getMetadataStore().getSchema(schemaName.toUpperCase());
+ } catch (QueryMetadataException e) {
+ LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
+ return null;
}
+ return s.getTables().get(tableName.toUpperCase());
}
+
+ public EventDistributor getEventDistributor() {
+ if (this.eventDistributor != null) {
+ return eventDistributor;
+ }
+ return this;
+ }
}
13 years, 9 months
teiid SVN: r3094 - in trunk: common-core/src/test/java/org/teiid/core/types and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-15 14:12:29 -0400 (Fri, 15 Apr 2011)
New Revision: 3094
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
Log:
TEIID-1011: adding the conversion between the Object[] and Object acceptable. Also returning the results as Object[] from the OLAP Execution factory.
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15 13:59:42 UTC (rev 3093)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15 18:12:29 UTC (rev 3094)
@@ -772,7 +772,7 @@
@SuppressWarnings("unchecked")
public static <T> T transformValue(Object value, Class sourceType,
Class<T> targetClass) throws TransformationException {
- if (value == null || sourceType == targetClass) {
+ if (value == null || sourceType == targetClass || DefaultDataClasses.OBJECT == targetClass) {
return (T) value;
}
Transform transform = DataTypeManager.getTransform(sourceType,
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15 13:59:42 UTC (rev 3093)
+++ trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15 18:12:29 UTC (rev 3094)
@@ -222,4 +222,9 @@
assertEquals("hello", DataTypeManager.transformValue(new Foo(), DataTypeManager.DefaultDataClasses.STRING)); //$NON-NLS-1$
}
+ @SuppressWarnings("unchecked")
+ @Test public void testObjectArrayToObject() throws Exception {
+ Object[] value = {1,2};
+ assertArrayEquals(value, (Object[])DataTypeManager.transformValue(value, value.getClass(), DataTypeManager.DefaultDataClasses.OBJECT));
+ }
}
Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-04-15 13:59:42 UTC (rev 3093)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-04-15 18:12:29 UTC (rev 3094)
@@ -22,7 +22,7 @@
package org.teiid.translator.olap;
import java.sql.SQLException;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@@ -126,8 +126,10 @@
for (Position colPos : cols) {
Cell cell = cellSet.getCell(colPos, nextRow);
result[i++] = cell.getValue();
- }
- return Arrays.asList(result);
+ }
+ ArrayList<Object[]> results = new ArrayList<Object[]>();
+ results.add(result);
+ return results;
}
@Override
13 years, 9 months