use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class DatabaseInformationFull method JAR_JAR_USAGE.
Table JAR_JAR_USAGE() {
Table t = sysTables[JAR_JAR_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[JAR_JAR_USAGE]);
addColumn(t, "PATH_JAR_CATALOG", SQL_IDENTIFIER);
addColumn(t, "PATH_JAR_SCHAMA", SQL_IDENTIFIER);
addColumn(t, "PATH_JAR_NAME", SQL_IDENTIFIER);
addColumn(t, "JAR_CATALOG", SQL_IDENTIFIER);
addColumn(t, "JAR_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "JAR_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[JAR_JAR_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
return t;
}
// column number mappings
final int path_jar_catalog = 0;
final int path_jar_schema = 1;
final int path_jar_name = 2;
final int jar_catalog = 3;
final int jar_schema = 4;
final int jar_name = 5;
//
Iterator it;
Object[] row;
return t;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class DatabaseInformationFull method COLUMN_UDT_USAGE.
/**
* UDT's are shown if the authorization is the user or a role given to the
* user.
*
* <p>
*
* @return Table
*/
Table COLUMN_UDT_USAGE() {
Table t = sysTables[COLUMN_UDT_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[COLUMN_UDT_USAGE]);
addColumn(t, "UDT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "UDT_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "UDT_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[COLUMN_UDT_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
Result rs = sys.executeDirectStatement("SELECT UDT_CATALOG, UDT_SCHEMA, UDT_NAME, TABLE_CATALOG, " + "TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE UDT_NAME IS NOT NULL;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class DatabaseInformationMain method SYSTEM_PROCEDURECOLUMNS.
/**
* Retrieves a <code>Table</code> object describing the
* return, parameter and result columns of the accessible
* routines defined within this database.<p>
*
* Each row is a procedure column description with the following
* columns: <p>
*
* <pre class="SqlCodeExample">
* PROCEDURE_CAT VARCHAR routine catalog
* PROCEDURE_SCHEM VARCHAR routine schema
* PROCEDURE_NAME VARCHAR routine name
* COLUMN_NAME VARCHAR column/parameter name
* COLUMN_TYPE SMALLINT kind of column/parameter
* DATA_TYPE SMALLINT SQL type from DITypes
* TYPE_NAME VARCHAR SQL type name
* PRECISION INTEGER precision (length) of type
* LENGTH INTEGER transfer size, in bytes, if definitely known
* (roughly equivalent to BUFFER_SIZE for table
* columns)
* SCALE SMALLINT scale
* RADIX SMALLINT radix
* NULLABLE SMALLINT can column contain NULL?
* REMARKS VARCHAR explanatory comment on column
* // JDBC 4.0
* COLUMN_DEF VARCHAR The default column value.
* The string NULL (not enclosed in quotes)
* - If NULL was specified as the default value
* TRUNCATE (not enclosed in quotes)
* - If the specified default value cannot be
* represented without truncation
* NULL
* - If a default value was not specified
* SQL_DATA_TYPE INTEGER CLI type list from SQL 2003 Table 37,
* tables 6-9 Annex A1, and/or addendums in other
* documents, such as:
* SQL 2003 Part 9: Management of External Data (SQL/MED) : DATALINK
* SQL 2003 Part 14: XML-Related Specifications (SQL/XML) : XML
* SQL_DATETIME_SUB INTEGER SQL 2003 CLI datetime/interval subcode.
* CHAR_OCTET_LENGTH INTEGER The maximum length of binary and character
* based columns. For any other datatype the
* returned value is a NULL
* ORDINAL_POSITION INTEGER The ordinal position, starting from 1, for the
* input and output parameters for a procedure.
* A value of 0 is returned if this row describes
* the procedure's return value.
* IS_NULLABLE VARCHAR ISO rules are used to determinte the nulliblity
* for a column.
*
* YES (enclosed in quotes) --- if the column can include NULLs
* NO (enclosed in quotes) --- if the column cannot include NULLs
* empty string --- if the nullability for the column is unknown
*
* SPECIFIC_NAME VARCHAR The name which uniquely identifies this
* procedure within its schema.
* Typically (but not restricted to) a
* fully qualified Java Method name and
* signature
* // HSQLDB extension
* JDBC_SEQ INTEGER The JDBC-specified order within
* runs of PROCEDURE_SCHEM, PROCEDURE_NAME,
* SPECIFIC_NAME, which is:
*
* return value (0), if any, first, followed
* by the parameter descriptions in call order
* (1..n1), followed by the result column
* descriptions in column number order
* (n1 + 1..n1 + n2)
* </pre> <p>
*
* @return a <code>Table</code> object describing the
* return, parameter and result columns
* of the accessible routines defined
* within this database.
*/
Table SYSTEM_PROCEDURECOLUMNS() {
Table t = sysTables[SYSTEM_PROCEDURECOLUMNS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_PROCEDURECOLUMNS]);
// ----------------------------------------------------------------
// required
// ----------------------------------------------------------------
// 0
addColumn(t, "PROCEDURE_CAT", SQL_IDENTIFIER);
// 1
addColumn(t, "PROCEDURE_SCHEM", SQL_IDENTIFIER);
// not null
addColumn(t, "PROCEDURE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "COLUMN_TYPE", Type.SQL_SMALLINT);
// not null
addColumn(t, "DATA_TYPE", Type.SQL_SMALLINT);
// not null
addColumn(t, "TYPE_NAME", SQL_IDENTIFIER);
// 7
addColumn(t, "PRECISION", Type.SQL_INTEGER);
// 8
addColumn(t, "LENGTH", Type.SQL_INTEGER);
// 9
addColumn(t, "SCALE", Type.SQL_SMALLINT);
// 10
addColumn(t, "RADIX", Type.SQL_SMALLINT);
// not null
addColumn(t, "NULLABLE", Type.SQL_SMALLINT);
// 12
addColumn(t, "REMARKS", CHARACTER_DATA);
// ----------------------------------------------------------------
// JDBC 4.0
// ----------------------------------------------------------------
// 13
addColumn(t, "COLUMN_DEF", CHARACTER_DATA);
// 14
addColumn(t, "SQL_DATA_TYPE", Type.SQL_INTEGER);
// 15
addColumn(t, "SQL_DATETIME_SUB", Type.SQL_INTEGER);
// 16
addColumn(t, "CHAR_OCTET_LENGTH", Type.SQL_INTEGER);
// not null
addColumn(t, "ORDINAL_POSITION", Type.SQL_INTEGER);
// not null
addColumn(t, "IS_NULLABLE", CHARACTER_DATA);
// not null
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
// ----------------------------------------------------------------
// just for JDBC sort contract
// ----------------------------------------------------------------
// not null
addColumn(t, "JDBC_SEQ", Type.SQL_INTEGER);
// ----------------------------------------------------------------
// order: PROCEDURE_SCHEM, PROCEDURE_NAME, SPECIFIC_NAME, SEQ
// added for unique: PROCEDURE_CAT
// false PK, as PROCEDURE_SCHEM and/or PROCEDURE_CAT may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SYSTEM_PROCEDURECOLUMNS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 1, 2, 19, 20, 0 }, false);
return t;
}
// calculated column values
String procedureCatalog;
String procedureSchema;
String procedureName;
String columnName;
Integer columnType;
Integer dataType;
String dataTypeName;
Integer precision;
Integer length;
Integer scale;
Integer radix;
Integer nullability;
String remark;
// JDBC 4.0
String colDefault;
Integer sqlDataType;
Integer sqlDateTimeSub;
Integer charOctetLength;
Integer ordinalPosition;
String isNullable;
String specificName;
// extended
int jdbcSequence;
// intermediate holders
int colCount;
HsqlArrayList aliasList;
Object[] info;
Method method;
Iterator methods;
Object[] row;
DITypeInfo ti;
// Initialization
// and aliases
methods = ns.iterateAllAccessibleMethods(session, true);
ti = new DITypeInfo();
// no such thing as identity or ignorecase return/parameter
// procedure columns. Future: may need to worry about this if
// result columns are ever reported
ti.setTypeSub(Types.TYPE_SUB_DEFAULT);
// JDBC 4.0
/**
* @todo we do not yet support declarative p-column defaults.
* In essence, the default value for a procedure column is NULL
*/
colDefault = null;
procedureCatalog = database.getCatalogName().name;
procedureSchema = database.schemaManager.getDefaultSchemaHsqlName().name;
// Do it.
while (methods.hasNext()) {
info = (Object[]) methods.next();
method = (Method) info[0];
aliasList = (HsqlArrayList) info[1];
pi.setMethod(method);
specificName = pi.getSpecificName();
procedureName = pi.getFQN();
colCount = pi.getColCount();
for (int i = 0; i < colCount; i++) {
ti.setTypeCode(pi.getColTypeCode(i));
columnName = pi.getColName(i);
columnType = pi.getColUsage(i);
dataType = pi.getColJDBCDataType(i);
dataTypeName = ti.getTypeName();
precision = ti.getPrecision();
length = pi.getColLen(i);
scale = ti.getDefaultScale();
radix = ti.getNumPrecRadix();
nullability = pi.getColNullability(i);
remark = pi.getColRemark(i);
// JDBC 4.0
//colDefault = null;
sqlDataType = ti.getSqlDataType();
sqlDateTimeSub = ti.getSqlDateTimeSub();
charOctetLength = ti.getCharOctLen();
ordinalPosition = pi.getColOrdinalPosition(i);
isNullable = pi.getColIsNullable(i);
// extended
jdbcSequence = pi.getColSequence(i);
addPColRows(t, aliasList, procedureCatalog, procedureSchema, procedureName, columnName, columnType, dataType, dataTypeName, precision, length, scale, radix, nullability, remark, colDefault, sqlDataType, sqlDateTimeSub, charOctetLength, ordinalPosition, isNullable, specificName, jdbcSequence);
}
}
return t;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class DatabaseInformationMain method TABLES.
Table TABLES() {
Table t = sysTables[TABLES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TABLES]);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_TYPE", CHARACTER_DATA);
addColumn(t, "SELF_REFERENCING_COLUMN_NAME", SQL_IDENTIFIER);
addColumn(t, "REFERENCE_GENERATION", CHARACTER_DATA);
addColumn(t, "USER_DEFINED_TYPE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_NAME", SQL_IDENTIFIER);
addColumn(t, "IS_INSERTABLE_INTO", YES_OR_NO);
addColumn(t, "IS_TYPED", YES_OR_NO);
addColumn(t, "COMMIT_ACTION", CHARACTER_DATA);
//
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TABLES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// intermediate holders
Iterator tables;
Table table;
Object[] row;
final int table_catalog = 0;
final int table_schema = 1;
final int table_name = 2;
final int table_type = 3;
final int self_referencing_column_name = 4;
final int reference_generation = 5;
final int user_defined_type_catalog = 6;
final int user_defined_type_schema = 7;
final int user_defined_type_name = 8;
final int is_insertable_into = 9;
final int is_typed = 10;
final int commit_action = 11;
// Initialization
tables = allTables();
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
if (!isAccessibleTable(table)) {
continue;
}
row = t.getEmptyRowData();
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = table.getSchemaName().name;
row[table_name] = table.getName().name;
switch(table.getTableType()) {
case TableBase.SYSTEM_TABLE:
case TableBase.VIEW_TABLE:
row[table_type] = "VIEW";
row[is_insertable_into] = "NO";
break;
case TableBase.TEMP_TABLE:
case TableBase.TEMP_TEXT_TABLE:
row[table_type] = "GLOBAL TEMPORARY";
row[is_insertable_into] = "YES";
break;
default:
row[table_type] = "BASE TABLE";
row[is_insertable_into] = table.isWritable() ? "YES" : "NO";
break;
}
row[self_referencing_column_name] = null;
row[reference_generation] = null;
row[user_defined_type_catalog] = null;
row[user_defined_type_schema] = null;
row[user_defined_type_name] = null;
row[is_typed] = "NO";
row[commit_action] = table.isTemp() ? (table.onCommitPreserve() ? "PRESERVE" : "DELETE") : null;
t.insertSys(store, row);
}
return t;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class DatabaseInformationMain method SYSTEM_INDEXINFO.
/**
* Retrieves a <code>Table</code> object describing the visible
* <code>Index</code> objects for each accessible table defined
* within this database.<p>
*
* Each row is an index column description with the following
* columns: <p>
*
* <pre class="SqlCodeExample">
* TABLE_CAT VARCHAR table's catalog
* TABLE_SCHEM VARCHAR simple name of table's schema
* TABLE_NAME VARCHAR simple name of the table using the index
* NON_UNIQUE BOOLEAN can index values be non-unique?
* INDEX_QUALIFIER VARCHAR catalog in which the index is defined
* INDEX_NAME VARCHAR simple name of the index
* TYPE SMALLINT index type: { Clustered | Hashed | Other }
* ORDINAL_POSITION SMALLINT column sequence number within index
* COLUMN_NAME VARCHAR simple column name
* ASC_OR_DESC VARCHAR col. sort sequence: {"A" (Asc) | "D" (Desc)}
* CARDINALITY INTEGER # of unique values in index (not implemented)
* PAGES INTEGER index page use (not implemented)
* FILTER_CONDITION VARCHAR filter condition, if any (not implemented)
* // HSQLDB-extension
* ROW_CARDINALITY INTEGER total # of rows in index (not implemented)
* </pre> <p>
*
* @return a <code>Table</code> object describing the visible
* <code>Index</code> objects for each accessible
* table defined within this database.
*/
final Table SYSTEM_INDEXINFO() {
Table t = sysTables[SYSTEM_INDEXINFO];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_INDEXINFO]);
// JDBC
addColumn(t, "TABLE_CAT", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEM", SQL_IDENTIFIER);
// NOT NULL
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// NOT NULL
addColumn(t, "NON_UNIQUE", Type.SQL_BOOLEAN);
addColumn(t, "INDEX_QUALIFIER", SQL_IDENTIFIER);
addColumn(t, "INDEX_NAME", SQL_IDENTIFIER);
// NOT NULL
addColumn(t, "TYPE", Type.SQL_SMALLINT);
// NOT NULL
addColumn(t, "ORDINAL_POSITION", Type.SQL_SMALLINT);
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
addColumn(t, "ASC_OR_DESC", CHARACTER_DATA);
addColumn(t, "CARDINALITY", Type.SQL_INTEGER);
addColumn(t, "PAGES", Type.SQL_INTEGER);
addColumn(t, "FILTER_CONDITION", CHARACTER_DATA);
// HSQLDB extension
addColumn(t, "ROW_CARDINALITY", Type.SQL_INTEGER);
// order: NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
// added for unique: INDEX_QUALIFIER, TABLE_NAME
// false PK, as INDEX_QUALIFIER may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SYSTEM_INDEXINFO].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 6, 5, 7, 4, 2, 1 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// calculated column values
String tableCatalog;
String tableSchema;
String tableName;
Boolean nonUnique;
String indexQualifier;
String indexName;
Integer indexType;
//Integer ordinalPosition;
//String columnName;
//String ascOrDesc;
Integer cardinality;
Integer pages;
String filterCondition;
Integer rowCardinality;
// Intermediate holders
Iterator tables;
Table table;
int indexCount;
int[] cols;
int col;
int colCount;
Object[] row;
DITableInfo ti;
HsqlProperties p;
// column number mappings
final int itable_cat = 0;
final int itable_schem = 1;
final int itable_name = 2;
final int inon_unique = 3;
final int iindex_qualifier = 4;
final int iindex_name = 5;
final int itype = 6;
final int iordinal_position = 7;
final int icolumn_name = 8;
final int iasc_or_desc = 9;
final int icardinality = 10;
final int ipages = 11;
final int ifilter_condition = 12;
final int irow_cardinality = 13;
// Initialization
ti = new DITableInfo();
p = database.getProperties();
tables = p.isPropertyTrue("hsqldb.system_table_indexinfo") ? allTables() : database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
if (table.isView() || !isAccessibleTable(table)) {
continue;
}
ti.setTable(table);
tableCatalog = table.getCatalogName().name;
tableSchema = table.getSchemaName().name;
tableName = ti.getName();
// not supported yet
filterCondition = null;
// different cat for index not supported yet
indexQualifier = tableCatalog;
indexCount = table.getIndexCount();
// process all of the visible indices for this table
for (int i = 0; i < indexCount; i++) {
colCount = ti.getIndexVisibleColumns(i);
if (colCount < 1) {
continue;
}
indexName = ti.getIndexName(i);
nonUnique = ti.isIndexNonUnique(i);
cardinality = ti.getIndexCardinality(i);
pages = ValuePool.INTEGER_0;
rowCardinality = ti.getIndexRowCardinality(i);
cols = ti.getIndexColumns(i);
indexType = ti.getIndexType(i);
for (int k = 0; k < colCount; k++) {
col = cols[k];
row = t.getEmptyRowData();
row[itable_cat] = tableCatalog;
row[itable_schem] = tableSchema;
row[itable_name] = tableName;
row[inon_unique] = nonUnique;
row[iindex_qualifier] = indexQualifier;
row[iindex_name] = indexName;
row[itype] = indexType;
row[iordinal_position] = ValuePool.getInt(k + 1);
row[icolumn_name] = ti.getColName(col);
row[iasc_or_desc] = ti.getIndexColDirection(i, col);
row[icardinality] = cardinality;
row[ipages] = pages;
row[irow_cardinality] = rowCardinality;
row[ifilter_condition] = filterCondition;
t.insertSys(store, row);
}
}
}
return t;
}
Aggregations