use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method TABLE_CONSTRAINTS.
/**
* The TABLE_CONSTRAINTS table has one row for each table constraint
* associated with a table. <p>
*
* It effectively contains a representation of the table constraint
* descriptors. <p>
*
* <b>Definition:</b> <p>
*
* <pre class="SqlCodeExample">
* CREATE TABLE SYSTEM_TABLE_CONSTRAINTS (
* CONSTRAINT_CATALOG VARCHAR NULL,
* CONSTRAINT_SCHEMA VARCHAR NULL,
* CONSTRAINT_NAME VARCHAR NOT NULL,
* CONSTRAINT_TYPE VARCHAR NOT NULL,
* TABLE_CATALOG VARCHAR NULL,
* TABLE_SCHEMA VARCHAR NULL,
* TABLE_NAME VARCHAR NOT NULL,
* IS_DEFERRABLE VARCHAR NOT NULL,
* INITIALLY_DEFERRED VARCHAR NOT NULL,
*
* CHECK ( CONSTRAINT_TYPE IN
* ( 'UNIQUE', 'PRIMARY KEY',
* 'FOREIGN KEY', 'CHECK' ) ),
*
* CHECK ( ( IS_DEFERRABLE, INITIALLY_DEFERRED ) IN
* ( VALUES ( 'NO', 'NO' ),
* ( 'YES', 'NO' ),
* ( 'YES', 'YES' ) ) )
* )
* </pre>
*
* <b>Description:</b> <p>
*
* <ol>
* <li> The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and
* CONSTRAINT_NAME are the catalog name, unqualified schema
* name, and qualified identifier, respectively, of the
* constraint being described. If the <table constraint
* definition> or <add table constraint definition>
* that defined the constraint did not specify a
* <constraint name>, then the values of CONSTRAINT_CATALOG,
* CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are
* implementation-defined. <p>
*
* <li> The values of CONSTRAINT_TYPE have the following meanings: <p>
* <table border cellpadding="3">
* <tr>
* <td nowrap>FOREIGN KEY</td>
* <td nowrap>The constraint being described is a
* foreign key constraint.</td>
* </tr>
* <tr>
* <td nowrap>UNIQUE</td>
* <td nowrap>The constraint being described is a
* unique constraint.</td>
* </tr>
* <tr>
* <td nowrap>PRIMARY KEY</td>
* <td nowrap>The constraint being described is a
* primary key constraint.</td>
* </tr>
* <tr>
* <td nowrap>CHECK</td>
* <td nowrap>The constraint being described is a
* check constraint.</td>
* </tr>
* </table> <p>
*
* <li> The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are
* the catalog name, the unqualified schema name, and the
* qualified identifier of the name of the table to which the
* table constraint being described applies. <p>
*
* <li> The values of IS_DEFERRABLE have the following meanings: <p>
*
* <table>
* <tr>
* <td nowrap>YES</td>
* <td nowrap>The table constraint is deferrable.</td>
* </tr>
* <tr>
* <td nowrap>NO</td>
* <td nowrap>The table constraint is not deferrable.</td>
* </tr>
* </table> <p>
*
* <li> The values of INITIALLY_DEFERRED have the following meanings: <p>
*
* <table>
* <tr>
* <td nowrap>YES</td>
* <td nowrap>The table constraint is initially deferred.</td>
* </tr>
* <tr>
* <td nowrap>NO</td>
* <td nowrap>The table constraint is initially immediate.</td>
* </tr>
* </table> <p>
* </ol>
*
* @return Table
*/
Table TABLE_CONSTRAINTS() {
Table t = sysTables[TABLE_CONSTRAINTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TABLE_CONSTRAINTS]);
addColumn(t, "CONSTRAINT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CONSTRAINT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "CONSTRAINT_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "CONSTRAINT_TYPE", CHARACTER_DATA);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "IS_DEFERRABLE", YES_OR_NO);
// not null
addColumn(t, "INITIALLY_DEFERRED", YES_OR_NO);
// false PK, as CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA,
// TABLE_CATALOG and/or TABLE_SCHEMA may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TABLE_CONSTRAINTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// Intermediate holders
Iterator tables;
Table table;
Constraint[] constraints;
int constraintCount;
Constraint constraint;
String cat;
String schem;
Object[] row;
// column number mappings
final int constraint_catalog = 0;
final int constraint_schema = 1;
final int constraint_name = 2;
final int constraint_type = 3;
final int table_catalog = 4;
final int table_schema = 5;
final int table_name = 6;
final int is_deferable = 7;
final int initially_deferred = 8;
// initialization
tables = database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
// else compiler complains
table = null;
// do it
while (tables.hasNext()) {
table = (Table) tables.next();
/** @todo - requires table level INSERT or UPDATE or DELETE or REFERENCES (not SELECT) right */
if (table.isView() || !isAccessibleTable(table)) {
continue;
}
constraints = table.getConstraints();
constraintCount = constraints.length;
for (int i = 0; i < constraintCount; i++) {
constraint = constraints[i];
row = t.getEmptyRowData();
switch(constraint.getConstraintType()) {
case Constraint.CHECK:
{
row[constraint_type] = "CHECK";
break;
}
case Constraint.UNIQUE:
{
row[constraint_type] = "UNIQUE";
break;
}
case Constraint.FOREIGN_KEY:
{
row[constraint_type] = "FOREIGN KEY";
table = constraint.getRef();
break;
}
case Constraint.PRIMARY_KEY:
{
row[constraint_type] = "PRIMARY KEY";
break;
}
case Constraint.MAIN:
default:
{
continue;
}
}
cat = database.getCatalogName().name;
schem = table.getSchemaName().name;
row[constraint_catalog] = cat;
row[constraint_schema] = schem;
row[constraint_name] = constraint.getName().name;
row[table_catalog] = cat;
row[table_schema] = schem;
row[table_name] = table.getName().name;
row[is_deferable] = Tokens.T_NO;
row[initially_deferred] = Tokens.T_NO;
t.insertSys(store, row);
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method AUTHORIZATIONS.
/**
* SYSTEM_AUTHORIZATIONS<p>
*
* <b>Function</b><p>
*
* The AUTHORIZATIONS table has one row for each <role name> and
* one row for each <authorization identifier > referenced in the
* Information Schema. These are the <role name>s and
* <authorization identifier>s that may grant privileges as well as
* those that may create a schema, or currently own a schema created
* through a <schema definition>. <p>
*
* <b>Definition</b><p>
*
* <pre class="SqlCodeExample">
* CREATE TABLE AUTHORIZATIONS (
* AUTHORIZATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER,
* AUTHORIZATION_TYPE INFORMATION_SCHEMA.CHARACTER_DATA
* CONSTRAINT AUTHORIZATIONS_AUTHORIZATION_TYPE_NOT_NULL
* NOT NULL
* CONSTRAINT AUTHORIZATIONS_AUTHORIZATION_TYPE_CHECK
* CHECK ( AUTHORIZATION_TYPE IN ( 'USER', 'ROLE' ) ),
* CONSTRAINT AUTHORIZATIONS_PRIMARY_KEY
* PRIMARY KEY (AUTHORIZATION_NAME)
* )
* </pre>
*
* <b>Description</b><p>
*
* <ol>
* <li> The values of AUTHORIZATION_TYPE have the following meanings:<p>
*
* <table border cellpadding="3">
* <tr>
* <td nowrap>USER</td>
* <td nowrap>The value of AUTHORIZATION_NAME is a known
* <user identifier>.</td>
* <tr>
* <tr>
* <td nowrap>NO</td>
* <td nowrap>The value of AUTHORIZATION_NAME is a <role
* name> defined by a <role definition>.</td>
* <tr>
* </table> <p>
* </ol>
*
* @return Table
*/
Table AUTHORIZATIONS() {
Table t = sysTables[AUTHORIZATIONS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[AUTHORIZATIONS]);
// not null
addColumn(t, "AUTHORIZATION_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "AUTHORIZATION_TYPE", SQL_IDENTIFIER);
// true PK
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[AUTHORIZATIONS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0 }, true);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// Intermediate holders
Iterator grantees;
Grantee grantee;
Object[] row;
// initialization
grantees = session.getGrantee().visibleGrantees().iterator();
// Do it.
while (grantees.hasNext()) {
grantee = (Grantee) grantees.next();
row = t.getEmptyRowData();
row[0] = grantee.getNameString();
row[1] = grantee.isRole() ? "ROLE" : "USER";
t.insertSys(store, row);
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method TRIGGER_SEQUENCE_USAGE.
Table TRIGGER_SEQUENCE_USAGE() {
Table t = sysTables[TRIGGER_SEQUENCE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TRIGGER_SEQUENCE_USAGE]);
addColumn(t, "TRIGGER_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRIGGER_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TRIGGER_NAME", SQL_IDENTIFIER);
addColumn(t, "SEQUENCE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SEQUENCE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "SEQUENCE_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRIGGER_SEQUENCE_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int trigger_catalog = 0;
final int trigger_schema = 1;
final int trigger_name = 2;
final int sequence_catalog = 3;
final int sequence_schema = 4;
final int sequence_name = 5;
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.TRIGGER);
while (it.hasNext()) {
TriggerDef trigger = (TriggerDef) it.next();
if (!session.getGrantee().isAccessible(trigger)) {
continue;
}
OrderedHashSet set = trigger.getReferences();
for (int i = 0; i < set.size(); i++) {
HsqlName refName = (HsqlName) set.get(i);
if (refName.type != SchemaObject.SEQUENCE) {
continue;
}
if (!session.getGrantee().isAccessible(refName)) {
continue;
}
row = t.getEmptyRowData();
row[trigger_catalog] = database.getCatalogName().name;
row[trigger_schema] = trigger.getSchemaName().name;
row[trigger_name] = trigger.getName().name;
row[sequence_catalog] = database.getCatalogName().name;
row[sequence_schema] = refName.schema.name;
row[sequence_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
// Initialization
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method SQL_FEATURES.
Table SQL_FEATURES() {
Table t = sysTables[SQL_FEATURES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SQL_FEATURES]);
addColumn(t, "FEATURE_ID", CHARACTER_DATA);
addColumn(t, "FEATURE_NAME", CHARACTER_DATA);
addColumn(t, "SUB_FEATURE_ID", CHARACTER_DATA);
addColumn(t, "SUB_FEATURE_NAME", CHARACTER_DATA);
addColumn(t, "IS_SUPPORTED", YES_OR_NO);
addColumn(t, "IS_VERIFIED_BY", CHARACTER_DATA);
addColumn(t, "COMMENTS", CHARACTER_DATA);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SQL_FEATURES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 2 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
String sql = (String) statementMap.get("/*sql_features*/");
Result rs = sys.executeDirectStatement(sql);
t.insertSys(store, rs);
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method ROLE_UDT_GRANTS.
Table ROLE_UDT_GRANTS() {
Table t = sysTables[ROLE_UDT_GRANTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROLE_UDT_GRANTS]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "UDT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "UDT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "UDT_NAME", SQL_IDENTIFIER);
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_TABLE_GRANTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, null, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int grantor = 0;
final int grantee = 1;
final int udt_catalog = 2;
final int udt_schema = 3;
final int udt_name = 4;
final int privilege_type = 5;
final int is_grantable = 6;
return t;
}
Aggregations