teiid SVN: r2924 - in trunk: client/src/main/java/org/teiid/adminapi and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-22 20:33:24 -0500 (Tue, 22 Feb 2011)
New Revision: 2924
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/client/src/main/java/org/teiid/adminapi/Model.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-1470 updating dynamic vdb deployment logic
Modified: trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2011-02-22 20:58:00 UTC (rev 2923)
+++ trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2011-02-23 01:33:24 UTC (rev 2924)
@@ -83,6 +83,7 @@
<bean name="VDBStatusChecker" class="org.teiid.deployers.VDBStatusChecker">
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="threadPool"><inject bean="jboss.system:service=ThreadPool"/></property>
</bean>
<!-- Persistence class for the VDB deployment file -->
Modified: trunk/client/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Model.java 2011-02-22 20:58:00 UTC (rev 2923)
+++ trunk/client/src/main/java/org/teiid/adminapi/Model.java 2011-02-23 01:33:24 UTC (rev 2924)
@@ -62,14 +62,14 @@
Type getModelType();
/**
- * Determine whether this model can support more than one connector binding.
+ * Determine whether this model can support more than one source.
*
- * @return <code>true</code> if this model supports multi-source bindings
+ * @return <code>true</code> if this model supports multiple sources
*/
boolean isSupportsMultiSourceBindings();
/**
- * Associated Source Names for the Models (Connector Bindings)
+ * Associated Source Names for the Models
* @return String
*/
List<String> getSourceNames();
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-02-22 20:58:00 UTC (rev 2923)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-02-23 01:33:24 UTC (rev 2924)
@@ -301,28 +301,41 @@
}
if (!loaded) {
- 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$
- final ValidationError addedError = model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
threadPool.run(new Runnable() {
@Override
public void run() {
- loadMetadata(vdb, model, cache, cacheFile, vdbStore, cmr, addedError);
+ Boolean loadStatus = loadMetadata(vdb, model, cache, cacheFile, vdbStore, cmr);
+ //if (loadStatus == null) {
+ //TODO: a source is up, but we failed. should we retry or poll?
+ //}
+ if (loadStatus == null || !loadStatus) {
+ //defer the load to the status checker if/when a source is available/redeployed
+ model.addAttchment(Runnable.class, this);
+ }
}
});
}
}
}
- private void loadMetadata(VDBMetaData vdb, ModelMetaData model, boolean cache, File cacheFile, MetadataStoreGroup vdbStore, ConnectorManagerRepository cmr, ValidationError addedError) {
- Exception exception = null;
-
- boolean loaded = false;
+ /**
+ * @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$
+ final ValidationError addedError = model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
+
+ String exceptionMessage = null;
+ Boolean loaded = false;
for (String sourceName: model.getSourceNames()) {
ConnectorManager cm = cmr.getConnectorManager(sourceName);
- if (cm == null) {
- continue;
- }
+ String status = cm.getStausMessage();
+ if (status != null && status.length() > 0) {
+ exceptionMessage = status;
+ continue;
+ }
+ loaded = null;
try {
MetadataStore store = cm.getMetadata(model.getName(), this.vdbRepository.getBuiltinDatatypes(), model.getProperties());
if (cache) {
@@ -333,34 +346,34 @@
loaded = true;
break;
} catch (TranslatorException e) {
- if (exception == null) {
- exception = e;
+ //TODO: we aren't effectively differentiating the type of load error - connectivity vs. metadata
+ if (exceptionMessage == null) {
+ exceptionMessage = e.getMessage();
}
} catch (IOException e) {
- if (exception == null) {
- exception = e;
+ if (exceptionMessage == null) {
+ exceptionMessage = e.getMessage();
}
}
}
synchronized (vdb) {
- if (!loaded) {
+ if (loaded == null || !loaded) {
vdb.setStatus(VDB.Status.INACTIVE);
- String msg = RuntimePlugin.Util.getString("failed_to_retrive_metadata", vdb.getName()+"-"+vdb.getVersion(), model.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
- if (exception != null) {
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), exception.getMessage());
+ 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$
+ 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, msg);
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, failed_msg);
+ } else if (vdb.isValid()) {
+ this.vdbRepository.updateVDB(vdb.getName(), vdb.getVersion());
+ vdb.setStatus(VDB.Status.ACTIVE);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
}
- else {
- if (vdb.isValid()) {
- this.vdbRepository.updateVDB(vdb.getName(), vdb.getVersion());
- vdb.setStatus(VDB.Status.ACTIVE);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
- }
}
+
+ return loaded;
}
private File buildCachedModelFileName(VFSDeploymentUnit unit, VDBMetaData vdb, String modelName) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-02-22 20:58:00 UTC (rev 2923)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-02-23 01:33:24 UTC (rev 2924)
@@ -21,6 +21,9 @@
*/
package org.teiid.deployers;
+import java.util.LinkedList;
+
+import org.jboss.util.threadpool.ThreadPool;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -35,6 +38,7 @@
public class VDBStatusChecker {
private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
private VDBRepository vdbRepository;
+ private ThreadPool threadPool;
public void translatorAdded(String translatorName) {
resourceAdded(translatorName, true);
@@ -67,6 +71,7 @@
if (vdb.getStatus() == VDB.Status.ACTIVE || vdb.isPreview()) {
continue;
}
+ LinkedList<Runnable> runnables = new LinkedList<Runnable>();
synchronized (vdb) {
ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
@@ -84,7 +89,13 @@
if (status != null && status.length() > 0) {
model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), status);
LogManager.logInfo(LogConstants.CTX_RUNTIME, status);
- }
+ } else {
+ //get the pending metadata load
+ Runnable r = model.removeAttachment(Runnable.class);
+ if (r != null) {
+ runnables.add(r);
+ }
+ }
}
}
@@ -97,7 +108,12 @@
}
}
- if (valid) {
+ if (!runnables.isEmpty()) {
+ //the task themselves will set the status on completion/failure
+ for (Runnable runnable : runnables) {
+ this.threadPool.run(runnable);
+ }
+ } else if (valid) {
vdb.setStatus(VDB.Status.ACTIVE);
LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
}
@@ -150,5 +166,9 @@
}
}
return null;
- }
+ }
+
+ public void setThreadPool(ThreadPool threadPool) {
+ this.threadPool = threadPool;
+ }
}
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-02-22 20:58:00 UTC (rev 2923)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-02-23 01:33:24 UTC (rev 2924)
@@ -58,7 +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. Fix errors and re-deploy the VDB.
+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.
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}
13 years, 10 months
teiid SVN: r2923 - in trunk/documentation: reference/src/main/docbook/en-US/content and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-22 15:58:00 -0500 (Tue, 22 Feb 2011)
New Revision: 2923
Modified:
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
minor doc updates correcting verbage in matviews and changing the note for olap
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-02-22 20:57:16 UTC (rev 2922)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-02-22 20:58:00 UTC (rev 2923)
@@ -60,7 +60,7 @@
Constraints or other database features cannot be added to internal materialization tables.</para>
</listitem>
<listitem><para>The data volume is large. Internal materialization (and temp tables in general) have memory overhead for each page.
- A rough guideline is that no more than 100 million rows should in all materializated tables across all VDBs for every 1 gigabyte of heap.</para>
+ A rough guideline is that there can be 100 million rows in all materializated tables across all VDBs for every gigabyte of heap.</para>
</listitem>
</itemizedlist>
</para>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-02-22 20:57:16 UTC (rev 2922)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-02-22 20:58:00 UTC (rev 2923)
@@ -1048,7 +1048,7 @@
<para>
The results of the query will be returned such that each row on the row axis will be packed into an array value that will first contain each hierarcy member name on the row axis then each measure value from the column axis.
</para>
- <note><para>Currently the resultset only supports 2 dimentional cube.</para></note>
+ <note><para>The use of <xref linkend="dataroles"/> should be considered to prevent arbitrary MDX from being submitted to the invokeMDX procedure.</para></note>
<para>
This translator requires a data source to be configured to the OLAP cube using OLAP4J JDBC driver. Two sample
-ds.xml files provided for accessing OLAP servers in teiid-examples section. One is Mondrian specific, when Mondrian server is deloyed
13 years, 10 months
teiid SVN: r2922 - trunk/runtime/src/main/java/org/teiid/transport.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-22 15:57:16 -0500 (Tue, 22 Feb 2011)
New Revision: 2922
Modified:
trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
Log:
foward merging 7.1.1
Modified: trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-02-22 20:56:11 UTC (rev 2921)
+++ trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-02-22 20:57:16 UTC (rev 2922)
@@ -150,7 +150,7 @@
// application_name was not reported by releases before 9.0.)
sendParameterStatus("client_encoding", this.encoding.name());
- sendParameterStatus("DateStyle", this.props.getProperty("DateStyle"));
+ sendParameterStatus("DateStyle", this.props.getProperty("DateStyle", "ISO"));
sendParameterStatus("integer_datetimes", "off");
sendParameterStatus("is_superuser", "off");
sendParameterStatus("server_encoding", "SQL_ASCII");
@@ -206,7 +206,9 @@
}
public void setEncoding(Charset value) {
- this.encoding = value;
+ if (value != null) {
+ this.encoding = value;
+ }
}
@Override
13 years, 10 months
teiid SVN: r2921 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-22 15:56:11 -0500 (Tue, 22 Feb 2011)
New Revision: 2921
Modified:
trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
Log:
TEIID-1478 minor importing updates
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2011-02-22 17:36:19 UTC (rev 2920)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2011-02-22 20:56:11 UTC (rev 2921)
@@ -46,6 +46,7 @@
private Map<String, Datatype> dataTypes;
private Properties importProperties;
private MetadataStore store = new MetadataStore();
+ private boolean autoCorrectColumnNames = true;
public MetadataFactory(String modelName, Map<String, Datatype> dataTypes, Properties importProperties) {
this.dataTypes = dataTypes;
@@ -92,7 +93,10 @@
* @throws TranslatorException
*/
public Column addColumn(String name, String type, ColumnSet<?> table) throws TranslatorException {
- if (name.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR) != -1) {
+ if (autoCorrectColumnNames) {
+ name.replace(AbstractMetadataRecord.NAME_DELIM_CHAR, '_');
+ } else if (name.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR) != -1) {
+ //TODO: for now this is not used
throw new TranslatorException(DataPlugin.Util.getString("MetadataFactory.invalid_name", name)); //$NON-NLS-1$
}
Column column = new Column();
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-02-22 17:36:19 UTC (rev 2920)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-02-22 20:56:11 UTC (rev 2921)
@@ -156,12 +156,14 @@
continue; //there's a good chance this won't work
}
BaseColumn record = null;
+ int precision = columns.getInt(8);
+ String runtimeType = getRuntimeType(sqlType, typeName, precision);
if (columnType == DatabaseMetaData.procedureColumnResult) {
- Column column = metadataFactory.addProcedureResultSetColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), procedure);
+ Column column = metadataFactory.addProcedureResultSetColumn(columnName, runtimeType, procedure);
record = column;
column.setNativeType(typeName);
} else {
- record = metadataFactory.addProcedureParameter(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), Type.values()[columnType], procedure);
+ record = metadataFactory.addProcedureParameter(columnName, runtimeType, Type.values()[columnType], procedure);
}
record.setPrecision(columns.getInt(8));
record.setLength(columns.getInt(9));
@@ -236,16 +238,38 @@
String columnName = columns.getString(4);
int type = columns.getInt(5);
String typeName = columns.getString(6);
- type = checkForUnsigned(type, typeName);
+ int columnLength = columns.getInt(7);
+ String runtimeType = getRuntimeType(type, typeName, columnLength);
//note that the resultset is already ordered by position, so we can rely on just adding columns in order
- Column column = metadataFactory.addColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(type), tableInfo.table);
+ Column column = metadataFactory.addColumn(columnName, runtimeType, tableInfo.table);
column.setNameInSource(quoteName(columnName));
- column.setNativeType(columns.getString(6));
+ column.setPrecision(columnLength);
+ column.setNativeType(typeName);
column.setRadix(columns.getInt(10));
column.setNullType(NullType.values()[columns.getShort(11)]);
column.setUpdatable(true);
String remarks = columns.getString(12);
column.setAnnotation(remarks);
+ String defaultValue = columns.getString(13);
+ column.setDefaultValue(defaultValue);
+ if (defaultValue != null && type == Types.BIT && TypeFacility.RUNTIME_NAMES.BOOLEAN.equals(runtimeType)) {
+ //try to determine a usable boolean value
+ if(defaultValue.length() == 1) {
+ int charIntVal = defaultValue.charAt(0);
+ // Set boolean FALse for incoming 0, TRUE for 1
+ if(charIntVal==0) {
+ column.setDefaultValue(Boolean.FALSE.toString());
+ } else if(charIntVal==1) {
+ column.setDefaultValue(Boolean.TRUE.toString());
+ }
+ } else { //SQLServer quotes bit values
+ String trimedDefault = defaultValue.trim();
+ if (defaultValue.startsWith("(") && defaultValue.endsWith(")")) {
+ trimedDefault = defaultValue.substring(1, defaultValue.length() - 1);
+ }
+ column.setDefaultValue(trimedDefault);
+ }
+ }
column.setCharOctetLength(columns.getInt(16));
if (rsColumns >= 23) {
column.setAutoIncremented("YES".equalsIgnoreCase(columns.getString(23))); //$NON-NLS-1$
@@ -253,6 +277,14 @@
}
columns.close();
}
+
+ private String getRuntimeType(int type, String typeName, int precision) {
+ if (type == Types.BIT && precision > 1) {
+ type = Types.BINARY;
+ }
+ type = checkForUnsigned(type, typeName);
+ return TypeFacility.getDataTypeNameFromSQLType(type);
+ }
private String quoteName(String name) {
if (quoteNameInSource) {
@@ -318,7 +350,8 @@
String fullTableName = getFullyQualifiedName(tableCatalog, tableSchema, tableName);
pkTable = tableMap.get(fullTableName);
if (pkTable == null) {
- throw new TranslatorException(JDBCPlugin.Util.getString("JDBCMetadataProcessor.cannot_find_primary", fullTableName)); //$NON-NLS-1$
+ //throw new TranslatorException(JDBCPlugin.Util.getString("JDBCMetadataProcessor.cannot_find_primary", fullTableName)); //$NON-NLS-1$
+ continue; //just drop the foreign key, the user probably didn't import the other table
}
fkName = fks.getString(12);
if (fkName == null) {
Modified: trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2011-02-22 17:36:19 UTC (rev 2920)
+++ trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2011-02-22 20:56:11 UTC (rev 2921)
@@ -29,7 +29,3 @@
ConnectionListener.failed_to_report_jdbc_connection_details=Failed to report the JDBC driver and connection information
-
-
-
-JDBCMetadataProcessor.cannot_find_primary=Cannot find primary key table {0}
13 years, 10 months
teiid SVN: r2920 - branches/7.1.x/runtime/src/main/java/org/teiid/transport.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-02-22 12:36:19 -0500 (Tue, 22 Feb 2011)
New Revision: 2920
Modified:
branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
Log:
TEIID-1477: The older clients were not setting the "DateStyle" property which is always present in the newer version of the driver. The code is written to expect it, now it supplies the default DateStyle as ISO, if not found one.
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-02-21 14:57:16 UTC (rev 2919)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-02-22 17:36:19 UTC (rev 2920)
@@ -139,7 +139,7 @@
// application_name was not reported by releases before 9.0.)
sendParameterStatus("client_encoding", this.encoding.name());
- sendParameterStatus("DateStyle", this.props.getProperty("DateStyle"));
+ sendParameterStatus("DateStyle", this.props.getProperty("DateStyle", "ISO"));
sendParameterStatus("integer_datetimes", "off");
sendParameterStatus("is_superuser", "off");
sendParameterStatus("server_encoding", "SQL_ASCII");
@@ -195,7 +195,9 @@
}
public void setEncoding(Charset value) {
- this.encoding = value;
+ if (value != null) {
+ this.encoding = value;
+ }
}
@Override
13 years, 10 months
teiid SVN: r2919 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-02-21 09:57:16 -0500 (Mon, 21 Feb 2011)
New Revision: 2919
Added:
trunk/build/kits/jboss-container/teiid-examples/jca/Ingres-xa-ds.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java
Modified:
trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
Log:
TEIID-1059: Adding translator for Ingres database.
Added: trunk/build/kits/jboss-container/teiid-examples/jca/Ingres-xa-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/Ingres-xa-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/Ingres-xa-ds.xml 2011-02-21 14:57:16 UTC (rev 2919)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<datasources>
+ <xa-datasource>
+ <jndi-name>ingresDS</jndi-name>
+
+ <xa-datasource-class>com.ingres.jdbc.IngresXADataSource</xa-datasource-class>
+ <xa-datasource-property name="DatabaseName">{database}</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">21071</xa-datasource-property>
+ <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
+ <xa-datasource-property name="timeZone">GMT</xa-datasource-property>
+ <user-name>user</user-name>
+ <password>password</password>
+
+ <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
+
+ <max-pool-size>5</max-pool-size>
+ <min-pool-size>1</min-pool-size>
+
+ <blocking-timeout-millis>2000</blocking-timeout-millis>
+ <idle-timeout-minutes>2</idle-timeout-minutes>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <no-tx-separate-pools>true</no-tx-separate-pools>
+ </xa-datasource>
+</datasources>
Property changes on: trunk/build/kits/jboss-container/teiid-examples/jca/Ingres-xa-ds.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-02-21 14:57:16 UTC (rev 2919)
@@ -0,0 +1,275 @@
+/*
+ * 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.translator.jdbc.ingres;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Limit;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+@Translator(name="ingres", description="A translator for Ingres Database")
+public class IngresExecutionFactory extends JDBCExecutionFactory {
+
+ private static final String INGRES = "ingres"; //$NON-NLS-1$
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ ConvertModifier convert = new ConvertModifier();
+ convert.addTypeMapping("bit", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convert.addTypeMapping("integer", FunctionModifier.INTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convert.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convert.addTypeMapping("float", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(15,0)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(38,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convert.addTypeMapping("time with time zone", FunctionModifier.TIME); //$NON-NLS-1$
+ convert.addTypeMapping("timestamp with time zone", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convert.addTypeMapping("varchar($1)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addTypeMapping("long varchar", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addTypeMapping("blob", FunctionModifier.BLOB); //$NON-NLS-1$
+ convert.addTypeMapping("clob", FunctionModifier.CLOB); //$NON-NLS-1$
+ convert.addTypeMapping("byte($1)", FunctionModifier.OBJECT); //$NON-NLS-1$
+ convert.addTypeMapping("long byte", FunctionModifier.OBJECT); //$NON-NLS-1$
+ convert.addTypeMapping("varbyte($1)", FunctionModifier.OBJECT); //$NON-NLS-1$
+ convert.addTypeMapping("ansidate", FunctionModifier.DATE); //$NON-NLS-1$
+ convert.addTypeMapping("timestamp(9) with time zone", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("bit_and")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("bit_not")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("bit_or")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("bit_xor")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("current_time")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("current_date")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lowercase")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("uppercase")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
+ registerFunctionModifier("bitadd", new AliasModifier("bit_add")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.CONCAT);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ return supportedFunctions;
+ }
+
+ @Override
+ public List<FunctionMethod> getPushDownFunctions(){
+ List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bitadd", "bitadd", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, ""), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("integer2", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bit_length", "bit_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "character_length", "character_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "charextract", "charextract", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // uses ingres date??
+ //supportedFunctions.add("date_trunc");
+ //supportedFunctions.add("dow");
+ //supportedFunctions.add("extract");
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "gmt_timestamp", "gmt_timestamp", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hash", "hash", INGRES,//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hex", "hex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // do not have byte[] type
+ //supportedFunctions.add("intextract");
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "ln", "ln", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float1", DataTypeManager.DefaultDataTypes.DOUBLE, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // see lowercase
+ // supportedFunctions.add("lower");
+ // supportedFunctions.add("upper");
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "octet_length", "octet_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad", "pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad", "pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "randomf", "randomf", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "session_user", "session_user", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "size", "size", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "squeeze", "squeeze", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "soundex", "soundex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "unhex", "unhex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "usercode", "usercode", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "username", "username", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ignore
+ // supportedFunctions.add("uuid_create");
+ // supportedFunctions.add("uuid_compare");
+ // supportedFunctions.add("uuid_from_char");
+ // supportedFunctions.add("uuid_to_char");
+
+ return pushdownFunctions;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ return Arrays.asList("FETCH FIRST ", limit.getRowLimit(), " ROWS ONLY"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.LAST;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java 2011-02-21 14:57:16 UTC (rev 2919)
@@ -0,0 +1,48 @@
+/*
+ * 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.translator.jdbc.ingres;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.FunctionModifier;
+
+public class LocateFunctionModifier extends FunctionModifier {
+
+ private LanguageFactory languageFactory;
+
+ public LocateFunctionModifier(LanguageFactory languageFactory) {
+ this.languageFactory = languageFactory;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression a = function.getParameters().get(0);
+ Expression b = function.getParameters().get(1);
+
+ return Arrays.asList(languageFactory.createFunction("locate", new Expression[] {b, a}, TypeFacility.RUNTIME_TYPES.INTEGER)); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2011-02-18 15:19:32 UTC (rev 2918)
+++ trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2011-02-21 14:57:16 UTC (rev 2919)
@@ -288,4 +288,20 @@
<parameter class="java.lang.String">Modeshape</parameter>
</constructor>
</bean>
+
+ <!-- Ingres -->
+ <bean name="translator-ingres-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-ingres" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-ingres" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.jdbc.ingres.IngresExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-ingres</parameter>
+ <parameter class="java.lang.String">Ingres</parameter>
+ </constructor>
+ </bean>
</deployment>
\ No newline at end of file
13 years, 10 months
teiid SVN: r2918 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-18 10:19:32 -0500 (Fri, 18 Feb 2011)
New Revision: 2918
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1475 refining previous approach
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-02-17 18:55:02 UTC (rev 2917)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-02-18 15:19:32 UTC (rev 2918)
@@ -204,58 +204,59 @@
return null;
}
StringBuilder sb = new StringBuilder(exact ? maxLength : (maxLength >> 4));
+ while (true) {
+ char c = readChar();
+ if (c == '\n') {
+ if (sb.length() == 0) {
+ if (eof) {
+ return null;
+ }
+ continue; //skip empty lines
+ }
+ if (exact && sb.length() < lineWidth) {
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.invalid_width", sb.length(), lineWidth, textLine, systemId)); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+ sb.append(c);
+ if (sb.length() > maxLength) {
+ if (exact) {
+ sb.deleteCharAt(sb.length() - 1);
+ //we're not forcing them to fully specify the line, so just drop the rest
+ //TODO: there should be a max read length
+ while (readChar() != '\n') {
+
+ }
+ return sb.toString();
+ }
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.line_too_long", textLine+1, systemId, maxLength)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ private char readChar() throws TeiidProcessingException {
try {
- while (true) {
- char c = readChar();
+ int c = reader.read();
+ if (cr) {
if (c == '\n') {
- if (sb.length() == 0) {
- if (eof) {
- return null;
- }
- continue; //skip empty lines
- }
- if (exact && sb.length() < lineWidth) {
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.invalid_width", sb.length(), lineWidth, textLine, systemId)); //$NON-NLS-1$
- }
- return sb.toString();
- }
- sb.append(c);
- if (sb.length() > maxLength) {
- if (exact) {
- //we're not forcing them to fully specify the line, so just drop the rest
- //TODO: there should be a max read length
- while ((c = readChar()) != '\n') {
-
- }
- return sb.toString();
- }
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.line_too_long", textLine+1, systemId, maxLength)); //$NON-NLS-1$
- }
- }
+ c = reader.read();
+ }
+ cr = false;
+ }
+ switch (c) {
+ case '\r':
+ cr = true;
+ case -1:
+ eof = true;
+ case '\n':
+ textLine++;
+ return '\n';
+ }
+ return (char)c;
} catch (IOException e) {
throw new TeiidProcessingException(e);
}
}
-
- private char readChar() throws IOException {
- int c = reader.read();
- if (cr) {
- if (c == '\n') {
- c = reader.read();
- }
- cr = false;
- }
- switch (c) {
- case '\r':
- cr = true;
- case -1:
- eof = true;
- case '\n':
- textLine++;
- return '\n';
- }
- return (char)c;
- }
private void initReader() throws ExpressionEvaluationException,
BlockedException, TeiidComponentException, TeiidProcessingException {
@@ -291,14 +292,17 @@
}
while (textLine < skip) {
boolean isHeader = textLine == header;
- //if we don't need a header, then we could just scan, but for now we'll enforce a max length
- String line = readLine(Math.min(lineWidth, DataTypeManager.MAX_STRING_LENGTH), false);
- if (line == null) { //just return an empty batch
- reset();
- return;
- }
if (isHeader) {
+ String line = readLine(lineWidth, false);
+ if (line == null) { //just return an empty batch
+ reset();
+ return;
+ }
processHeader(parseLine(line));
+ } else {
+ while (readChar() != '\n') {
+
+ }
}
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-02-17 18:55:02 UTC (rev 2917)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-02-18 15:19:32 UTC (rev 2918)
@@ -63,10 +63,10 @@
}
@Test public void testTextTableFixed() throws Exception {
- String sql = "select count(*) from texttable(? COLUMNS compkey string width 78, CDM_ID string width 14, CURRENCY string width 9, \"START\" string width 31, MATURITY string width 38, AMOUNT double width 13, RECORDSOURCE string width 13, SUMMIT_ID string width 25, RATE double width 21, SPREAD double width 9, DESK string width 13) x"; //$NON-NLS-1$
+ String sql = "select max(compkey), max(cdm_id), max(currency), max(\"start\"), max(maturity), max(amount), count(*) from texttable(? COLUMNS compkey string width 76, CDM_ID string width 14, CURRENCY string width 9, \"START\" string width 31, MATURITY string width 31, AMOUNT double width 21, RECORDSOURCE string width 13, SUMMIT_ID string width 15, RATE double width 20, SPREAD double width 20, DESK string width 14) x"; //$NON-NLS-1$
List[] expected = new List[] {
- Arrays.asList(52),
+ Arrays.asList("000369USD05/20/200405/20/2007", "000369", "USD", "12/18/2000", "12/19/2005", 6.7209685146E8, 52),
};
FakeDataManager dataManager = new FakeDataManager();
@@ -75,6 +75,19 @@
processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(clobFromFile("text/cdm_dos.txt")));
}
+ @Test public void testTextTableFixedPartial() throws Exception {
+ String sql = "select max(length(compkey)) from texttable(? COLUMNS compkey string width 76) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(30),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(clobFromFile("text/cdm_dos.txt")));
+ }
+
@Test public void testNamedMultilineHeader() throws Exception {
String sql = "SELECT * from texttable(? COLUMNS Col3Head string HEADER) x";
13 years, 10 months
teiid SVN: r2917 - in trunk/engine/src/main: resources/org/teiid/query and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-17 13:55:02 -0500 (Thu, 17 Feb 2011)
New Revision: 2917
Modified:
trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
TEIIDDES-806 updating validation logic and messages
Modified: trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2011-02-17 18:52:11 UTC (rev 2916)
+++ trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2011-02-17 18:55:02 UTC (rev 2917)
@@ -56,8 +56,6 @@
* the virtual group is always a <code>Query</code>. This object visits various parts of
* this <code>Query</code> and verifies if the virtual group definition will allows it to be
* updated.</p>
- *
- * TODO: add insert support based upon partitioning
*/
public class UpdateValidator {
@@ -428,7 +426,9 @@
}
if (query.getFrom().getClauses().size() > 1 || (!(query.getFrom().getClauses().get(0) instanceof UnaryFromClause))) {
- report.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0009", query.getFrom())); //$NON-NLS-1$
+ String warning = QueryPlugin.Util.getString("ERR.015.012.0009", query.getFrom());
+ updateReport.handleValidationWarning(warning); //$NON-NLS-1$
+ deleteReport.handleValidationWarning(warning); //$NON-NLS-1$
updateInfo.isSimple = false;
}
List<GroupSymbol> allGroups = query.getFrom().getGroups();
@@ -445,15 +445,14 @@
if (!allGroups.isEmpty()) {
setUpdateFlags(allGroups.iterator().next());
}
- } else if (this.updateInfo.updateType == UpdateType.INHERENT || this.updateInfo.deleteType == UpdateType.INHERENT) {
+ } else {
for (GroupSymbol groupSymbol : allGroups) {
UpdateMapping info = updateInfo.updatableGroups.get(groupSymbol.getCanonicalName());
if (info == null) {
continue; // not projected
}
- String warning = QueryPlugin.Util.getString("ERR.015.012.0004"); //$NON-NLS-1$
- updateReport.handleValidationWarning(warning);
- deleteReport.handleValidationWarning(warning);
+ String warning = QueryPlugin.Util.getString("ERR.015.012.0004", info.correlatedName); //$NON-NLS-1$
+ report.handleValidationWarning(warning);
}
}
@@ -475,7 +474,7 @@
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0015"), false, true, false); //$NON-NLS-1$
}
if (this.updateInfo.updateType == UpdateType.INHERENT && !updatable) {
- handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0005"), true, false, true); //$NON-NLS-1$
+ handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0005"), true, false, false); //$NON-NLS-1$
}
if (this.updateInfo.deleteType == UpdateType.INHERENT && this.updateInfo.deleteTarget == null) {
if (this.updateInfo.isSimple && updatable) {
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-02-17 18:52:11 UTC (rev 2916)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-02-17 18:55:02 UTC (rev 2917)
@@ -161,16 +161,16 @@
# util (011)
# validator (012)
-ERR.015.012.0001 = The query defining an updatable view must be a simple query or a UNION ALL of simple queries.
-ERR.015.012.0002 = The query defining an updatable view has a WITH clause, pass-through processing will not be used for UPDATE/DELETE operations.
-ERR.015.012.0003 = The query defining an updatable view projects a column from a non-updatable group {0}.
-ERR.015.012.0004 = The query defining an updatable view has a non key preserving join group {0}, which cannot be targeted by UPDATE/DELETE operations.
-ERR.015.012.0005 = The query defining an updatable view has no valid target for UPDATEs.
-ERR.015.012.0006 = The query defining an updatable view should not use aggregates or grouping.
-ERR.015.012.0007 = The query defining an updatable view has a non-updatable expression {0} for view column {1}.
-ERR.015.012.0008 = The query defining an updatable view cannot use SELECT DISTINCT.
-ERR.015.012.0009 = The query defining an updatable view has a non-simple FROM clause, pass-through processing will not be used for UPDATE/DELETE operations.
-ERR.015.012.0010 = The query defining an updatable view does not project the column {0}, which is required to make {1} a target of INSERT operations.
+ERR.015.012.0001 = The updatable view query must be simple (containing a FROM clause and not using SELECT INTO) or a UNION ALL of simple queries.
+ERR.015.012.0002 = The updatable view query has a WITH clause, pass-through processing will not be used for UPDATE/DELETE operations.
+ERR.015.012.0003 = The updatable view query projects a column from a non-updatable group {0}.
+ERR.015.012.0004 = The updatable view query has a non key preserving group {0}, which cannot be targeted by INSERT/UPDATE/DELETE operations.
+ERR.015.012.0005 = The updatable view has no valid target for UPDATEs.
+ERR.015.012.0006 = The updatable view query must not use aggregates or grouping.
+ERR.015.012.0007 = The updatable view query has a non-updatable expression {0} for view column {1}.
+ERR.015.012.0008 = The updatable view query cannot use SELECT DISTINCT.
+ERR.015.012.0009 = The updatable view query has a join, pass-through processing will not be used for UPDATE/DELETE operations.
+ERR.015.012.0010 = The updatable view query does not project the column {0}, which is required to make {1} a target of INSERT operations.
ERR.015.012.0011 = There must be exactly one projected symbol in the subcommand of an IN clause.
ERR.015.012.0012 = An AssignmentStatement cannot change the value of a {0} or {1} variable.
ERR.015.012.0013 = The query defining an updatable virtual group cannot use LIMIT.
@@ -799,6 +799,7 @@
TextTableNode.character_not_allowed=Text parse error: Non-whitespace character found between the qualifier and the delimiter in text line {0} in {1}.
TextTableNode.unknown_escape=Text parse error: Unknown escape sequence \\{0} in text line {1} in {2}.
TextTableNode.invalid_width=Text parse error: Fixed width line width {0} is smaller than the expected {1} on text line {2} in {3}.
+TextTableNode.line_too_long=Text parse error: Delimited line is longer than the expected max of {2} on text line {0} in {1}.
XMLTableNode.error=Error evaluating XQuery row context for XMLTable: {0}
XMLTableNode.path_error=Error evaluating XMLTable column path expression for column: {0}
13 years, 10 months
teiid SVN: r2916 - in trunk/engine/src/main/java/org/teiid: query/processor/relational and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-17 13:52:11 -0500 (Thu, 17 Feb 2011)
New Revision: 2916
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
Log:
TEIID-1476 updates to prevent unintended exceptions
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-02-17 17:32:44 UTC (rev 2915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-02-17 18:52:11 UTC (rev 2916)
@@ -204,7 +204,13 @@
while (cause.getCause() != null && cause.getCause() != cause) {
cause = cause.getCause();
}
- StackTraceElement elem = cause.getStackTrace()[0];
+ StackTraceElement[] elems = cause.getStackTrace();
+ Object elem = null;
+ if (elems.length > 0) {
+ elem = cause.getStackTrace()[0];
+ } else {
+ elem = cause.getMessage();
+ }
LogManager.logWarning(LogConstants.CTX_DQP, QueryPlugin.Util.getString("ProcessWorker.processing_error", e.getMessage(), requestID, e.getClass().getName(), elem)); //$NON-NLS-1$
}else {
LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("ProcessWorker.error", requestID)); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2011-02-17 17:32:44 UTC (rev 2915)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2011-02-17 18:52:11 UTC (rev 2916)
@@ -274,7 +274,9 @@
public void closeDirect() {
super.closeDirect();
joinStrategy.close();
- this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, null);
+ if (this.getContext() != null) {
+ this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, null);
+ }
}
public JoinType getJoinType() {
13 years, 10 months
teiid SVN: r2915 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-02-17 12:32:44 -0500 (Thu, 17 Feb 2011)
New Revision: 2915
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1475 added checks to ensure that we do pull the file into memory on invalid input
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-02-17 15:12:44 UTC (rev 2914)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-02-17 17:32:44 UTC (rev 2915)
@@ -51,8 +51,7 @@
/**
* Handles text file processing.
*
- * TODO: unix style escape handling \t \n, etc.
- * TODO: parse using something more memory safe than strings
+ * TODO: unix style escape handling \t \n, etc. - see also the unescape function
* TODO: allow for escaping with fixed parsing
* TODO: allow for fixed parsing without new lines
* TODO: allow for a configurable line terminator
@@ -75,6 +74,9 @@
private int textLine = 0;
private Map<String, Integer> nameIndexes;
private String systemId;
+
+ private boolean cr;
+ private boolean eof;
public TextTableNode(int nodeID) {
super(nodeID);
@@ -110,6 +112,7 @@
noQuote = table.isEscape();
quote = table.getQuote();
}
+ lineWidth = table.getColumns().size() * DataTypeManager.MAX_STRING_LENGTH;
}
Map elementMap = createLookupMap(table.getProjectedSymbols());
this.projectionIndexes = getProjectionIndexes(elementMap, getElements());
@@ -133,6 +136,8 @@
}
this.nameIndexes = null;
this.textLine = 0;
+ this.cr = false;
+ this.eof = false;
}
public void setTable(TextTable table) {
@@ -161,7 +166,7 @@
}
while (!isBatchFull()) {
- String line = readLine();
+ String line = readLine(lineWidth, table.isFixedWidth());
if (line == null) {
terminateBatches();
@@ -194,22 +199,63 @@
return pullBatch();
}
- private String readLine() throws TeiidProcessingException {
- while (true) {
- try {
- String line = reader.readLine();
- if (line != null) {
- textLine++;
- if (line.length() == 0) {
- continue;
+ private String readLine(int maxLength, boolean exact) throws TeiidProcessingException {
+ if (eof) {
+ return null;
+ }
+ StringBuilder sb = new StringBuilder(exact ? maxLength : (maxLength >> 4));
+ try {
+ while (true) {
+ char c = readChar();
+ if (c == '\n') {
+ if (sb.length() == 0) {
+ if (eof) {
+ return null;
+ }
+ continue; //skip empty lines
}
- }
- return line;
- } catch (IOException e) {
- throw new TeiidProcessingException(e);
+ if (exact && sb.length() < lineWidth) {
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.invalid_width", sb.length(), lineWidth, textLine, systemId)); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+ sb.append(c);
+ if (sb.length() > maxLength) {
+ if (exact) {
+ //we're not forcing them to fully specify the line, so just drop the rest
+ //TODO: there should be a max read length
+ while ((c = readChar()) != '\n') {
+
+ }
+ return sb.toString();
+ }
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.line_too_long", textLine+1, systemId, maxLength)); //$NON-NLS-1$
+ }
}
+ } catch (IOException e) {
+ throw new TeiidProcessingException(e);
}
}
+
+ private char readChar() throws IOException {
+ int c = reader.read();
+ if (cr) {
+ if (c == '\n') {
+ c = reader.read();
+ }
+ cr = false;
+ }
+ switch (c) {
+ case '\r':
+ cr = true;
+ case -1:
+ eof = true;
+ case '\n':
+ textLine++;
+ return '\n';
+ }
+ return (char)c;
+ }
private void initReader() throws ExpressionEvaluationException,
BlockedException, TeiidComponentException, TeiidProcessingException {
@@ -245,7 +291,8 @@
}
while (textLine < skip) {
boolean isHeader = textLine == header;
- String line = readLine();
+ //if we don't need a header, then we could just scan, but for now we'll enforce a max length
+ String line = readLine(Math.min(lineWidth, DataTypeManager.MAX_STRING_LENGTH), false);
if (line == null) { //just return an empty batch
reset();
return;
@@ -289,9 +336,13 @@
while (true) {
if (line == null) {
if (escaped) {
- builder.append('\n'); //allow for escaped new lines
+ //allow for escaped new lines
+ if (cr) {
+ builder.append('\r');
+ }
+ builder.append('\n');
escaped = false;
- line = readLine();
+ line = readLine(lineWidth, false);
continue;
}
if (!qualified) {
@@ -299,7 +350,7 @@
addValue(result, wasQualified, builder.toString());
return result;
}
- line = readLine();
+ line = readLine(lineWidth, false);
if (line == null) {
throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.unclosed", systemId)); //$NON-NLS-1$
}
@@ -368,11 +419,7 @@
result.add(val);
}
- private List<String> parseFixedWidth(String line)
- throws TeiidProcessingException {
- if (line.length() < lineWidth) {
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.invalid_width", line.length(), lineWidth, textLine, systemId)); //$NON-NLS-1$
- }
+ private List<String> parseFixedWidth(String line) {
ArrayList<String> result = new ArrayList<String>();
int beginIndex = 0;
for (TextColumn col : table.getColumns()) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-02-17 15:12:44 UTC (rev 2914)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-02-17 17:32:44 UTC (rev 2915)
@@ -22,14 +22,15 @@
package org.teiid.query.processor;
-import static org.teiid.query.optimizer.TestOptimizer.getTypicalCapabilities;
-import static org.teiid.query.optimizer.TestOptimizer.helpPlan;
+import static org.teiid.query.optimizer.TestOptimizer.*;
import static org.teiid.query.processor.TestProcessor.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import javax.sql.rowset.serial.SerialClob;
+
import org.junit.Test;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.ClobImpl;
@@ -62,7 +63,7 @@
}
@Test public void testTextTableFixed() throws Exception {
- String sql = "select count(*) from texttable(? COLUMNS compkey string width 77, CDM_ID string width 14, CURRENCY string width 9, \"START\" string width 31, MATURITY string width 38, AMOUNT double width 13, RECORDSOURCE string width 13, SUMMIT_ID string width 25, RATE double width 21, SPREAD double width 9, DESK string width 13) x"; //$NON-NLS-1$
+ String sql = "select count(*) from texttable(? COLUMNS compkey string width 78, CDM_ID string width 14, CURRENCY string width 9, \"START\" string width 31, MATURITY string width 38, AMOUNT double width 13, RECORDSOURCE string width 13, SUMMIT_ID string width 25, RATE double width 21, SPREAD double width 9, DESK string width 13) x"; //$NON-NLS-1$
List[] expected = new List[] {
Arrays.asList(52),
@@ -255,5 +256,15 @@
helpProcess(plan, hdm, expected);
}
+
+ @Test(expected=TeiidProcessingException.class) public void testTextTableInvalidData() throws Exception {
+ String sql = "select count(*) from texttable(? COLUMNS PARTNAME string) x"; //$NON-NLS-1$
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ char[] data = new char[5000];
+ processPreparedStatement(sql, null, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(new ClobType(new SerialClob(data))));
+ }
}
13 years, 10 months