diff --git a/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html b/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
index 4785ccfe9d..2356ff1239 100644
--- a/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
+++ b/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
@@ -29,6 +29,7 @@
Highlights
TEIID-3009 WITH project minimization - common table expressions will have their project columns minimized.
TEIID-3038 geoSpatial support for MongoDB translator
TEIID-3050 Increased Insert Performance with sources that support batching or insert with iterator.
+ TEIID-3044 Function Metadata is available through system tables and DatabaseMetaData.
diff --git a/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java b/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
index 21bdd29df6..0a3625824d 100644
--- a/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
+++ b/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
@@ -255,6 +255,29 @@ final private static class RUNTIME_MODEL{
.append(" WHERE UCASE(VDBName)").append(LIKE_ESCAPE)//$NON-NLS-1$
.append(" AND UCASE(Name)").append(LIKE_ESCAPE)//$NON-NLS-1$
.append(" ORDER BY TABLE_SCHEM").toString(); //$NON-NLS-1$
+
+ private static final String QUERY_FUNCTIONS = new StringBuffer("SELECT VDBName AS Function_CAT, SchemaName AS FUNCTION_SCHEM, " //$NON-NLS-1$
+ + "Name AS FUNCTION_NAME, Description as REMARKS, 1 as FUNCTION_TYPE, UID AS SPECIFIC_NAME") //$NON-NLS-1$
+ .append(" FROM ").append(RUNTIME_MODEL.VIRTUAL_MODEL_NAME).append(".Functions") //$NON-NLS-1$ //$NON-NLS-2$
+ .append(" WHERE UCASE(VDBName)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" AND UCASE(SchemaName)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" AND UCASE(Name)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" ORDER BY FUNCTION_CAT, FUNCTION_SCHEM, FUNCTION_NAME, SPECIFIC_NAME").toString(); //$NON-NLS-1$
+
+ private static final String QUERY_FUNCTION_COLUMNS = new StringBuffer("SELECT VDBName AS Function_CAT, SchemaName AS FUNCTION_SCHEM, ") //$NON-NLS-1$
+ .append("FunctionName AS FUNCTION_NAME, Name as COLUMN_NAME, CASE WHEN Type = 'ReturnValue' Then 4 WHEN Type = 'In' Then 1 ELSE 0 END AS COLUMN_TYPE") //$NON-NLS-1$
+ .append(", 1 AS DATA_TYPE") //$NON-NLS-1$
+ .append(", DataType AS TYPE_NAME, \"Precision\" AS \"PRECISION\", TypeLength AS LENGTH, convert(Scale, short) AS SCALE") //$NON-NLS-1$
+ .append(", Radix AS RADIX, convert(decodeString(NullType, '") //$NON-NLS-1$
+ .append(PROC_COLUMN_NULLABILITY_MAPPING).append("', ','), integer) AS NULLABLE") //$NON-NLS-1$
+ .append(", Description AS REMARKS, NULL AS CHAR_OCTET_LENGTH, Position AS ORDINAL_POSITION,") //$NON-NLS-1$
+ .append(IS_NULLABLE).append(", FunctionUID as SPECIFIC_NAME") //$NON-NLS-1$
+ .append(" FROM ").append(RUNTIME_MODEL.VIRTUAL_MODEL_NAME).append(".FunctionParams") //$NON-NLS-1$ //$NON-NLS-2$
+ .append(" WHERE UCASE(VDBName)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" AND UCASE(SchemaName)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" AND UCASE(FunctionName)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" AND UCASE(Name)").append(LIKE_ESCAPE)//$NON-NLS-1$
+ .append(" ORDER BY FUNCTION_CAT, FUNCTION_SCHEM, FUNCTION_NAME, SPECIFIC_NAME, ORDINAL_POSITION").toString(); //$NON-NLS-1$
private final String TABLE_TYPE;
@@ -2267,12 +2290,121 @@ public ResultSet getClientInfoProperties() throws SQLException {
public ResultSet getFunctionColumns(String catalog, String schemaPattern,
String functionNamePattern, String columnNamePattern)
throws SQLException {
- throw SqlUtil.createFeatureNotSupportedException();
+ if (catalog == null) {
+ catalog = PERCENT;
+ }
+
+ if (schemaPattern == null) {
+ schemaPattern = PERCENT;
+ }
+
+ if (functionNamePattern == null) {
+ functionNamePattern = PERCENT;
+ }
+
+ if (columnNamePattern == null) {
+ columnNamePattern = PERCENT;
+ }
+
+ List records = new ArrayList ();
+
+ ResultSetMetaData rmetadata = null;
+ ResultSetImpl results = null;
+ PreparedStatementImpl prepareQuery = null;
+ try {
+ prepareQuery = driverConnection.prepareStatement(QUERY_FUNCTION_COLUMNS);
+ prepareQuery.setString(1, catalog.toUpperCase());
+ prepareQuery.setString(2, schemaPattern.toUpperCase());
+ prepareQuery.setString(3, functionNamePattern.toUpperCase());
+ prepareQuery.setString(4, columnNamePattern.toUpperCase());
+ results = prepareQuery.executeQuery();
+ // Get the metadata for the results
+ rmetadata = results.getMetaData();
+ int cols = rmetadata.getColumnCount();
+ while (results.next ()) {
+ List currentRow = new ArrayList (cols);
+ for(int i=0; i < cols; i++) {
+ currentRow.add(results.getObject(i+1));
+ }
+ String typeName = (String)currentRow.get(6);
+ Integer length = (Integer)currentRow.get(8);
+ Integer precision = (Integer)currentRow.get(7);
+ if (precision != null && precision <= 0) {
+ currentRow.set(7, JDBCSQLTypeInfo.getDefaultPrecision(typeName));
+ }
+ if (length != null && length <= 0) {
+ currentRow.set(8, JDBCSQLTypeInfo.getDefaultPrecision(typeName));
+ }
+ if (typeName != null) {
+ currentRow.set(5, JDBCSQLTypeInfo.getSQLType(typeName));
+ } else {
+ currentRow.set(5, null);
+ }
+ // add the current row to the list of records.
+ records.add(currentRow);
+ }// end of while
+
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getfunctioncolumns_success")); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return dummyStatement().createResultSet(records, rmetadata);
+ } catch(Exception e) {
+ throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getfunctioncolumns_error", e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
+ }
}
public ResultSet getFunctions(String catalog, String schemaPattern,
String functionNamePattern) throws SQLException {
- throw SqlUtil.createFeatureNotSupportedException();
+ if (catalog == null) {
+ catalog = PERCENT;
+ }
+
+ if (schemaPattern == null) {
+ schemaPattern = PERCENT;
+ }
+
+ if (functionNamePattern == null) {
+ functionNamePattern = PERCENT;
+ }
+ List records = new ArrayList ();
+
+ ResultSetMetaData rmetadata = null;
+ ResultSetImpl results = null;
+ PreparedStatementImpl prepareQuery = null;
+ try {
+ prepareQuery = driverConnection.prepareStatement(QUERY_FUNCTIONS);
+ prepareQuery.setString(1, catalog.toUpperCase());
+ prepareQuery.setString(2, schemaPattern.toUpperCase());
+ prepareQuery.setString(3, functionNamePattern.toUpperCase());
+ results = prepareQuery.executeQuery();
+ // Get the metadata for the results
+ rmetadata = results.getMetaData();
+ int cols = rmetadata.getColumnCount();
+ while (results.next ()) {
+ List currentRow = new ArrayList(cols);
+
+ for(int i = 0; i < cols; i++) {
+ currentRow.add(results.getObject(i+1));
+ }
+
+ records.add(currentRow);
+ }
+
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getfunctions_success")); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return dummyStatement().createResultSet(records, rmetadata);
+ } catch(Exception e) {
+ throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getfunctions_error", e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
+ }
}
public RowIdLifetime getRowIdLifetime() throws SQLException {
diff --git a/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java b/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
index 0bbbb4755b..ea63f10bc2 100644
--- a/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
+++ b/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
@@ -257,7 +257,7 @@ public int[] executeBatch() throws SQLException {
}
@Override
- public ResultSet executeQuery() throws SQLException {
+ public ResultSetImpl executeQuery() throws SQLException {
executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET, true, null, autoGeneratedKeys);
return resultSet;
}
diff --git a/client/src/main/resources/org/teiid/jdbc/i18n.properties b/client/src/main/resources/org/teiid/jdbc/i18n.properties
index cb6fd0b92f..bc4c543ebd 100644
--- a/client/src/main/resources/org/teiid/jdbc/i18n.properties
+++ b/client/src/main/resources/org/teiid/jdbc/i18n.properties
@@ -66,7 +66,11 @@ MMDatabaseMetadata.getProcCol_success=Successfully obtained metadata info for th
MMDatabaseMetadata.getProc_error=Error trying to get metadata information for procedure name like {0} - {1}.
MMDatabaseMetadata.getProc_success=Successfully obtained metadata information for the procedure whose name matches {0}.
MMDatabaseMetadata.getschema_error=Error trying to obtain schema metadata info on this connection: {0}.
-MMDatabaseMetadata.getschema_success=Schema metadata info successfully obtained for this connection.
+MMDatabaseMetadata.getschema_success=Schema metadata info successfully obtained for this connection.
+MMDatabaseMetadata.getfunctions_error=Error trying to obtain function metadata info on this connection: {0}.
+MMDatabaseMetadata.getfunctions_success=Function metadata info successfully obtained for this connection.
+MMDatabaseMetadata.getfunctioncolumns_error=Error trying to obtain function param metadata info on this connection: {0}.
+MMDatabaseMetadata.getfunctioncolumns_success=Function param metadata info successfully obtained for this connection.
MMDatabaseMetadata.getTable_error=Error trying to obtain metadata information for the tables that match {0}: {1}.
MMDatabaseMetadata.getTable_success=Successfully obtained metadata information for the table names that match {0}.
MMDatabaseMetadata.getTableType_success=Successfully obtained metadata information for the table types.
diff --git a/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java b/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
index 82ce38939e..368c6fb029 100644
--- a/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
+++ b/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
@@ -523,9 +523,9 @@ public void fillRow(List