[teiid-commits] teiid SVN: r2931 - in branches/7.1.x/runtime/src/main/java/org/teiid: odbc and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Feb 23 13:08:23 EST 2011


Author: rareddy
Date: 2011-02-23 13:08:23 -0500 (Wed, 23 Feb 2011)
New Revision: 2931

Modified:
   branches/7.1.x/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
   branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
Log:
TEIID-1477: Adding support to handle "select version()" call, and couple other 'select' call I have seen with the other tools. Also fixed bug in specifying the pg_type so that pg_attribute transformation returns correct type for the table columns

Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java	2011-02-23 17:57:40 UTC (rev 2930)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java	2011-02-23 18:08:23 UTC (rev 2931)
@@ -369,7 +369,7 @@
 			"   union " + //$NON-NLS-1$
 			"SELECT 20 as oid,  'long' as typname,  (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace,  convert(8, short) as typlen,  convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid  FROM (SELECT 1) X" + //$NON-NLS-1$
 			"   union " + //$NON-NLS-1$
-			"SELECT 23 as oid,  'int' as typname,   (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace,  convert(4, short) as typlen,  convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid  FROM (SELECT 1) X" + //$NON-NLS-1$
+			"SELECT 23 as oid,  'integer' as typname,   (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace,  convert(4, short) as typlen,  convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid  FROM (SELECT 1) X" + //$NON-NLS-1$
 			"   union " + //$NON-NLS-1$
 			"SELECT 26 as oid,  'oid' as typname,  (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typname,    convert(4, short) as typlen,  convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid  FROM (SELECT 1) X" + //$NON-NLS-1$
 			"   union " + //$NON-NLS-1$

Modified: branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-02-23 17:57:40 UTC (rev 2930)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-02-23 18:08:23 UTC (rev 2931)
@@ -34,6 +34,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.teiid.core.util.ApplicationInfo;
 import org.teiid.jdbc.ConnectionImpl;
 import org.teiid.jdbc.TeiidDriver;
 import org.teiid.logging.LogConstants;
@@ -300,7 +301,8 @@
 		// set client_encoding to 'WIN1252'
 		if (sql != null) {
 			// selects are coming with "select\t" so using a space after "select" does not always work
-			if (sql.startsWith("select") || sql.startsWith("SELECT")) { //$NON-NLS-1$ //$NON-NLS-2$
+			String sqlLower = sql.toLowerCase();
+			if (sqlLower.startsWith("select")) { //$NON-NLS-1$
 				modified = sql.replace('\n', ' ');
 											
 				Matcher m = null;
@@ -321,6 +323,15 @@
 								"FKTABLE_NAME, FKCOLUMN_NAME, KEY_SEQ, UPDATE_RULE, DELETE_RULE, FK_NAME, PK_NAME, DEFERRABILITY "+//$NON-NLS-1$
 								"FROM SYS.ReferenceKeyColumns WHERE PKTABLE_NAME LIKE '"+m.group(14)+"' and PKTABLE_SCHEM LIKE '"+m.group(15)+"'";//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 				}
+				else if (modified.equalsIgnoreCase("select version()")) { //$NON-NLS-1$
+					modified = "SELECT 'Teiid "+ApplicationInfo.getInstance().getReleaseNumber()+"'"; //$NON-NLS-1$ //$NON-NLS-2$
+				}
+				else if (modified.startsWith("SELECT name FROM master..sysdatabases")) { //$NON-NLS-1$
+					modified = "SELECT 'Teiid'"; //$NON-NLS-1$
+				}
+				else if (modified.equalsIgnoreCase("select db_name() dbname")) { //$NON-NLS-1$
+					modified = "SELECT current_database()"; //$NON-NLS-1$
+				}
 				else {
 					modified = modified.replaceAll("E'", "'"); //$NON-NLS-1$ //$NON-NLS-2$
 					modified =  modified.replaceAll("::[A-Za-z0-9]*", " "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -342,8 +353,11 @@
 				if (m.matches()) {
 					if (m.group(2).equalsIgnoreCase("client_encoding")) { //$NON-NLS-1$
 						this.client.setEncoding(PGCharsetConverter.getCharset(m.group(4)));
-						modified = "SELECT 'SET'"; //$NON-NLS-1$
 					}
+					else {
+						this.props.setProperty(m.group(2), m.group(4));
+					}
+					modified = "SELECT 'SET'"; //$NON-NLS-1$
 				}
 				else if (modified.equalsIgnoreCase("BEGIN")) { //$NON-NLS-1$
 					try {



More information about the teiid-commits mailing list