Author: shawkins
Date: 2009-05-12 20:57:35 -0400 (Tue, 12 May 2009)
New Revision: 920
Added:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
Log:
TEIID-105 adding mysql support for bit operations and creating a mysql 5 specific
translator/capabilities.
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
---
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2009-05-12
22:13:24 UTC (rev 919)
+++
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2009-05-13
00:57:35 UTC (rev 920)
@@ -85,7 +85,7 @@
public class SQLStringVisitor extends AbstractLanguageVisitor implements SQLReservedWords
{
private Set<String> infixFunctions = new
HashSet<String>(Arrays.asList("%", "+", "-",
"*", "+", "/", "||", //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "&", "~", "|", "^")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "&", "|", "^")); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
private static final String ESCAPED_QUOTE = "''"; //$NON-NLS-1$
Added:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
===================================================================
---
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
(rev 0)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java 2009-05-13
00:57:35 UTC (rev 920)
@@ -0,0 +1,49 @@
+/*
+ * 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.connector.jdbc.mysql;
+
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.jdbc.translator.AliasModifier;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+public class BitFunctionModifier extends AliasModifier {
+ private ILanguageFactory langFactory;
+
+ public BitFunctionModifier(String alias, ILanguageFactory langFactory) {
+ super(alias);
+ this.langFactory = langFactory;
+ }
+
+ /**
+ * Wrap the renamed function in a convert back to integer
+ */
+ @Override
+ public IExpression modify(IFunction function) {
+ return langFactory.createFunction(SourceSystemFunctions.CONVERT,
+ new IExpression[] {super.modify(function),
langFactory.createLiteral(MySQLConvertModifier.SIGNED_INTEGER,
TypeFacility.RUNTIME_TYPES.STRING)}, TypeFacility.RUNTIME_TYPES.INTEGER);
+ }
+
+}
Property changes on:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java
===================================================================
---
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java 2009-05-12
22:13:24 UTC (rev 919)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java 2009-05-13
00:57:35 UTC (rev 920)
@@ -41,7 +41,9 @@
*/
class MySQLConvertModifier extends BasicFunctionModifier {
- private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
+ public static final String SIGNED_INTEGER = "SIGNED INTEGER";
//$NON-NLS-1$
+
+ private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
private ILanguageFactory langFactory;
@@ -66,7 +68,7 @@
} else if (target.equals("byte") || //$NON-NLS-1$
target.equals("short") || //$NON-NLS-1$
target.equals("integer")) { //$NON-NLS-1$
- return convertToNativeType(function, "SIGNED INTEGER");
//$NON-NLS-1$
+ return convertToNativeType(function, SIGNED_INTEGER);
} else if (target.equals("long") || //$NON-NLS-1$
target.equals("biginteger")) { //$NON-NLS-1$
return convertToNativeType(function, "SIGNED"); //$NON-NLS-1$
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
---
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-12
22:13:24 UTC (rev 919)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-13
00:57:35 UTC (rev 920)
@@ -33,7 +33,6 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.SourceSystemFunctions;
-import org.teiid.connector.jdbc.translator.AliasModifier;
import org.teiid.connector.jdbc.translator.Translator;
@@ -47,10 +46,10 @@
public void initialize(ConnectorEnvironment env) throws ConnectorException {
super.initialize(env);
registerFunctionModifier(SourceSystemFunctions.CONVERT, new
MySQLConvertModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.BITAND, new
AliasModifier("&")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITNOT, new
AliasModifier("~")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITOR, new
AliasModifier("|")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITXOR, new
AliasModifier("^")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITAND, new
BitFunctionModifier("&", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITNOT, new
BitFunctionModifier("~", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITOR, new
BitFunctionModifier("|", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITXOR, new
BitFunctionModifier("^", getLanguageFactory())); //$NON-NLS-1$
}
@Override