Skip to content

Commit

Permalink
TEIID-2689 adding support for regproc cast
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 7, 2013
1 parent 1321cc4 commit d79bf7b
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 178 deletions.
Expand Up @@ -429,8 +429,9 @@ private Table add_pg_type() {
addColumn("typdelim", DataTypeManager.DefaultDataTypes.CHAR, t); //$NON-NLS-1$
addColumn("typrelid", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
addColumn("typelem", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
addColumn("typinput", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
String transformation =
"select oid, typname, (SELECT pg_catalog.getOid(uid) FROM SYS.Schemas where Name = 'SYS') as typnamespace, typlen, typtype, false as typnotnull, typbasetype, typtypmod, cast(',' as char) as typdelim, typrelid, typelem from texttable('" + //$NON-NLS-1$
"select oid, typname, (SELECT pg_catalog.getOid(uid) FROM SYS.Schemas where Name = 'SYS') as typnamespace, typlen, typtype, false as typnotnull, typbasetype, typtypmod, cast(',' as char) as typdelim, typrelid, typelem, null as typeinput from texttable('" + //$NON-NLS-1$
"16,boolean,1,b,0,-1,0,0\n" + //$NON-NLS-1$
"1043,string,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
"25,text,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
Expand Down
12 changes: 12 additions & 0 deletions runtime/src/main/java/org/teiid/odbc/ScriptReader.java
Expand Up @@ -203,6 +203,18 @@ private String readStatementLoop() throws IOException {
}
builder.insert(expressionStart, "(SELECT oid FROM pg_class WHERE upper(relname) = "); //$NON-NLS-1$
builder.append(")"); //$NON-NLS-1$
} else if ("regproc".equalsIgnoreCase(type)) {
String name = builder.substring(expressionStart);
if (name.startsWith("'\"") && name.length() > 4) { //$NON-NLS-1$
name = name.substring(2, name.length()-2);
name = '\''+ name + '\'';
}
if (name.startsWith("'")) { //$NON-NLS-1$
builder.setLength(expressionStart);
builder.append(name.toUpperCase());
}
builder.insert(expressionStart, "(SELECT oid FROM pg_proc WHERE upper(proname) = "); //$NON-NLS-1$
builder.append(")"); //$NON-NLS-1$
} else {
builder.insert(expressionStart, "cast("); //$NON-NLS-1$
builder.append(" AS ").append(type).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down
Expand Up @@ -19,20 +19,20 @@ parts SYS
parts SYSADMIN Triggers Table <null> true false tid:60b87e792634-5d71c5db-00000010 -1 <null> true false <null>
parts SYSADMIN VDBResources Table <null> true false tid:60b87e792634-1e9b1131-0000000c -1 <null> true false <null>
parts SYS VirtualDatabases Table <null> true false tid:2cb59cfd55db-a9e11fad-000000aa -1 <null> true false <null>
parts pg_catalog matpg_datatype Table <null> false false tid:7ff2755e9621-e544c1cc-0000006a -1 <null> true true <null>
parts pg_catalog matpg_relatt Table <null> false false tid:7ff2755e9621-75d65150-00000060 -1 <null> true true <null>
parts pg_catalog pg_am Table <null> false false tid:7ff2755e9621-065a8b74-00000033 -1 <null> true false <null>
parts pg_catalog pg_attrdef Table <null> false false tid:7ff2755e9621-ec00662c-0000004c -1 <null> true false <null>
parts pg_catalog matpg_datatype Table <null> false false tid:7ff2755e9621-e544c1cc-0000006b -1 <null> true true <null>
parts pg_catalog matpg_relatt Table <null> false false tid:7ff2755e9621-75d65150-00000061 -1 <null> true true <null>
parts pg_catalog pg_am Table <null> false false tid:7ff2755e9621-065a8b74-00000034 -1 <null> true false <null>
parts pg_catalog pg_attrdef Table <null> false false tid:7ff2755e9621-ec00662c-0000004d -1 <null> true false <null>
parts pg_catalog pg_attribute Table <null> false false tid:7ff2755e9621-edc4ea54-0000000f -1 <null> true true <null>
parts pg_catalog pg_class Table <null> false false tid:7ff2755e9621-62e78530-00000004 -1 <null> true true <null>
parts pg_catalog pg_database Table <null> false false tid:7ff2755e9621-dda8fac3-00000051 -1 <null> true false <null>
parts pg_catalog pg_description Table <null> false false tid:7ff2755e9621-3be1b5b4-00000072 -1 <null> true false <null>
parts pg_catalog pg_index Table <null> false false tid:7ff2755e9621-633d048a-00000027 -1 <null> true true <null>
parts pg_catalog pg_database Table <null> false false tid:7ff2755e9621-dda8fac3-00000052 -1 <null> true false <null>
parts pg_catalog pg_description Table <null> false false tid:7ff2755e9621-3be1b5b4-00000073 -1 <null> true false <null>
parts pg_catalog pg_index Table <null> false false tid:7ff2755e9621-633d048a-00000028 -1 <null> true true <null>
parts pg_catalog pg_namespace Table <null> false false tid:7ff2755e9621-37a09513-00000001 -1 <null> true false <null>
parts pg_catalog pg_proc Table <null> false false tid:7ff2755e9621-d9ec709e-00000036 -1 <null> true true <null>
parts pg_catalog pg_trigger Table <null> false false tid:7ff2755e9621-d50d2370-00000042 -1 <null> true false <null>
parts pg_catalog pg_proc Table <null> false false tid:7ff2755e9621-d9ec709e-00000037 -1 <null> true true <null>
parts pg_catalog pg_trigger Table <null> false false tid:7ff2755e9621-d50d2370-00000043 -1 <null> true false <null>
parts pg_catalog pg_type Table <null> false false tid:7ff2755e9621-d9ee5c82-0000001b -1 <null> true true <null>
parts pg_catalog pg_user Table <null> false false tid:7ff2755e9621-d9eeb913-0000005b -1 <null> true false <null>
parts pg_catalog pg_user Table <null> false false tid:7ff2755e9621-d9eeb913-0000005c -1 <null> true false <null>
Row Count : 33
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
VDBName 12 parts java.lang.String VDBName string SYS Tables 255 255 0 false true false false 1 true true false false
Expand Down

0 comments on commit d79bf7b

Please sign in to comment.