use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_COLUMN_USAGE.
Table ROUTINE_COLUMN_USAGE() {
Table t = sysTables[ROUTINE_COLUMN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_COLUMN_USAGE]);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_COLUMN_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1, 2, 6, 7, 8, 9 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int specific_catalog = 0;
final int specific_schema = 1;
final int specific_name = 2;
final int routine_catalog = 3;
final int routine_schema = 4;
final int routine_name = 5;
final int table_catalog = 6;
final int table_schema = 7;
final int table_name = 8;
final int column_name = 9;
//
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
while (it.hasNext()) {
RoutineSchema routine = (RoutineSchema) it.next();
if (!session.getGrantee().isAccessible(routine)) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
OrderedHashSet set = specifics[m].getReferences();
for (int i = 0; i < set.size(); i++) {
HsqlName refName = (HsqlName) set.get(i);
if (refName.type != SchemaObject.COLUMN) {
continue;
}
if (!session.getGrantee().isAccessible(refName)) {
continue;
}
row = t.getEmptyRowData();
//
row[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = specifics[m].getSchemaName().name;
row[specific_name] = specifics[m].getName().name;
row[routine_catalog] = database.getCatalogName().name;
row[routine_schema] = routine.getSchemaName().name;
row[routine_name] = routine.getName().name;
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = refName.parent.schema.name;
row[table_name] = refName.parent.name;
row[column_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
return t;
}
use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.
the class RowStoreAVLMemory method insertIndexNodes.
boolean insertIndexNodes(Index primaryIndex, Index newIndex) {
int position = newIndex.getPosition();
RowIterator it = primaryIndex.firstRow(this);
int rowCount = 0;
HsqlException error = null;
try {
while (it.hasNext()) {
Row row = it.getNextRow();
((RowAVL) row).insertNode(position);
// count before inserting
rowCount++;
newIndex.insert(null, this, row);
}
return true;
} catch (java.lang.OutOfMemoryError e) {
error = Error.error(ErrorCode.OUT_OF_MEMORY);
} catch (HsqlException e) {
error = e;
}
// backtrack on error
// rowCount rows have been modified
it = primaryIndex.firstRow(this);
for (int i = 0; i < rowCount; i++) {
Row row = it.getNextRow();
NodeAVL backnode = ((RowAVL) row).getNode(0);
int j = position;
while (--j > 0) {
backnode = backnode.nNext;
}
backnode.nNext = backnode.nNext.nNext;
}
throw error;
}
use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.
the class TextCache method writeHeader.
private void writeHeader(String header) {
try {
byte[] buf = null;
String firstLine = header + NL;
try {
buf = firstLine.getBytes(stringEncoding);
} catch (UnsupportedEncodingException e) {
buf = firstLine.getBytes();
}
dataFile.write(buf, 0, buf.length);
fileFreePosition = buf.length;
} catch (IOException e) {
throw new HsqlException(e.getMessage(), "", 0);
}
}
use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.
the class PersistentStoreCollectionSession method getStore.
public PersistentStore getStore(Object key) {
try {
TableBase table = (TableBase) key;
PersistentStore store;
switch(table.persistenceScope) {
case TableBase.SCOPE_STATEMENT:
store = (PersistentStore) rowStoreMapStatement.get(table.getPersistenceId());
if (store == null) {
store = session.database.logger.newStore(session, this, table, true);
}
return store;
case TableBase.SCOPE_TRANSACTION:
store = (PersistentStore) rowStoreMapTransaction.get(table.getPersistenceId());
if (store == null) {
store = session.database.logger.newStore(session, this, table, true);
}
return store;
case TableBase.SCOPE_SESSION:
store = (PersistentStore) rowStoreMapSession.get(table.getPersistenceId());
if (store == null) {
store = session.database.logger.newStore(session, this, table, true);
}
return store;
}
} catch (HsqlException e) {
}
throw Error.runtimeError(ErrorCode.U_S0500, "PSCS");
}
use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.
the class TestVoltCompiler method checkDDLAgainstGivenSchema.
private Database checkDDLAgainstGivenSchema(String errorRegex, String givenSchema, String... ddl) throws Exception {
String schemaDDL = givenSchema + StringUtils.join(ddl, " ");
VoltCompiler compiler = new VoltCompiler(false);
boolean success;
String error;
try {
success = compileDDL(schemaDDL, compiler);
error = (success || compiler.m_errors.size() == 0 ? "" : compiler.m_errors.get(compiler.m_errors.size() - 1).message);
} catch (HsqlException hex) {
success = false;
error = hex.getMessage();
} catch (PlanningErrorException plex) {
success = false;
error = plex.getMessage();
}
if (errorRegex == null) {
assertTrue(String.format("Expected success\nDDL: %s\n%s", StringUtils.join(ddl, " "), error), success);
Catalog cat = compiler.getCatalog();
return cat.getClusters().get("cluster").getDatabases().get("database");
} else {
assertFalse(String.format("Expected error (\"%s\")\nDDL: %s", errorRegex, StringUtils.join(ddl, " ")), success);
assertFalse("Expected at least one error message.", error.isEmpty());
Matcher m = Pattern.compile(errorRegex).matcher(error);
assertTrue(String.format("%s\nEXPECTED: %s", error, errorRegex), m.matches());
return null;
}
}
Aggregations