use of org.hsqldb_voltpatches.Session in project voltdb by VoltDB.
the class DatabaseInformationFull method ROLE_USAGE_GRANTS.
Table ROLE_USAGE_GRANTS() {
Table t = sysTables[ROLE_USAGE_GRANTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROLE_USAGE_GRANTS]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_TYPE", CHARACTER_DATA);
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_USAGE_GRANTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 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 GRANTOR, GRANTEE, OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_NAME, " + "OBJECT_TYPE, PRIVILEGE_TYPE, IS_GRANTABLE " + "FROM INFORMATION_SCHEMA.USAGE_PRIVILEGES " + "JOIN INFORMATION_SCHEMA.APPLICABLE_ROLES ON GRANTEE = ROLE_NAME;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.Session in project voltdb by VoltDB.
the class DatabaseInformationFull method COLUMN_DOMAIN_USAGE.
/**
* Domains are shown if the authorization is the user or a role given to the
* user.
*
* <p>
*
* @return Table
*/
Table COLUMN_DOMAIN_USAGE() {
Table t = sysTables[COLUMN_DOMAIN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[COLUMN_DOMAIN_USAGE]);
addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_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_DOMAIN_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 DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, TABLE_CATALOG, " + "TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE DOMAIN_NAME IS NOT NULL;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.Session in project voltdb by VoltDB.
the class DatabaseInformationFull method SYSTEM_SESSIONS.
/**
* Retrieves a <code>Table</code> object describing all visible
* sessions. ADMIN users see *all* sessions
* while non-admin users see only their own session.<p>
*
* Each row is a session state description with the following columns: <p>
*
* <pre class="SqlCodeExample">
* SESSION_ID INTEGER session identifier
* CONNECTED TIMESTAMP time at which session was created
* USER_NAME VARCHAR db user name of current session user
* IS_ADMIN BOOLEAN is session user an admin user?
* AUTOCOMMIT BOOLEAN is session in autocommit mode?
* READONLY BOOLEAN is session in read-only mode?
* MAXROWS INTEGER session's MAXROWS setting
* LAST_IDENTITY INTEGER last identity value used by this session
* TRANSACTION_SIZE INTEGER # of undo items in current transaction
* SCHEMA VARCHAR current schema for session
* </pre> <p>
*
* @return a <code>Table</code> object describing all visible
* sessions
*/
Table SYSTEM_SESSIONS() {
Table t = sysTables[SYSTEM_SESSIONS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_SESSIONS]);
addColumn(t, "SESSION_ID", CARDINAL_NUMBER);
addColumn(t, "CONNECTED", TIME_STAMP);
addColumn(t, "USER_NAME", SQL_IDENTIFIER);
addColumn(t, "IS_ADMIN", Type.SQL_BOOLEAN);
addColumn(t, "AUTOCOMMIT", Type.SQL_BOOLEAN);
addColumn(t, "READONLY", Type.SQL_BOOLEAN);
addColumn(t, "MAXROWS", CARDINAL_NUMBER);
// Note: some sessions may have a NULL LAST_IDENTITY value
addColumn(t, "LAST_IDENTITY", CARDINAL_NUMBER);
addColumn(t, "TRANSACTION_SIZE", CARDINAL_NUMBER);
addColumn(t, "SCHEMA", SQL_IDENTIFIER);
// order: SESSION_ID
// true primary key
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SYSTEM_SESSIONS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0 }, true);
return t;
}
// column number mappings
final int isid = 0;
final int ict = 1;
final int iuname = 2;
final int iis_admin = 3;
final int iautocmt = 4;
final int ireadonly = 5;
final int imaxrows = 6;
final int ilast_id = 7;
final int it_size = 8;
final int it_schema = 9;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
// intermediate holders
Session[] sessions;
Session s;
Object[] row;
// Initialisation
sessions = ns.listVisibleSessions(session);
// Do it.
for (int i = 0; i < sessions.length; i++) {
s = sessions[i];
row = t.getEmptyRowData();
row[isid] = ValuePool.getLong(s.getId());
row[ict] = new TimestampData(s.getConnectTime() / 1000);
row[iuname] = s.getUsername();
row[iis_admin] = ValuePool.getBoolean(s.isAdmin());
row[iautocmt] = ValuePool.getBoolean(s.isAutoCommit());
row[ireadonly] = ValuePool.getBoolean(s.isReadOnlyDefault());
row[imaxrows] = ValuePool.getInt(s.getSQLMaxRows());
row[ilast_id] = ValuePool.getLong(((Number) s.getLastIdentity()).longValue());
row[it_size] = ValuePool.getInt(s.getTransactionSize());
row[it_schema] = s.getCurrentSchemaHsqlName().name;
t.insertSys(store, row);
}
return t;
}
use of org.hsqldb_voltpatches.Session in project voltdb by VoltDB.
the class DataFileDefrag method writeTableToDataFile.
int[] writeTableToDataFile(Table table) throws IOException {
Session session = database.getSessionManager().getSysSession();
PersistentStore store = session.sessionData.getRowStore(table);
RowOutputInterface rowOut = new RowOutputBinary();
DoubleIntIndex pointerLookup = new DoubleIntIndex(table.getPrimaryIndex().sizeEstimate(store), false);
int[] rootsArray = table.getIndexRootsArray();
long pos = fileOffset;
int count = 0;
pointerLookup.setKeysSearchTarget();
Error.printSystemOut("lookup begins: " + stopw.elapsedTime());
RowIterator it = table.rowIterator(session);
for (; it.hasNext(); count++) {
CachedObject row = it.getNextRow();
pointerLookup.addUnsorted(row.getPos(), (int) (pos / scale));
if (count % 50000 == 0) {
Error.printSystemOut("pointer pair for row " + count + " " + row.getPos() + " " + pos);
}
pos += row.getStorageSize();
}
Error.printSystemOut(table.getName().name + " list done ", stopw.elapsedTime());
count = 0;
it = table.rowIterator(session);
for (; it.hasNext(); count++) {
CachedObject row = it.getNextRow();
rowOut.reset();
row.write(rowOut, pointerLookup);
fileStreamOut.write(rowOut.getOutputStream().getBuffer(), 0, rowOut.size());
fileOffset += row.getStorageSize();
if ((count) % 50000 == 0) {
Error.printSystemOut(count + " rows " + stopw.elapsedTime());
}
}
for (int i = 0; i < rootsArray.length; i++) {
if (rootsArray[i] == -1) {
continue;
}
int lookupIndex = pointerLookup.findFirstEqualKeyIndex(rootsArray[i]);
if (lookupIndex == -1) {
throw Error.error(ErrorCode.DATA_FILE_ERROR);
}
rootsArray[i] = pointerLookup.getValue(lookupIndex);
}
setTransactionRowLookups(pointerLookup);
Error.printSystemOut(table.getName().name + " : table converted");
return rootsArray;
}
use of org.hsqldb_voltpatches.Session in project voltdb by VoltDB.
the class LobManager method createSchema.
public void createSchema() {
sysLobSession = database.sessionManager.getSysLobSession();
Session session = sysLobSession;
InputStream fis = getClass().getResourceAsStream(resourceFileName);
InputStreamReader reader = null;
try {
reader = new InputStreamReader(fis, "ISO-8859-1");
} catch (Exception e) {
}
LineNumberReader lineReader = new LineNumberReader(reader);
LineGroupReader lg = new LineGroupReader(lineReader, starters);
HashMappedList map = lg.getAsMap();
lg.close();
String sql = (String) map.get("/*lob_schema_definition*/");
Statement statement = session.compileStatement(sql);
Result result = statement.execute(session);
Table table = database.schemaManager.getTable(session, "BLOCKS", "SYSTEM_LOBS");
// table.isTransactional = false;
getLob = session.compileStatement(getLobSQL);
getLobPart = session.compileStatement(getLobPartSQL);
createLob = session.compileStatement(createLobSQL);
createLobPart = session.compileStatement(createLobPartSQL);
divideLobPart = session.compileStatement(divideLobPartSQL);
deleteLob = session.compileStatement(deleteLobSQL);
deleteLobPart = session.compileStatement(deleteLobPartSQL);
setLobLength = session.compileStatement(updateLobLengthSQL);
setLobUsage = session.compileStatement(updateLobUsageSQL);
getNextLobId = session.compileStatement(getNextLobIdSQL);
}
Aggregations