in HSQL/src/org/hsqldb1/DatabaseInformationFull.java [1301:1461]
Table SYSTEM_TRIGGERS() throws HsqlException {
Table t = sysTables[SYSTEM_TRIGGERS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_TRIGGERS]);
addColumn(t, "TRIGGER_CAT", Types.VARCHAR);
addColumn(t, "TRIGGER_SCHEM", Types.VARCHAR);
addColumn(t, "TRIGGER_NAME", Types.VARCHAR, false);
addColumn(t, "TRIGGER_TYPE", Types.VARCHAR, 15, false);
addColumn(t, "TRIGGERING_EVENT", Types.VARCHAR, 10, false);
addColumn(t, "TABLE_CAT", Types.VARCHAR);
addColumn(t, "TABLE_SCHEM", Types.VARCHAR);
addColumn(t, "BASE_OBJECT_TYPE", Types.VARCHAR, 8, false);
addColumn(t, "TABLE_NAME", Types.VARCHAR, false);
addColumn(t, "COLUMN_NAME", Types.VARCHAR);
addColumn(t, "REFERENCING_NAMES", Types.VARCHAR, false);
addColumn(t, "WHEN_CLAUSE", Types.VARCHAR);
addColumn(t, "STATUS", Types.VARCHAR, 8, false);
addColumn(t, "DESCRIPTION", Types.VARCHAR, false);
addColumn(t, "ACTION_TYPE", Types.VARCHAR, false);
addColumn(t, "TRIGGER_BODY", Types.VARCHAR, false);
// order: TRIGGER_TYPE, TRIGGER_SCHEM, TRIGGER_NAME
// added for unique: TRIGGER_CAT
// false PK, as TRIGGER_SCHEM and/or TRIGGER_CAT may be null
t.createPrimaryKey(null, new int[] {
3, 1, 2, 0
}, false);
return t;
}
// calculated column values
String triggerCatalog;
String triggerSchema;
String triggerName;
String triggerType;
String triggeringEvent;
String tableCatalog;
String tableSchema;
String baseObjectType;
String tableName;
String columnName;
String referencingNames;
String whenClause;
String status;
String description;
String actionType;
String triggerBody;
// Intermediate holders
Iterator tables;
Table table;
HsqlArrayList[] vTrigs;
HsqlArrayList triggerList;
TriggerDef def;
Object[] row;
// column number mappings
final int itrigger_cat = 0;
final int itrigger_schem = 1;
final int itrigger_name = 2;
final int itrigger_type = 3;
final int itriggering_event = 4;
final int itable_cat = 5;
final int itable_schem = 6;
final int ibase_object_type = 7;
final int itable_name = 8;
final int icolumn_name = 9;
final int ireferencing_names = 10;
final int iwhen_clause = 11;
final int istatus = 12;
final int idescription = 13;
final int iaction_type = 14;
final int itrigger_body = 15;
// Initialization
tables = database.schemaManager.allTablesIterator();
// these are the only values supported, currently
actionType = "CALL";
baseObjectType = "TABLE";
columnName = null;
referencingNames = "ROW";
whenClause = null;
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
vTrigs = table.triggerLists;
// faster test first
if (vTrigs == null) {
continue;
}
if (!isAccessibleTable(table)) {
continue;
}
tableCatalog = ns.getCatalogName(table);
triggerCatalog = tableCatalog;
tableSchema = table.getSchemaName();
triggerSchema = tableSchema;
tableName = table.getName().name;
for (int i = 0; i < vTrigs.length; i++) {
triggerList = vTrigs[i];
if (triggerList == null) {
continue;
}
for (int j = 0; j < triggerList.size(); j++) {
def = (TriggerDef) triggerList.get(j);
if (def == null) {
continue;
}
triggerName = def.name.name;
description = def.getDDL().toString();
status = def.valid ? "ENABLED"
: "DISABLED";
triggerBody = def.triggerClassName;
triggerType = def.when;
if (def.forEachRow) {
triggerType += " EACH ROW";
}
triggeringEvent = def.operation;
row = t.getEmptyRowData();
row[itrigger_cat] = triggerCatalog;
row[itrigger_schem] = triggerSchema;
row[itrigger_name] = triggerName;
row[itrigger_type] = triggerType;
row[itriggering_event] = triggeringEvent;
row[itable_cat] = tableCatalog;
row[itable_schem] = tableSchema;
row[ibase_object_type] = baseObjectType;
row[itable_name] = tableName;
row[icolumn_name] = columnName;
row[ireferencing_names] = referencingNames;
row[iwhen_clause] = whenClause;
row[istatus] = status;
row[idescription] = description;
row[iaction_type] = actionType;
row[itrigger_body] = triggerBody;
t.insertSys(row);
}
}
}
t.setDataReadOnly(true);
return t;
}