teiid SVN: r3760 - in branches/7.6.x: client/src/main/java/org/teiid/net/socket and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-24 20:40:08 -0500 (Sat, 24 Dec 2011)
New Revision: 3760
Modified:
branches/7.6.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/7.6.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
branches/7.6.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
branches/7.6.x/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
Log:
TEIID-1883 fix for not using the appropriate timeout
Modified: branches/7.6.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.6.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-12-23 02:17:51 UTC (rev 3759)
+++ branches/7.6.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-12-25 01:40:08 UTC (rev 3760)
@@ -40,6 +40,8 @@
import java.util.Properties;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -543,16 +545,21 @@
});
if (synch) {
try {
- pendingResult.get();
+ pendingResult.get(queryTimeoutMS==0?Integer.MAX_VALUE:queryTimeoutMS, TimeUnit.MILLISECONDS);
result.get(); //throw an exception if needed
return result;
} catch (ExecutionException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException)e.getCause();
}
+ if (e.getCause() != null) {
+ throw TeiidSQLException.create(e.getCause());
+ }
throw TeiidSQLException.create(e);
} catch (InterruptedException e) {
timeoutOccurred();
+ } catch (TimeoutException e) {
+ timeoutOccurred();
}
throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete")); //$NON-NLS-1$
}
@@ -577,7 +584,7 @@
reqMsg.setExecutionId(this.currentRequestID);
ResultsFuture.CompletionListener<ResultsMessage> compeletionListener = null;
- if (queryTimeoutMS > 0) {
+ if (queryTimeoutMS > 0 && !synch) {
final Task c = cancellationTimer.add(cancelTask, queryTimeoutMS);
compeletionListener = new ResultsFuture.CompletionListener<ResultsMessage>() {
@Override
Modified: branches/7.6.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
===================================================================
--- branches/7.6.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2011-12-23 02:17:51 UTC (rev 3759)
+++ branches/7.6.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2011-12-25 01:40:08 UTC (rev 3760)
@@ -70,7 +70,7 @@
}
}
- private static SocketProfile SOCKET_PROFILE = new SocketProfile();
+ private ConnectionProfile socketProfile = new SocketProfile();
private ConnectionProfile embeddedProfile = new EmbeddedProfile();
public static TeiidDriver getInstance() {
@@ -104,7 +104,7 @@
if (conn == ConnectionType.Embedded) {
myConnection = embeddedProfile.connect(url, info);
} else {
- myConnection = SOCKET_PROFILE.connect(url, info);
+ myConnection = socketProfile.connect(url, info);
}
} catch (TeiidSQLException e) {
logger.log(Level.SEVERE, "Could not create connection", e); //$NON-NLS-1$
@@ -122,6 +122,10 @@
this.embeddedProfile = embeddedProfile;
}
+ public void setSocketProfile(ConnectionProfile socketProfile) {
+ this.socketProfile = socketProfile;
+ }
+
/**
* Returns true if the driver thinks that it can open a connection to the given URL.
* Expected URL format for server mode is
Modified: branches/7.6.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
===================================================================
--- branches/7.6.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2011-12-23 02:17:51 UTC (rev 3759)
+++ branches/7.6.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2011-12-25 01:40:08 UTC (rev 3760)
@@ -269,7 +269,7 @@
timeoutMillis -= now - start;
start = now;
if (timeoutMillis <= 0) {
- throw new TimeoutException();
+ throw new TimeoutException("Read timeout after " + timeout + " milliseconds."); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@@ -332,7 +332,7 @@
@Override
public Object get() throws InterruptedException, ExecutionException {
try {
- return this.get(SocketServerConnectionFactory.getInstance().getSynchronousTtl(), TimeUnit.MILLISECONDS);
+ return this.get(instance.getSynchTimeout(), TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
throw new ExecutionException(e);
}
Modified: branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-12-23 02:17:51 UTC (rev 3759)
+++ branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-12-25 01:40:08 UTC (rev 3760)
@@ -28,7 +28,6 @@
import java.util.Properties;
import org.jboss.deployers.spi.DeploymentException;
-import org.mockito.Mockito;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -142,13 +141,24 @@
this.dqp.setCacheFactory(new DefaultCacheFactory());
this.dqp.setTransactionService(new FakeTransactionService());
- cmr = Mockito.mock(ConnectorManagerRepository.class);
- Mockito.stub(cmr.getConnectorManager("source")).toReturn(new ConnectorManager("x", "x") {
+ cmr = new ConnectorManagerRepository() {
@Override
- public SourceCapabilities getCapabilities() {
- return new BasicSourceCapabilities();
+ public ConnectorManager getConnectorManager(String connectorName) {
+ ConnectorManager cm = super.getConnectorManager(connectorName);
+ if (cm != null) {
+ return cm;
+ }
+ if (connectorName.equalsIgnoreCase("source")) {
+ return new ConnectorManager("x", "x") {
+ @Override
+ public SourceCapabilities getCapabilities() {
+ return new BasicSourceCapabilities();
+ }
+ };
+ }
+ return null;
}
- });
+ };
config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250, "resultsetcache")); //$NON-NLS-1$
this.dqp.setCacheFactory(new DefaultCacheFactory() {
@@ -168,6 +178,10 @@
return dqp;
}
+ public ConnectorManagerRepository getConnectorManagerRepository() {
+ return cmr;
+ }
+
public void setConnectorManagerRepository(ConnectorManagerRepository cmr) {
this.cmr = cmr;
}
Modified: branches/7.6.x/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
===================================================================
--- branches/7.6.x/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2011-12-23 02:17:51 UTC (rev 3759)
+++ branches/7.6.x/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2011-12-25 01:40:08 UTC (rev 3760)
@@ -37,16 +37,26 @@
import org.junit.Test;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.DQPConfiguration;
+import org.teiid.dqp.service.AutoGenDataService;
+import org.teiid.jdbc.ConnectionImpl;
+import org.teiid.jdbc.ConnectionProfile;
import org.teiid.jdbc.FakeServer;
import org.teiid.jdbc.TeiidDriver;
+import org.teiid.jdbc.TeiidSQLException;
import org.teiid.jdbc.TestMMDatabaseMetaData;
+import org.teiid.net.CommunicationException;
+import org.teiid.net.ConnectionException;
+import org.teiid.net.socket.SocketServerConnectionFactory;
+import org.teiid.translator.TranslatorException;
@SuppressWarnings("nls")
public class TestJDBCSocketTransport {
static InetSocketAddress addr;
static SocketListener jdbcTransport;
+ static FakeServer server;
@BeforeClass public static void oneTimeSetup() throws Exception {
SocketConfiguration config = new SocketConfiguration();
@@ -57,7 +67,7 @@
DQPConfiguration dqpConfig = new DQPConfiguration();
dqpConfig.setMaxActivePlans(2);
- FakeServer server = new FakeServer(dqpConfig);
+ server = new FakeServer(dqpConfig);
server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
@@ -68,6 +78,7 @@
if (jdbcTransport != null) {
jdbcTransport.stop();
}
+ server.stop();
}
Connection conn;
@@ -127,4 +138,46 @@
}
}
+ @Test public void testSyncTimeout() throws Exception {
+ TeiidDriver td = new TeiidDriver();
+ td.setSocketProfile(new ConnectionProfile() {
+
+ @Override
+ public ConnectionImpl connect(String url, Properties info)
+ throws TeiidSQLException {
+ SocketServerConnectionFactory sscf = new SocketServerConnectionFactory();
+ sscf.initialize(info);
+ try {
+ return new ConnectionImpl(sscf.getConnection(info), info, url);
+ } catch (CommunicationException e) {
+ throw TeiidSQLException.create(e);
+ } catch (ConnectionException e) {
+ throw TeiidSQLException.create(e);
+ }
+ }
+ });
+ Properties p = new Properties();
+ p.setProperty("user", "testuser");
+ p.setProperty("password", "testpassword");
+ p.setProperty("org.teiid.sockets.soTimeout", "50");
+ p.setProperty("org.teiid.sockets.SynchronousTtl", "50");
+ ConnectorManagerRepository cmr = server.getConnectorManagerRepository();
+ AutoGenDataService agds = new AutoGenDataService() {
+ @Override
+ protected Object getConnectionFactory()
+ throws TranslatorException {
+ return null;
+ }
+ };
+ agds.setSleep(100);
+ cmr.addConnectorManager("source", agds);
+ try {
+ conn = td.connect("jdbc:teiid:parts@mm://"+addr.getHostName()+":" +jdbcTransport.getPort(), p);
+ Statement s = conn.createStatement();
+ assertTrue(s.execute("select * from parts"));
+ } finally {
+ server.setConnectorManagerRepository(cmr);
+ }
+ }
+
}
12 years, 11 months
teiid SVN: r3759 - in branches/7.6.x/client/src: main/java/org/teiid/net/socket and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-22 21:17:51 -0500 (Thu, 22 Dec 2011)
New Revision: 3759
Added:
branches/7.6.x/client/src/test/java/org/teiid/net/socket/TestHandshake.java
branches/7.6.x/client/src/test/resources/handshake.ser
Modified:
branches/7.6.x/client/src/main/java/org/teiid/client/security/LogonResult.java
branches/7.6.x/client/src/main/java/org/teiid/net/socket/Handshake.java
Log:
TEIID-1882 fix for backwards compatibility
Modified: branches/7.6.x/client/src/main/java/org/teiid/client/security/LogonResult.java
===================================================================
--- branches/7.6.x/client/src/main/java/org/teiid/client/security/LogonResult.java 2011-12-22 18:32:16 UTC (rev 3758)
+++ branches/7.6.x/client/src/main/java/org/teiid/client/security/LogonResult.java 2011-12-23 02:17:51 UTC (rev 3759)
@@ -22,6 +22,7 @@
package org.teiid.client.security;
+import java.io.EOFException;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@@ -119,6 +120,8 @@
vdbVersion = in.readInt();
try {
addtionalProperties = ExternalizeUtil.readMap(in);
+ } catch (EOFException e) {
+
} catch (OptionalDataException e) {
}
Modified: branches/7.6.x/client/src/main/java/org/teiid/net/socket/Handshake.java
===================================================================
--- branches/7.6.x/client/src/main/java/org/teiid/net/socket/Handshake.java 2011-12-22 18:32:16 UTC (rev 3758)
+++ branches/7.6.x/client/src/main/java/org/teiid/net/socket/Handshake.java 2011-12-23 02:17:51 UTC (rev 3759)
@@ -22,11 +22,11 @@
package org.teiid.net.socket;
+import java.io.EOFException;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.OptionalDataException;
import org.teiid.core.util.ApplicationInfo;
@@ -85,7 +85,7 @@
publicKey = (byte[])in.readObject();
try {
authType = AuthenticationType.values()[in.readByte()];
- } catch (OptionalDataException e) {
+ } catch (EOFException e) {
}
}
Added: branches/7.6.x/client/src/test/java/org/teiid/net/socket/TestHandshake.java
===================================================================
--- branches/7.6.x/client/src/test/java/org/teiid/net/socket/TestHandshake.java (rev 0)
+++ branches/7.6.x/client/src/test/java/org/teiid/net/socket/TestHandshake.java 2011-12-23 02:17:51 UTC (rev 3759)
@@ -0,0 +1,42 @@
+/*
+ * 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.net.socket;
+
+import static org.junit.Assert.*;
+
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestHandshake {
+
+ @Test public void testCompatibility() throws Exception {
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(UnitTestUtil.getTestDataFile("handshake.ser")));
+ Handshake hs = (Handshake)ois.readObject();
+ assertEquals(AuthenticationType.CLEARTEXT, hs.getAuthType());
+ }
+
+}
Property changes on: branches/7.6.x/client/src/test/java/org/teiid/net/socket/TestHandshake.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/7.6.x/client/src/test/resources/handshake.ser
===================================================================
(Binary files differ)
Property changes on: branches/7.6.x/client/src/test/resources/handshake.ser
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
12 years, 11 months
teiid SVN: r3758 - branches/7.6.x/common-core/src/main/java/org/teiid/core/types/basic.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-22 13:32:16 -0500 (Thu, 22 Dec 2011)
New Revision: 3758
Modified:
branches/7.6.x/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
Log:
TEIID-1824 minimizing factory creation
Modified: branches/7.6.x/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
===================================================================
--- branches/7.6.x/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2011-12-22 18:31:53 UTC (rev 3757)
+++ branches/7.6.x/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2011-12-22 18:32:16 UTC (rev 3758)
@@ -60,7 +60,7 @@
public static Type isXml(Reader reader) throws TransformationException {
Type type = Type.ELEMENT;
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
try{
XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
int event = xmlReader.getEventType();
12 years, 11 months
teiid SVN: r3757 - in trunk: common-core/src/main/java/org/teiid/core/types/basic and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-22 13:31:53 -0500 (Thu, 22 Dec 2011)
New Revision: 3757
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
Log:
TEIID-1824 minimizing factory creation
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-12-22 01:53:47 UTC (rev 3756)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-12-22 18:31:53 UTC (rev 3757)
@@ -24,21 +24,31 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
-import javax.xml.stream.*;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.core.types.XMLType;
@SuppressWarnings("nls")
public class VDBMetadataParser {
public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
- XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLInputFactory inputFactory=XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
// elements
Modified: trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2011-12-22 01:53:47 UTC (rev 3756)
+++ trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2011-12-22 18:31:53 UTC (rev 3757)
@@ -60,7 +60,7 @@
public static Type isXml(Reader reader) throws TransformationException {
Type type = Type.ELEMENT;
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
try{
XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
int event = xmlReader.getEventType();
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-12-22 01:53:47 UTC (rev 3756)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-12-22 18:31:53 UTC (rev 3757)
@@ -975,7 +975,6 @@
// ================== Function = convert =====================
- @SuppressWarnings("unchecked")
public static Object convert(Object src, String type)
throws FunctionExecutionException {
try {
@@ -1035,8 +1034,10 @@
* This function should never actually be called - it is here solely so the
* lookup function can be resolved properly. The actual function is
* implemented in the ExpresionEvaluator
- * @param context The context to apply the criteria in
- * @param expression The expression on the left side of the criteria
+ * @param codeTable
+ * @param returnElement
+ * @param keyElement
+ * @param keyValue
* @return Same as expression
*/
public static Object lookup(Object codeTable, Object returnElement, Object keyElement, Object keyValue) {
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-12-22 01:53:47 UTC (rev 3756)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-12-22 18:31:53 UTC (rev 3757)
@@ -15,6 +15,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import org.teiid.core.types.XMLType;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
@@ -31,7 +32,7 @@
}
public static FunctionMetadataReader parseFunctions(InputStream content) throws XMLStreamException {
- XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLInputFactory inputFactory=XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
FunctionMetadataReader fmr = new FunctionMetadataReader();
while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
12 years, 11 months
teiid SVN: r3756 - in branches/7.6.x: runtime/src/main/java/org/teiid/deployers and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-21 20:53:47 -0500 (Wed, 21 Dec 2011)
New Revision: 3756
Modified:
branches/7.6.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/7.6.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1878 fix for creating the global table metadata store too early for dynamic vdbs
Modified: branches/7.6.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.6.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-12-20 22:40:36 UTC (rev 3755)
+++ branches/7.6.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-12-22 01:53:47 UTC (rev 3756)
@@ -292,15 +292,6 @@
@Override
public void added(String name, int version, CompositeVDB vdb) {
- GlobalTableStore gts = new GlobalTableStoreImpl(dqpCore.getBufferManager(), vdb.getVDB().getAttachment(TransformationMetadata.class));
- if (objectReplicator != null) {
- try {
- gts = objectReplicator.replicate(name + version, GlobalTableStore.class, gts, 300000);
- } catch (Exception e) {
- LogManager.logError(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.getString("replication_failed", gts)); //$NON-NLS-1$
- }
- }
- vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
if (!recentlyRemoved.remove(new VDBKey(name, version))) {
return;
}
@@ -319,7 +310,21 @@
// dump the caches.
dqpCore.clearCache(Cache.PREPARED_PLAN_CACHE.toString(), name, version);
dqpCore.clearCache(Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString(), name, version);
- }
+ }
+
+ @Override
+ public void finishedDeployment(String name, int version,
+ CompositeVDB vdb) {
+ GlobalTableStore gts = new GlobalTableStoreImpl(dqpCore.getBufferManager(), vdb.getVDB().getAttachment(TransformationMetadata.class));
+ if (objectReplicator != null) {
+ try {
+ gts = objectReplicator.replicate(name + version, GlobalTableStore.class, gts, 300000);
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.getString("replication_failed", gts)); //$NON-NLS-1$
+ }
+ }
+ vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
+ }
});
}
Modified: branches/7.6.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/7.6.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-12-20 22:40:36 UTC (rev 3755)
+++ branches/7.6.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-12-22 01:53:47 UTC (rev 3756)
@@ -74,7 +74,7 @@
update();
}
- public void addChild(CompositeVDB child) {
+ public synchronized void addChild(CompositeVDB child) {
if (this.children == null) {
this.children = new LinkedHashMap<VDBKey, CompositeVDB>();
}
@@ -83,14 +83,14 @@
this.mergedVDB = null;
}
- public void removeChild(VDBKey child) {
+ public synchronized void removeChild(VDBKey child) {
if (this.children != null) {
this.children.remove(child);
}
this.mergedVDB = null;
}
- void update() {
+ synchronized void update() {
TransformationMetadata metadata = buildTransformationMetaData(mergedVDB, getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions, this.additionalStores);
mergedVDB.addAttchment(QueryMetadataInterface.class, metadata);
mergedVDB.addAttchment(TransformationMetadata.class, metadata);
@@ -123,7 +123,7 @@
return additionalStores;
}
- public VDBMetaData getVDB() {
+ public synchronized VDBMetaData getVDB() {
if (this.mergedVDB == null) {
this.mergedVDB = buildVDB();
update();
@@ -131,7 +131,7 @@
return this.mergedVDB;
}
- public boolean hasChildVdb(VDBKey child) {
+ public synchronized boolean hasChildVdb(VDBKey child) {
if (this.children != null) {
return this.children.containsKey(child);
}
@@ -201,7 +201,7 @@
return mergedUDF;
}
- private LinkedHashMap<String, Resource> getVisibilityMap() {
+ private synchronized LinkedHashMap<String, Resource> getVisibilityMap() {
if (this.children == null || this.children.isEmpty()) {
return this.visibilityMap;
}
@@ -219,7 +219,7 @@
return mergedvisibilityMap;
}
- public MetadataStoreGroup getMetadataStores() {
+ public synchronized MetadataStoreGroup getMetadataStores() {
if (this.children == null || this.children.isEmpty()) {
return this.stores;
}
Modified: branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
===================================================================
--- branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java 2011-12-20 22:40:36 UTC (rev 3755)
+++ branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java 2011-12-22 01:53:47 UTC (rev 3756)
@@ -24,4 +24,5 @@
public interface VDBLifeCycleListener {
void added(String name, int version, CompositeVDB vdb);
void removed(String name, int version, CompositeVDB vdb);
+ void finishedDeployment(String name, int version, CompositeVDB vdb);
}
Modified: branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-12-20 22:40:36 UTC (rev 3755)
+++ branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-12-22 01:53:47 UTC (rev 3756)
@@ -314,6 +314,7 @@
target.addChild(source);
notifyAdd(targetVDBName, targetVDBVersion, target);
+ notifyFinished(targetVDBName, targetVDBVersion, target);
}
// this is called by mc
@@ -328,8 +329,15 @@
if (v!= null) {
updateFromMetadataRepository(v);
v.update();
+ notifyFinished(name, version, v);
}
}
+
+ private void notifyFinished(String name, int version, CompositeVDB v) {
+ for(VDBLifeCycleListener l:this.listeners) {
+ l.finishedDeployment(name, version, v);
+ }
+ }
public void addListener(VDBLifeCycleListener listener) {
this.listeners.add(listener);
Modified: branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-12-20 22:40:36 UTC (rev 3755)
+++ branches/7.6.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-12-22 01:53:47 UTC (rev 3756)
@@ -101,12 +101,18 @@
this.repo.addListener(new VDBLifeCycleListener() {
@Override
+ public void added(String name, int version,
+ CompositeVDB vdb) {
+
+ }
+
+ @Override
public void removed(String name, int version, CompositeVDB vdb) {
}
@Override
- public void added(String name, int version, CompositeVDB vdb) {
+ public void finishedDeployment(String name, int version, CompositeVDB vdb) {
GlobalTableStore gts = new GlobalTableStoreImpl(dqp.getBufferManager(), vdb.getVDB().getAttachment(TransformationMetadata.class));
if (replicator != null) {
try {
12 years, 11 months
teiid SVN: r3755 - in branches/7.6.x: common-core/src/test/java/org/teiid/core/types and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-20 17:40:36 -0500 (Tue, 20 Dec 2011)
New Revision: 3755
Modified:
branches/7.6.x/common-core/src/main/java/org/teiid/core/types/BlobType.java
branches/7.6.x/common-core/src/main/java/org/teiid/core/types/ClobType.java
branches/7.6.x/common-core/src/main/java/org/teiid/core/types/Streamable.java
branches/7.6.x/common-core/src/main/java/org/teiid/core/types/XMLType.java
branches/7.6.x/common-core/src/test/java/org/teiid/core/types/TestClobValue.java
branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
Log:
TEIID-1879 moved the proactive check for source closure out of the doneProducingBatches method and added protection in the streamable logic so that the socket won't close
Modified: branches/7.6.x/common-core/src/main/java/org/teiid/core/types/BlobType.java
===================================================================
--- branches/7.6.x/common-core/src/main/java/org/teiid/core/types/BlobType.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/common-core/src/main/java/org/teiid/core/types/BlobType.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -22,6 +22,7 @@
package org.teiid.core.types;
+import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
@@ -147,7 +148,7 @@
}
@Override
- protected void writeReference(final ObjectOutput out) throws IOException {
+ protected void writeReference(final DataOutput out) throws IOException {
try {
writeBinary(out, getBinaryStream(), (int)length);
} catch (SQLException e) {
@@ -155,7 +156,7 @@
}
}
- static void writeBinary(final ObjectOutput out, InputStream is, int length) throws IOException {
+ static void writeBinary(final DataOutput out, InputStream is, int length) throws IOException {
OutputStream os = new OutputStream() {
@Override
Modified: branches/7.6.x/common-core/src/main/java/org/teiid/core/types/ClobType.java
===================================================================
--- branches/7.6.x/common-core/src/main/java/org/teiid/core/types/ClobType.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/common-core/src/main/java/org/teiid/core/types/ClobType.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -22,10 +22,10 @@
package org.teiid.core.types;
+import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
@@ -230,7 +230,7 @@
* These clobs should be small, so the wasted space should be minimal.
*/
@Override
- protected void writeReference(final ObjectOutput out) throws IOException {
+ protected void writeReference(final DataOutput out) throws IOException {
Writer w = new Writer() {
@Override
Modified: branches/7.6.x/common-core/src/main/java/org/teiid/core/types/Streamable.java
===================================================================
--- branches/7.6.x/common-core/src/main/java/org/teiid/core/types/Streamable.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/common-core/src/main/java/org/teiid/core/types/Streamable.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -22,6 +22,8 @@
package org.teiid.core.types;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@@ -29,8 +31,11 @@
import java.nio.charset.Charset;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.teiid.core.CorePlugin;
+import org.teiid.core.util.AccessibleByteArrayOutputStream;
@@ -42,6 +47,8 @@
* this is the ID that client needs to reference to get the chunk of data.
*/
public abstract class Streamable<T> implements Externalizable {
+
+ private static final Logger logger = Logger.getLogger(Streamable.class.getName());
private static final long serialVersionUID = -8252488562134729374L;
@@ -112,7 +119,7 @@
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
length = in.readLong();
- referenceStreamId = (String)in.readObject();
+ this.referenceStreamId = (String)in.readObject();
if (referenceStreamId == null) {
//we expect the data inline
readReference(in);
@@ -128,12 +135,27 @@
} catch (SQLException e) {
}
out.writeLong(length);
- out.writeObject(referenceStreamId);
+ boolean writeBuffer = false;
+ AccessibleByteArrayOutputStream baos = null;
if (referenceStreamId == null) {
- writeReference(out);
+ //TODO: detect when this buffering is not necessary
+ baos = new AccessibleByteArrayOutputStream();
+ DataOutputStream dataOutput = new DataOutputStream(baos);
+ try {
+ writeReference(dataOutput);
+ dataOutput.close();
+ writeBuffer = true;
+ } catch (IOException e) {
+ logger.log(Level.WARNING, e.getMessage());
+ referenceStreamId = "error"; //$NON-NLS-1$
+ }
}
+ out.writeObject(referenceStreamId);
+ if (writeBuffer) {
+ out.write(baos.getBuffer(), 0, baos.getCount());
+ }
}
- protected abstract void writeReference(ObjectOutput out) throws IOException;
+ protected abstract void writeReference(DataOutput out) throws IOException;
}
Modified: branches/7.6.x/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- branches/7.6.x/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -22,6 +22,7 @@
package org.teiid.core.types;
+import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
@@ -228,7 +229,7 @@
}
@Override
- protected void writeReference(final ObjectOutput out) throws IOException {
+ protected void writeReference(final DataOutput out) throws IOException {
try {
BlobType.writeBinary(out, getBinaryStream(), (int)length);
} catch (SQLException e) {
Modified: branches/7.6.x/common-core/src/test/java/org/teiid/core/types/TestClobValue.java
===================================================================
--- branches/7.6.x/common-core/src/test/java/org/teiid/core/types/TestClobValue.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/common-core/src/test/java/org/teiid/core/types/TestClobValue.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -28,6 +28,7 @@
import java.io.Reader;
import javax.sql.rowset.serial.SerialClob;
+import javax.sql.rowset.serial.SerialException;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
@@ -77,6 +78,27 @@
assertEquals(testString, read.getSubString(1, testString.length()));
}
+ @SuppressWarnings("serial")
+ @Test public void testReferencePersistenceError() throws Exception {
+ String testString = "this is test clob"; //$NON-NLS-1$
+ SerialClob clob = new SerialClob(testString.toCharArray()) {
+ @Override
+ public Reader getCharacterStream() throws SerialException {
+ throw new SerialException();
+ }
+ };
+
+ ClobType cv = new ClobType(clob);
+ cv.setReferenceStreamId(null);
+
+ // now force to serialize
+ ClobType read = UnitTestUtil.helpSerialize(cv);
+
+ assertTrue(read.length() > 0);
+ assertNotNull(read.getReferenceStreamId());
+ assertNull(read.getReference());
+ }
+
@Test public void testClobSubstring() throws Exception {
ClobImpl clob = new ClobImpl() {
public java.io.Reader getCharacterStream() throws java.sql.SQLException {
Modified: branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-12-20 22:07:09 UTC (rev 3754)
+++ branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-12-20 22:40:36 UTC (rev 3755)
@@ -370,6 +370,12 @@
this.resultsBuffer = collector.collectTuples();
if (!doneProducingBatches) {
doneProducingBatches();
+ //TODO: we could perform more tracking to know what source lobs are in use
+ if (this.resultsBuffer.getLobCount() == 0) {
+ for (DataTierTupleSource connectorRequest : getConnectorRequests()) {
+ connectorRequest.fullyCloseSource();
+ }
+ }
addToCache();
}
}
@@ -519,8 +525,8 @@
}
if (batch.getTerminationFlag()) {
doneProducingBatches();
+ addToCache();
}
- addToCache();
synchronized (lobStreams) {
if (resultsBuffer.isLobs()) {
super.flushBatchDirect(batch, false);
@@ -919,12 +925,6 @@
private void doneProducingBatches() {
this.doneProducingBatches = true;
- //TODO: we could perform more tracking to know what source lobs are in use
- if (this.resultsBuffer.getLobCount() == 0) {
- for (DataTierTupleSource connectorRequest : getConnectorRequests()) {
- connectorRequest.fullyCloseSource();
- }
- }
dqpCore.finishProcessing(this);
}
12 years, 11 months
teiid SVN: r3754 - in branches/7.6.x/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/netezza and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-20 17:07:09 -0500 (Tue, 20 Dec 2011)
New Revision: 3754
Modified:
branches/7.6.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java
branches/7.6.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java
Log:
TEIID-1876 changing the bit methods to int4, rather than intn
Modified: branches/7.6.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java
===================================================================
--- branches/7.6.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java 2011-12-20 18:38:15 UTC (rev 3753)
+++ branches/7.6.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java 2011-12-20 22:07:09 UTC (rev 3754)
@@ -44,10 +44,10 @@
@Translator(name = "netezza", description = "A translator for Netezza Database")
public class NetezzaExecutionFactory extends JDBCExecutionFactory {
- private static final String TIME_FORMAT = "HH24:MI:SS";
- private static final String DATE_FORMAT = "YYYY-MM-DD";
- private static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
- private static final String TIMESTAMP_FORMAT = DATETIME_FORMAT + ".MS";
+ private static final String TIME_FORMAT = "HH24:MI:SS"; //$NON-NLS-1$
+ private static final String DATE_FORMAT = "YYYY-MM-DD"; //$NON-NLS-1$
+ private static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT; //$NON-NLS-1$
+ private static final String TIMESTAMP_FORMAT = DATETIME_FORMAT + ".MS"; //$NON-NLS-1$
public NetezzaExecutionFactory() {
setSupportsFullOuterJoins(true);
@@ -62,51 +62,51 @@
//STRING FUNCTION MODIFIERS
////////////////////////////////////
- registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr"));
- registerFunctionModifier(SourceSystemFunctions.LCASE,new AliasModifier("lower"));
- registerFunctionModifier(SourceSystemFunctions.UCASE,new AliasModifier("upper"));
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true));
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||"));
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE,new AliasModifier("lower")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE,new AliasModifier("upper")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||")); //$NON-NLS-1$
///NUMERIC FUNCTION MODIFIERS
////////////////////////////////////
- registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil"));
- registerFunctionModifier(SourceSystemFunctions.POWER, new AliasModifier("pow"));
- registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN"));
+ registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.POWER, new AliasModifier("pow")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
///BIT FUNCTION MODIFIERS
////////////////////////////////////
- registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("intNand"));
- registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("intNnot"));
- registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("intNor"));
- registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("intNxor"));
+ registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("int4and")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("int4not")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("int4or")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("int4xor")); //$NON-NLS-1$
//DATE FUNCTION MODIFIERS
//////////////////////////////////////////
registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ExtractModifier("DOY"));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ExtractModifier("DOY")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.QUARTER, new ExtractFunctionModifier());
registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY"));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.WEEK, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ExtractModifier("DOW"));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ExtractModifier("DOW")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE"));
- registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME"));
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
//SYSTEM FUNCTIONS
////////////////////////////////////
- registerFunctionModifier(SourceSystemFunctions.IFNULL,new AliasModifier("NVL"));
+ registerFunctionModifier(SourceSystemFunctions.IFNULL,new AliasModifier("NVL")); //$NON-NLS-1$
// DATA TYPE CONVERSION
///////////////////////////////////////////
ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
- convertModifier.addTypeMapping("byteint", FunctionModifier.BYTE);
- convertModifier.addTypeMapping("smallint", FunctionModifier.SHORT);
- convertModifier.addTypeMapping("bigint", FunctionModifier.LONG);
- convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER);
- convertModifier.addTypeMapping("numeric(38,18)", FunctionModifier.BIGDECIMAL);
- convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("byteint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convertModifier.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(38,18)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
//convertModifier.addTypeMapping("nvarchar(5)", FunctionModifier.BOOLEAN);
///NO BOOLEAN, INTEGER, FLOAT, DATE, TIME, TIMESTAMP, as they are directly available in netezza
@@ -128,14 +128,14 @@
@Override
public List<?> translate(Function function) {
Expression stringValue = function.getParameters().get(0);
- return Arrays.asList("CASE WHEN ", stringValue, " IN ('false', '0') THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END");
+ return Arrays.asList("CASE WHEN ", stringValue, " IN ('false', '0') THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
});
convertModifier.addTypeConversion(new FunctionModifier() {
@Override
public List<?> translate(Function function) {
Expression stringValue = function.getParameters().get(0);
- return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END");
+ return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}, FunctionModifier.BOOLEAN);
@@ -143,25 +143,25 @@
////////STRING TO DATATYPE CONVERSION OTHER THAN DATE/TIME
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer"));
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double"));
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double")); //$NON-NLS-1$
///// STRING --> CHAR, BYTE, SHORT, LONG, BIGI, BIGD, BOOLEAN is taken care by Type Mapping
///// NO conversion support for NULL, CLOB, BLOB, OBJECT, XML
////STRING TO DATE/TIME CONVERSION////
//////////////////////////////////////
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", DATE_FORMAT));
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_timestamp", TIME_FORMAT));
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", TIMESTAMP_FORMAT));
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", DATE_FORMAT)); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_timestamp", TIME_FORMAT)); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", TIMESTAMP_FORMAT)); //$NON-NLS-1$
//////DATE/TIME INTERNAL CONVERSION/////////
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME"));
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE"));
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP"));
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
//convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //TIME --> TIMESTAMP --DOESN't WORK IN NETEZZA-NO FUNCTION SUPPORT
////DATE/TIME to STRING CONVERION////
/////////////////////////////////////
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", TIMESTAMP_FORMAT));
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", TIMESTAMP_FORMAT)); //$NON-NLS-1$
///NO NETEZAA FUNCTION for DATE, TIME to STRING
@@ -290,7 +290,7 @@
}
@Override
public List<?> translate(Function function) {
- return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")");
+ return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -300,11 +300,11 @@
Expression booleanValue = function.getParameters().get(0);
if (booleanValue instanceof Function) {
Function nested = (Function)booleanValue;
- if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) {
+ if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) { //$NON-NLS-1$
booleanValue = nested.getParameters().get(0);
}
}
- return Arrays.asList("(CASE WHEN ", booleanValue, " IN ( '0', 'FALSE') THEN 0 WHEN ", booleanValue, " IS NOT NULL THEN 1 END)");
+ return Arrays.asList("(CASE WHEN ", booleanValue, " IN ( '0', 'FALSE') THEN 0 WHEN ", booleanValue, " IS NOT NULL THEN 1 END)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -314,11 +314,11 @@
Expression booleanValue = function.getParameters().get(0);
if (booleanValue instanceof Function) {
Function nested = (Function)booleanValue;
- if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) {
+ if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) { //$NON-NLS-1$
booleanValue = nested.getParameters().get(0);
}
}
- return Arrays.asList("CASE WHEN ", booleanValue, " = '0' THEN 'false' WHEN ", booleanValue, " IS NOT NULL THEN 'true' END");
+ return Arrays.asList("CASE WHEN ", booleanValue, " = '0' THEN 'false' WHEN ", booleanValue, " IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -331,7 +331,7 @@
}
@Override
public List<?> translate(Function function) {
- return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")");
+ return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -339,7 +339,7 @@
@Override
public List<?> translateLimit(Limit limit, ExecutionContext context) {
if (limit.getRowOffset() > 0) {
- return Arrays.asList("LIMIT ", limit.getRowLimit(), " OFFSET ", limit.getRowOffset());
+ return Arrays.asList("LIMIT ", limit.getRowLimit(), " OFFSET ", limit.getRowOffset()); //$NON-NLS-1$ //$NON-NLS-2$
}
return null;
}
Modified: branches/7.6.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java
===================================================================
--- branches/7.6.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java 2011-12-20 18:38:15 UTC (rev 3753)
+++ branches/7.6.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java 2011-12-20 22:07:09 UTC (rev 3754)
@@ -206,7 +206,7 @@
@Test public void testBitAnd() throws Exception {
String input = "select bitand(intkey, intnum) from bqt1.smalla";
- String output = "SELECT intNand(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+ String output = "SELECT int4and(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
@@ -214,7 +214,7 @@
}
@Test public void testBitNot() throws Exception {
String input = "select bitnot(intkey) from bqt1.smalla";
- String output = "SELECT intNnot(SmallA.IntKey) FROM SmallA";
+ String output = "SELECT int4not(SmallA.IntKey) FROM SmallA";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
@@ -222,7 +222,7 @@
}
@Test public void testBitOr() throws Exception {
String input = "select bitor(intkey, intnum) from bqt1.smalla";
- String output = "SELECT intNor(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+ String output = "SELECT int4or(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
@@ -230,7 +230,7 @@
}
@Test public void testBitXor() throws Exception {
String input = "select bitxor(intkey, intnum) from bqt1.smalla";
- String output = "SELECT intNxor(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+ String output = "SELECT int4xor(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
12 years, 11 months
teiid SVN: r3753 - in trunk: connectors/connector-salesforce/src/main/rar/META-INF and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-20 13:38:15 -0500 (Tue, 20 Dec 2011)
New Revision: 3753
Added:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
Log:
forward merge from 7.6.x
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2011-12-20 18:38:15 UTC (rev 3753)
@@ -42,6 +42,7 @@
<ul>
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
+ <li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
</ul>
<h4>from 7.x</h4>
Modified: trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2011-12-20 18:38:15 UTC (rev 3753)
@@ -56,7 +56,7 @@
<description>{$display:"Salesforce URL",$description:"URL for connecting to Salesforce",$advanced:"true"}</description>
<config-property-name>URL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
- <config-property-value>https://www.salesforce.com/services/Soap/u/17.0</config-property-value>
+ <config-property-value>https://www.salesforce.com/services/Soap/u/22.0</config-property-value>
</config-property>
<config-property>
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -22,6 +22,10 @@
package org.teiid.translator.jdbc.mysql;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -30,6 +34,7 @@
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.FunctionModifier;
@Translator(name="mysql5", description="A translator for open source MySQL5 Database")
@@ -75,5 +80,25 @@
public String getLikeRegexString() {
return "REGEXP"; //$NON-NLS-1$
}
-
+
+ @Override
+ public Object retrieveValue(ResultSet results, int columnIndex,
+ Class<?> expectedType) throws SQLException {
+ Object result = super.retrieveValue(results, columnIndex, expectedType);
+ if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof Blob) {
+ return results.getString(columnIndex);
+ }
+ return result;
+ }
+
+ @Override
+ public Object retrieveValue(CallableStatement results, int parameterIndex,
+ Class<?> expectedType) throws SQLException {
+ Object result = super.retrieveValue(results, parameterIndex, expectedType);
+ if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof Blob) {
+ return results.getString(parameterIndex);
+ }
+ return result;
+ }
+
}
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-12-20 18:38:15 UTC (rev 3753)
@@ -70,10 +70,10 @@
<para>
Teiid can be configured with multiple named application policies
that group together relevant LoginModules. Each of these application
- policy (or domains) names can be used to fully
- qualify user names to
- authenticate only against that domain. The format for a qualified
- name is username@domainname.
+ policy (or domain) names can be used to fully qualify user names to
+ authenticate only against that domain. The format for a qualified
+ name is username@domainname. The security-domain attribute under the transport/authentication element in the &jboss-beans; file should be used set
+ the comma separated list of desired domains. The securityDomains property defaults to a single domain named teiid-security.
</para>
<para>If a user name is not fully qualified, then the installed
domains will be consulted in order until a domain
@@ -164,7 +164,7 @@
You could do one of the following for Teiid:
<itemizedlist>
<listitem>
- <para>Reuse the teiid-security (or whatever name you choose) security domain for Teiid by changing the teiid configuration &jboss-beans; to point to teiid-security.
+ <para>Reuse the admin-console (or whatever name you choose) security domain for Teiid by changing the teiid configuration &jboss-beans; to point to admin-console.
</para>
</listitem>
@@ -202,7 +202,7 @@
<section>
<title>Remote Connections</title>
- <para>On the server, edit the &jboss-beans; under teiid subsystem on ""transport" definition, add follows:
+ <para>On the server, edit the &jboss-beans; under teiid subsystem on "transport" definition, add follows:
<programlisting><![CDATA[
<transport name="jdbc" protocol="teiid" socket-binding="teiid-jdbc"/>
<authentication security-domain="teiid-security" krb5-domain="krb5-domain"/>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-12-20 18:38:15 UTC (rev 3753)
@@ -1716,24 +1716,16 @@
<tbody>
<row>
<entry>
- <para>DECODESTRING(x, y)</para>
+ <para>DECODESTRING(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as a string</para>
- </entry>
- <entry>
- <para>all string</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>DECODESTRING(x, y, z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as a string
+ with optional delimiter z and return the decoded column as a string.
+ If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
</para>
+ <warning><para>Deprecated. Use a CASE expression instead.</para></warning>
</entry>
<entry>
<para>all string</para>
@@ -1741,29 +1733,21 @@
</row>
<row>
<entry>
- <para>DECODEINTEGER(x, y)</para>
+ <para>DECODEINTEGER(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as an integer</para>
+ with optional delimiter z and return the decoded column as an
+ integer. If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
+ </para>
+ <warning><para>Deprecated. Use a CASE expression instead.</para></warning>
</entry>
<entry>
<para>all string parameters, return integer</para>
</entry>
</row>
- <row>
- <entry>
- <para>DECODEINTEGER(x,y,z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as an
- integer</para>
- </entry>
- <entry>
- <para>all string parameters, return integer</para>
- </entry>
- </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml 2011-12-20 18:38:15 UTC (rev 3753)
@@ -103,7 +103,7 @@
</para>
<para>
The name of the model is used as a
- top level schema name for all of the metadata imported from the
+ top level schema name for all of the metadata imported from the
connector. The name should be unique among all Models in the VDB and
should not contain the '.' character.
</para>
@@ -123,6 +123,7 @@
<itemizedlist>
<title>Source Element</title>
+ <para>A source is a named binding of a translator and connection source to a model.</para>
<listitem>
<para>
<emphasis>name</emphasis>
@@ -131,7 +132,9 @@
The name of the source to use for this
model. This can be any name you like, but will typically be the same
as the model name. Having a name different than the model name is
- only useful in multi-source scenarios.
+ only useful in multi-source scenarios. In multi-source, the source names under a given model must
+ be unique. If you have the same source bound to multiple models it may have the same name
+ for each. An exception will be raised if the same source name is used for different sources.
</para>
</listitem>
<listitem>
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -121,11 +121,7 @@
resolveTypes(insert, metadata, values, usingQuery);
if (!insert.getGroup().isResolved()) { //define the implicit temp group
- if(insert.getQueryExpression() != null) {
- ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(), insert.getQueryExpression().getProjectedSymbols());
- }else {
- ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(), insert.getVariables());
- }
+ ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(), insert.getVariables());
resolveVariables(metadata, insert, groups);
//ensure that the types match
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -41,6 +41,7 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.Transform;
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants;
@@ -2272,7 +2273,10 @@
newCaseExpr.setElseExpression(exprs[0]);
}
- newCaseExpr.setType(function.getType());
+ newCaseExpr.setType(DefaultDataClasses.STRING);
+ if (function.getName().equalsIgnoreCase(FunctionLibrary.DECODEINTEGER)) {
+ return ResolverUtil.getConversion(newCaseExpr, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
+ }
return newCaseExpr;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -70,7 +70,7 @@
public void visit(Function obj) {
this.setDeterminismLevel(obj.getFunctionDescriptor().getDeterministic());
- if (obj.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN) {
+ if (obj.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN || obj.getFunctionDescriptor().getDeterministic() == Determinism.NONDETERMINISTIC) {
evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
} else if (obj.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)
//TODO: if we had the context here we could plan better for non-prepared requests
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -157,9 +158,10 @@
Insert insert = (Insert)command;
TupleSource ts = insert.getTupleSource();
if (ts == null) {
+ Evaluator eval = new Evaluator(Collections.emptyMap(), this, context);
List<Object> values = new ArrayList<Object>(insert.getValues().size());
for (Expression expr : (List<Expression>)insert.getValues()) {
- values.add(Evaluator.evaluate(expr));
+ values.add(eval.evaluate(expr, null));
}
ts = new CollectionTupleSource(Arrays.asList(values).iterator());
}
@@ -345,12 +347,33 @@
throws TeiidComponentException, QueryMetadataException,
TeiidProcessingException, ExpressionEvaluationException,
QueryProcessingException {
- final GroupSymbol group = query.getFrom().getGroups().get(0);
+ GroupSymbol group = query.getFrom().getGroups().get(0);
if (!group.isTempGroupSymbol()) {
return null;
}
final String tableName = group.getNonCorrelationName();
- boolean remapColumns = !tableName.equalsIgnoreCase(group.getName());
+ if (!tableName.equalsIgnoreCase(group.getName())) {
+ group = group.clone();
+ group.setName(tableName);
+ group.setDefinition(null);
+ query.getFrom().getClauses().clear();
+ query.getFrom().addClause(new UnaryFromClause(group));
+ final GroupSymbol newGroup = group;
+ //convert to the actual table symbols (this is typically handled by the languagebridgefactory
+ ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
+ @Override
+ public Expression replaceExpression(Expression element) {
+ if (element instanceof ElementSymbol) {
+ ElementSymbol es = (ElementSymbol)element;
+ es = es.clone();
+ es.setGroupSymbol(newGroup);
+ return es;
+ }
+ return element;
+ }
+ };
+ PostOrderNavigator.doVisit(query, emv);
+ }
TempTable table = null;
if (group.isGlobalTable()) {
final GlobalTableStore globalStore = context.getGlobalTableStore();
@@ -391,21 +414,6 @@
}
}
}
- if (remapColumns) {
- //convert to the actual table symbols (this is typically handled by the languagebridgefactory
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
- @Override
- public Expression replaceExpression(Expression element) {
- if (element instanceof ElementSymbol) {
- ElementSymbol es = (ElementSymbol)element;
- es.getGroupSymbol().setName(tableName);
- es.getGroupSymbol().setDefinition(null);
- }
- return element;
- }
- };
- PostOrderNavigator.doVisit(query, emv);
- }
return table.createTupleSource(query.getProjectedSymbols(), query.getCriteria(), query.getOrderBy());
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -94,6 +94,7 @@
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
+import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings({"nls", "unchecked"})
public class TestProcessor {
@@ -7623,5 +7624,58 @@
Arrays.asList(3)});
}
+ @Test public void testMultipleAliasInUnionAll(){
+ String sql = "SELECT enterprise_id FROM ( " +
+ "SELECT * FROM ( " +
+ " SELECT id, id AS display_id, 103 AS enterprise_id FROM (" +
+ " SELECT 'x' as id, e1 FROM pm1.g1) AS nexted103) as table103Source " +
+ "UNION ALL " +
+ "SELECT 'x', 'x' AS display_id, 101 AS enterprise_id FROM (" +
+ " SELECT 'x', e1 FROM pm1.g1) AS nested101 " +
+ "UNION ALL " +
+ "SELECT 'x', 'x' AS display_id, 100 AS enterprise_id FROM (" +
+ " SELECT 'x', e1 FROM pm1.g1) AS nested100) as tableFrom1stSelect " +
+ "WHERE enterprise_id = 100";
+
+
+ // Create expected results - would expect these to be:
+ List[] expected = new List[] {
+ Arrays.asList(100)
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT 100 FROM pm1.g1 AS g_0", new List[] {Arrays.asList(100)});
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, RealMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder(false));
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testNonDeterministicPushdown() throws Exception {
+ // Create query
+ String sql = "SELECT RAND(), lookup('pm1.g1', 'e1', 'e2', 1) FROM pm1.g1 limit 2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Double(0.1), "a"),
+ Arrays.asList(new Double(0.2), "a"),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager hdm = new HardcodedDataManager();
+ hdm.addData("SELECT RAND() FROM pm1.g1", expected);
+ hdm.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new List<?>[] {Arrays.asList(1, "a")});
+ BasicSourceCapabilities bsc = new BasicSourceCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ bsc.setFunctionSupport(SourceSystemFunctions.RAND, true);
+ // Plan query
+ CommandContext cc = createCommandContext();
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(bsc), cc);
+
+ helpProcess(plan, cc, hdm, expected);
+ }
+
private static final boolean DEBUG = false;
}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275,3535-3555
/branches/7.6.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3673-3711
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3450,3452-3666
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275,3535-3555
/branches/7.6.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3673-3711,3714-3752
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3450,3452-3666
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -2946,5 +2946,9 @@
XMLQuery ex = (XMLQuery) SymbolMap.getExpression(q.getSelect().getSymbols().get(0));
assertEquals(DataTypeManager.DefaultDataClasses.XML, ex.getPassing().get(0).getExpression().getType());
}
+
+ @Test public void testImplicitTempTableWithExplicitColumns() {
+ helpResolve("insert into #temp(x, y) select e1, e2 from pm1.g1");
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -1043,23 +1043,23 @@
}
@Test public void testDefect16879_3(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_4(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_5(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 IS NULL THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_6(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_7(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE 'e' END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCaseExpressionThatResolvesToNull() {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -21,17 +21,13 @@
*/
package org.teiid.jboss;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -150,13 +146,10 @@
LogManager.logDetail(LogConstants.CTX_SECURITY, IntegrationPlugin.Util.getString("socket_binding_not_defined", transportName)); //$NON-NLS-1$
}
- ArrayList<String> domainList = new ArrayList<String>();
+ List<String> domainList = Collections.emptyList();
if (Element.AUTHENTICATION_SECURITY_DOMAIN_ATTRIBUTE.isDefined(operation)) {
String domains = Element.AUTHENTICATION_SECURITY_DOMAIN_ATTRIBUTE.asString(operation);
- StringTokenizer st = new StringTokenizer(domains, ","); //$NON-NLS-1$
- while(st.hasMoreTokens()) {
- domainList.add(st.nextToken());
- }
+ domainList = Arrays.asList(domains.split(","));//$NON-NLS-1$
}
transport.setAuthenticationDomains(domainList);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -250,13 +250,23 @@
IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map = new IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
for (Model model:deployment.getModels()) {
- for (String source:model.getSourceNames()) {
- if (cmr.getConnectorManager(source) != null) {
+ List<String> sourceNames = model.getSourceNames();
+ if (sourceNames.size() != new HashSet<String>(sourceNames).size()) {
+ throw new StartException(IntegrationPlugin.Util.getString("duplicate_source_name", model.getName(), deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+ }
+ for (String source:sourceNames) {
+ ConnectorManager cm = cmr.getConnectorManager(source);
+ String name = model.getSourceTranslatorName(source);
+ String connection = model.getSourceConnectionJndiName(source);
+ if (cm != null) {
+ if (!cm.getTranslatorName().equals(name)
+ || !cm.getConnectionName().equals(connection)) {
+ throw new StartException(IntegrationPlugin.Util.getString("source_name_mismatch", source, deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+ }
continue;
}
- String name = model.getSourceTranslatorName(source);
- ConnectorManager cm = new ConnectorManager(name, model.getSourceConnectionJndiName(source));
+ cm = new ConnectorManager(name, connection);
try {
ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo, getTranslatorRepository(), deployment, map, new HashSet<String>());
cm.setExecutionFactory(ef);
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-20 15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-20 18:38:15 UTC (rev 3753)
@@ -351,4 +351,7 @@
mark-datasource-available.describe=Notify that the defined data source is now available
mark-datasource-available.ds-name.describe=Data Source name
-mark-datasource-available.reply=void
\ No newline at end of file
+mark-datasource-available.reply=void
+
+duplicate_source_name=Source names are not unique for model {0} in {1}.{2}
+source_name_mismatch=There are different sources with the name {0} in {1}.{2}
Added: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java 2011-12-20 18:38:15 UTC (rev 3753)
@@ -0,0 +1,95 @@
+/*
+ * 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.systemmodel;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.LinkedHashMap;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+
+@SuppressWarnings("nls")
+public class TestMatViewAliasing {
+
+ private static final String MATVIEWS = "matviews";
+ private Connection conn;
+ private FakeServer server;
+
+ @Before public void setUp() throws Exception {
+ server = new FakeServer();
+
+ VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
+ MetadataFactory mf = new MetadataFactory("foo", vdbRepository.getBuiltinDatatypes(), new Properties());
+
+ Table mat = mf.addTable("mat");
+ mat.setVirtual(true);
+ mat.setMaterialized(true);
+ mat.setSelectTransformation("/*+ cache(ttl:0) */ select 1 as x, 'y' as Name");
+
+ mf.addColumn("x", DataTypeManager.DefaultDataTypes.INTEGER, mat);
+ mf.addColumn("Name", DataTypeManager.DefaultDataTypes.STRING, mat);
+
+ MetadataStore ms = mf.getMetadataStore();
+
+ server.deployVDB(MATVIEWS, ms, new LinkedHashMap<String, Resource>());
+ conn = server.createConnection("jdbc:teiid:"+MATVIEWS);
+ }
+
+ @After public void tearDown() throws Exception {
+ server.stop();
+ conn.close();
+ }
+
+ @Test public void testSystemMatViewsWithImplicitLoad() throws Exception {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select * from MatViews order by name");
+ assertTrue(rs.next());
+ assertEquals("NEEDS_LOADING", rs.getString("loadstate"));
+ assertEquals(false, rs.getBoolean("valid"));
+
+ rs = s.executeQuery("select * from mat order by x");
+ assertTrue(rs.next());
+ rs = s.executeQuery("select * from MatViews where name = 'mat'");
+ assertTrue(rs.next());
+ assertEquals("LOADED", rs.getString("loadstate"));
+
+ rs = s.executeQuery("select * from mat as a, mat as b where a.x = b.name order by a.x");
+ assertFalse(rs.next());
+ }
+
+}
Property changes on: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 11 months
teiid SVN: r3752 - trunk/client/src/main/java/org/teiid/jdbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-20 10:25:24 -0500 (Tue, 20 Dec 2011)
New Revision: 3752
Modified:
trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
Log:
minor cleanup of listeners
Modified: trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2011-12-19 20:24:05 UTC (rev 3751)
+++ trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2011-12-20 15:25:24 UTC (rev 3752)
@@ -28,8 +28,10 @@
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.HashSet;
+import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
+import java.util.Set;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
@@ -99,7 +101,7 @@
}
}
- private HashSet listeners;
+ private Set<ConnectionEventListener> listeners;
private XAResource resource;
private ConnectionImpl connection;
private ConnectionSource cs;
@@ -141,7 +143,7 @@
public synchronized void addConnectionEventListener(ConnectionEventListener listener){
if(listeners == null){
- listeners = new HashSet();
+ listeners = Collections.newSetFromMap(new IdentityHashMap<ConnectionEventListener, Boolean>());
}
this.listeners.add(listener);
}
@@ -174,9 +176,9 @@
*/
protected synchronized void notifyListener(SQLException e){
if(listeners != null && !listeners.isEmpty()){
- Iterator iter = listeners.iterator();
+ Iterator<ConnectionEventListener> iter = listeners.iterator();
while(iter.hasNext()){
- ConnectionEventListener listener = (ConnectionEventListener)iter.next();
+ ConnectionEventListener listener = iter.next();
if(e == null){
//no exception
listener.connectionClosed(new ConnectionEvent(this));
12 years, 11 months
teiid SVN: r3751 - in branches/7.6.x: test-integration/common/src/test/java/org/teiid/systemmodel and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-12-19 15:24:05 -0500 (Mon, 19 Dec 2011)
New Revision: 3751
Added:
branches/7.6.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
Modified:
branches/7.6.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
Log:
TEIID-1868 fix for partial remapping of a temp table query
Modified: branches/7.6.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/7.6.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-19 18:29:52 UTC (rev 3750)
+++ branches/7.6.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-19 20:24:05 UTC (rev 3751)
@@ -80,6 +80,7 @@
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.lang.Update;
import org.teiid.query.sql.navigator.PostOrderNavigator;
import org.teiid.query.sql.symbol.Constant;
@@ -357,12 +358,33 @@
throws TeiidComponentException, QueryMetadataException,
TeiidProcessingException, ExpressionEvaluationException,
QueryProcessingException {
- final GroupSymbol group = query.getFrom().getGroups().get(0);
+ GroupSymbol group = query.getFrom().getGroups().get(0);
if (!group.isTempGroupSymbol()) {
return null;
}
final String tableName = group.getNonCorrelationName().toUpperCase();
- boolean remapColumns = !tableName.equalsIgnoreCase(group.getName());
+ if (!tableName.equalsIgnoreCase(group.getName())) {
+ group = group.clone();
+ group.setName(tableName);
+ group.setDefinition(null);
+ query.getFrom().getClauses().clear();
+ query.getFrom().addClause(new UnaryFromClause(group));
+ final GroupSymbol newGroup = group;
+ //convert to the actual table symbols (this is typically handled by the languagebridgefactory
+ ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
+ @Override
+ public Expression replaceExpression(Expression element) {
+ if (element instanceof ElementSymbol) {
+ ElementSymbol es = (ElementSymbol)element;
+ es = es.clone();
+ es.setGroupSymbol(newGroup);
+ return es;
+ }
+ return element;
+ }
+ };
+ PostOrderNavigator.doVisit(query, emv);
+ }
TempTable table = null;
if (group.isGlobalTable()) {
final GlobalTableStore globalStore = context.getGlobalTableStore();
@@ -403,21 +425,6 @@
}
}
}
- if (remapColumns) {
- //convert to the actual table symbols (this is typically handled by the languagebridgefactory
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
- @Override
- public Expression replaceExpression(Expression element) {
- if (element instanceof ElementSymbol) {
- ElementSymbol es = (ElementSymbol)element;
- es.getGroupSymbol().setName(tableName);
- es.getGroupSymbol().setDefinition(null);
- }
- return element;
- }
- };
- PostOrderNavigator.doVisit(query, emv);
- }
return table.createTupleSource(query.getProjectedSymbols(), query.getCriteria(), query.getOrderBy());
}
Added: branches/7.6.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
===================================================================
--- branches/7.6.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java (rev 0)
+++ branches/7.6.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java 2011-12-19 20:24:05 UTC (rev 3751)
@@ -0,0 +1,95 @@
+/*
+ * 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.systemmodel;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.LinkedHashMap;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+
+@SuppressWarnings("nls")
+public class TestMatViewAliasing {
+
+ private static final String MATVIEWS = "matviews";
+ private Connection conn;
+ private FakeServer server;
+
+ @Before public void setUp() throws Exception {
+ server = new FakeServer();
+
+ VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
+ MetadataFactory mf = new MetadataFactory("foo", vdbRepository.getBuiltinDatatypes(), new Properties());
+
+ Table mat = mf.addTable("mat");
+ mat.setVirtual(true);
+ mat.setMaterialized(true);
+ mat.setSelectTransformation("/*+ cache(ttl:0) */ select 1 as x, 'y' as Name");
+
+ mf.addColumn("x", DataTypeManager.DefaultDataTypes.INTEGER, mat);
+ mf.addColumn("Name", DataTypeManager.DefaultDataTypes.STRING, mat);
+
+ MetadataStore ms = mf.getMetadataStore();
+
+ server.deployVDB(MATVIEWS, ms, new LinkedHashMap<String, Resource>());
+ conn = server.createConnection("jdbc:teiid:"+MATVIEWS);
+ }
+
+ @After public void tearDown() throws Exception {
+ server.stop();
+ conn.close();
+ }
+
+ @Test public void testSystemMatViewsWithImplicitLoad() throws Exception {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select * from MatViews order by name");
+ assertTrue(rs.next());
+ assertEquals("NEEDS_LOADING", rs.getString("loadstate"));
+ assertEquals(false, rs.getBoolean("valid"));
+
+ rs = s.executeQuery("select * from mat order by x");
+ assertTrue(rs.next());
+ rs = s.executeQuery("select * from MatViews where name = 'mat'");
+ assertTrue(rs.next());
+ assertEquals("LOADED", rs.getString("loadstate"));
+
+ rs = s.executeQuery("select * from mat as a, mat as b where a.x = b.name order by a.x");
+ assertFalse(rs.next());
+ }
+
+}
Property changes on: branches/7.6.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 11 months