* @return a <code>Table</code> object describing all of the
* standard SQL types known to this database
*/
final Table SYSTEM_ALLTYPEINFO() {
Table t = sysTables[SYSTEM_ALLTYPEINFO];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_ALLTYPEINFO]);
//-------------------------------------------
// same as SYSTEM_TYPEINFO:
// ------------------------------------------
addColumn(t, "TYPE_NAME", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", Type.SQL_SMALLINT);
addColumn(t, "PRECISION", Type.SQL_INTEGER);
addColumn(t, "LITERAL_PREFIX", CHARACTER_DATA);
addColumn(t, "LITERAL_SUFFIX", CHARACTER_DATA);
addColumn(t, "CREATE_PARAMS", CHARACTER_DATA);
addColumn(t, "NULLABLE", Type.SQL_SMALLINT);
addColumn(t, "CASE_SENSITIVE", Type.SQL_BOOLEAN);
addColumn(t, "SEARCHABLE", Type.SQL_SMALLINT);
addColumn(t, "UNSIGNED_ATTRIBUTE", Type.SQL_BOOLEAN);
addColumn(t, "FIXED_PREC_SCALE", Type.SQL_BOOLEAN);
addColumn(t, "AUTO_INCREMENT", Type.SQL_BOOLEAN);
addColumn(t, "LOCAL_TYPE_NAME", SQL_IDENTIFIER);
addColumn(t, "MINIMUM_SCALE", Type.SQL_SMALLINT);
addColumn(t, "MAXIMUM_SCALE", Type.SQL_SMALLINT);
addColumn(t, "SQL_DATA_TYPE", Type.SQL_INTEGER);
addColumn(t, "SQL_DATETIME_SUB", Type.SQL_INTEGER);
addColumn(t, "NUM_PREC_RADIX", Type.SQL_INTEGER);
//-------------------------------------------
// SQL CLI / ODBC - not in JDBC spec
// ------------------------------------------
addColumn(t, "INTERVAL_PRECISION", Type.SQL_INTEGER);
//-------------------------------------------
// extended:
//-------------------------------------------
// level of support
//-------------------------------------------
addColumn(t, "AS_TAB_COL", Type.SQL_BOOLEAN);
// for instance, some executable methods take Connection
// or return non-serializable Object such as ResultSet, neither
// of which maps to a supported table column type but which
// we show as JAVA_OBJECT in SYSTEM_PROCEDURECOLUMNS.
// Also, triggers take Object[] row, which we show as ARRAY
// presently, although STRUCT would probably be better in the
// future, as the row can actually contain mixed data types.
addColumn(t, "AS_PROC_COL", Type.SQL_BOOLEAN);
//-------------------------------------------
// actual values for attributes that cannot be represented
// within the limitations of the SQL CLI / JDBC interface
//-------------------------------------------
addColumn(t, "MAX_PREC_ACT", Type.SQL_BIGINT);
addColumn(t, "MIN_SCALE_ACT", Type.SQL_INTEGER);
addColumn(t, "MAX_SCALE_ACT", Type.SQL_INTEGER);
//-------------------------------------------
// how do we store this internally as a column value?
//-------------------------------------------
addColumn(t, "COL_ST_CLS_NAME", SQL_IDENTIFIER);
addColumn(t, "COL_ST_IS_SUP", Type.SQL_BOOLEAN);
//-------------------------------------------
// what is the standard Java mapping for the type?
//-------------------------------------------
addColumn(t, "STD_MAP_CLS_NAME", SQL_IDENTIFIER);
addColumn(t, "STD_MAP_IS_SUP", Type.SQL_BOOLEAN);
//-------------------------------------------
// what, if any, custom mapping do we provide?
// (under the current build options and hosting VM)
//-------------------------------------------
addColumn(t, "CST_MAP_CLS_NAME", SQL_IDENTIFIER);
addColumn(t, "CST_MAP_IS_SUP", Type.SQL_BOOLEAN);
//-------------------------------------------
// what is the max representable and actual
// character octet length, if applicable?
//-------------------------------------------
addColumn(t, "MCOL_JDBC", Type.SQL_INTEGER);
addColumn(t, "MCOL_ACT", Type.SQL_BIGINT);
//-------------------------------------------
// what is the default or fixed scale, if applicable?
//-------------------------------------------
addColumn(t, "DEF_OR_FIXED_SCALE", Type.SQL_INTEGER);
//-------------------------------------------
// Any type-specific, localized remarks can go here
//-------------------------------------------
addColumn(t, "REMARKS", CHARACTER_DATA);
//-------------------------------------------
// required for JDBC sort contract:
//-------------------------------------------
addColumn(t, "TYPE_SUB", Type.SQL_INTEGER);
// order: DATA_TYPE, TYPE_SUB
// true primary key
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
sysTableHsqlNames[SYSTEM_ALLTYPEINFO].name, false,
SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] {
1, 34
}, true);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Object[] row;
int type;
DITypeInfo ti;
//-----------------------------------------
// Same as SYSTEM_TYPEINFO
//-----------------------------------------
final int itype_name = 0;
final int idata_type = 1;
final int iprecision = 2;
final int iliteral_prefix = 3;
final int iliteral_suffix = 4;
final int icreate_params = 5;
final int inullable = 6;
final int icase_sensitive = 7;
final int isearchable = 8;
final int iunsigned_attribute = 9;
final int ifixed_prec_scale = 10;
final int iauto_increment = 11;
final int ilocal_type_name = 12;
final int iminimum_scale = 13;
final int imaximum_scale = 14;
final int isql_data_type = 15;
final int isql_datetime_sub = 16;
final int inum_prec_radix = 17;
//------------------------------------------
// Extensions
//------------------------------------------
// not in JDBC, but in SQL CLI SQLDA / ODBC
//------------------------------------------
final int iinterval_precision = 18;
//------------------------------------------
// HSQLDB/Java-specific:
//------------------------------------------
final int iis_sup_as_tcol = 19;
final int iis_sup_as_pcol = 20;
//------------------------------------------
final int imax_prec_or_len_act = 21;
final int imin_scale_actual = 22;
final int imax_scale_actual = 23;
//------------------------------------------
final int ics_cls_name = 24;
final int ics_cls_is_supported = 25;
//------------------------------------------
final int ism_cls_name = 26;
final int ism_cls_is_supported = 27;
//------------------------------------------
final int icm_cls_name = 28;
final int icm_cls_is_supported = 29;
//------------------------------------------
final int imax_char_oct_len_jdbc = 30;
final int imax_char_oct_len_act = 31;
//------------------------------------------
final int idef_or_fixed_scale = 32;
//------------------------------------------
final int iremarks = 33;
//------------------------------------------
final int itype_sub = 34;
ti = new DITypeInfo();
for (int i = 0; i < Types.ALL_TYPES.length; i++) {
ti.setTypeCode(Types.ALL_TYPES[i][0]);
ti.setTypeSub(Types.ALL_TYPES[i][1]);
row = t.getEmptyRowData();
row[itype_name] = ti.getTypeName();
row[idata_type] = ti.getDataType();
row[iprecision] = ti.getPrecision();
row[iliteral_prefix] = ti.getLiteralPrefix();
row[iliteral_suffix] = ti.getLiteralSuffix();
row[icreate_params] = ti.getCreateParams();
row[inullable] = ti.getNullability();
row[icase_sensitive] = ti.isCaseSensitive();
row[isearchable] = ti.getSearchability();
row[iunsigned_attribute] = ti.isUnsignedAttribute();
row[ifixed_prec_scale] = ti.isFixedPrecisionScale();
row[iauto_increment] = ti.isAutoIncrement();
row[ilocal_type_name] = ti.getLocalName();
row[iminimum_scale] = ti.getMinScale();
row[imaximum_scale] = ti.getMaxScale();
row[isql_data_type] = ti.getSqlDataType();
row[isql_datetime_sub] = ti.getSqlDateTimeSub();
row[inum_prec_radix] = ti.getNumPrecRadix();
//------------------------------------------
row[iinterval_precision] = ti.getIntervalPrecision();
//------------------------------------------
row[iis_sup_as_tcol] = ti.isSupportedAsTCol();
row[iis_sup_as_pcol] = ti.isSupportedAsPCol();
//------------------------------------------
row[imax_prec_or_len_act] = ti.getPrecisionAct();
row[imin_scale_actual] = ti.getMinScaleAct();
row[imax_scale_actual] = ti.getMaxScaleAct();
//------------------------------------------
row[ics_cls_name] = ti.getColStClsName();
row[ics_cls_is_supported] = ti.isColStClsSupported();
//------------------------------------------
row[ism_cls_name] = ti.getStdMapClsName();
row[ism_cls_is_supported] = ti.isStdMapClsSupported();
//------------------------------------------
row[icm_cls_name] = ti.getCstMapClsName();
try {
if (row[icm_cls_name] != null) {
ns.classForName((String) row[icm_cls_name]);
row[icm_cls_is_supported] = Boolean.TRUE;
}
} catch (Exception e) {
row[icm_cls_is_supported] = Boolean.FALSE;
}
//------------------------------------------
row[imax_char_oct_len_jdbc] = ti.getCharOctLen();
row[imax_char_oct_len_act] = ti.getCharOctLenAct();
//------------------------------------------
row[idef_or_fixed_scale] = ti.getDefaultScale();
//------------------------------------------
row[iremarks] = ti.getRemarks();
//------------------------------------------
row[itype_sub] = ti.getDataTypeSub();
t.insertSys(store, row);
}
return t;
}