return t;
}
//data types
private Table add_pg_type() throws TranslatorException {
Table t = createView("pg_type"); //$NON-NLS-1$
// Data type name
addColumn("oid", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
// Data type name
addColumn("typname", DataTypeManager.DefaultDataTypes.STRING, t); //$NON-NLS-1$
// The OID of the namespace that contains this type
addColumn("typnamespace", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
// For a fixed-size type, typlen is the number of bytes in the internal representation of the type.
// But for a variable-length type, typlen is negative. -1 indicates a "varlena" type (one that
// has a length word), -2 indicates a null-terminated C string.
addColumn("typlen", DataTypeManager.DefaultDataTypes.SHORT, t); //$NON-NLS-1$
// typtype is b for a base type, c for a composite type (e.g., a table's row type), d for a domain,
// e for an enum type, or p for a pseudo-type. See also typrelid and typbasetype
addColumn("typtype", DataTypeManager.DefaultDataTypes.CHAR, t); //$NON-NLS-1$
// if this is a domain (see typtype), then typbasetype identifies the type that this one is based on.
// Zero if this type is not a domain
addColumn("typbasetype", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
// Domains use typtypmod to record the typmod to be applied to their base type
// (-1 if base type does not use a typmod). -1 if this type is not a domain
addColumn("typtypmod", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
addColumn("typrelid", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
addColumn("typelem", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
String transformation =
"SELECT 16 as oid, 'boolean' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
//"SELECT 17 as oid, 'blob' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
//" union " + //$NON-NLS-1$
"SELECT 1043 as oid, 'string' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 25 as oid, 'text' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1042 as oid, 'char' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 21 as oid, 'short' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(2, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$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, 0 as typelem 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 700 as oid, 'float' 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 701 as oid, 'double' 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
//"SELECT 1009 as oid, 'clob' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
//" union " + //$NON-NLS-1$
"SELECT 1082 as oid, 'date' 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1083 as oid, 'datetime' 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1114 as oid, 'timestamp' 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, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1700 as oid, 'decimal' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 142 as oid, 'xml' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 14939 as oid, 'lo' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X"+//$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 2278 as oid, 'void' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(4, short) as typlen, convert('p', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 2249 as oid, 'record' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('p', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 30 as oid, 'oidvector' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 26 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1000 as oid, '_bool' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 16 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1002 as oid, '_char' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 18 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1005 as oid, '_int2' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 21 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1007 as oid, '_int4' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 23 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1009 as oid, '_text' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 25 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1028 as oid, '_oid' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 26 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1014 as oid, '_bpchar' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1042 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1015 as oid, '_varchar' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1043 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1016 as oid, '_int8' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 20 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1021 as oid, '_float4' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 700 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1022 as oid, '_float8' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 701 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1115 as oid, '_timestamp' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1114 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1182 as oid, '_date' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1082 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 1183 as oid, '_time' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1083 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
" union " + //$NON-NLS-1$
"SELECT 2287 as oid, '_record' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 2249 as typelem FROM (SELECT 1) X"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
return t;
}