use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompilerAlterDropTable method verifyTableColumnSize.
//Check given col size
private void verifyTableColumnSize(VoltCompiler compiler, String tableName, String colName, int sz) {
Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
Table table = db.getTables().get(tableName);
Column col = table.getColumns().get(colName);
assertNotNull(col);
assertEquals(sz, col.getSize());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompilerAlterDropTable method verifyIndexGone.
//Check given index exists
private void verifyIndexGone(VoltCompiler compiler, String tableName, String idxName) {
Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
Table table = db.getTables().get(tableName);
if (table == null) {
//Index must be gone.
return;
}
Index idx = table.getIndexes().get(idxName);
assertNull(idx);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class CatalogUtil method setSecurityEnabled.
/**
* Set the security setting in the catalog from the deployment file
* @param catalog the catalog to be updated
* @param security security element of the deployment xml
*/
private static void setSecurityEnabled(Catalog catalog, SecurityType security) {
Cluster cluster = catalog.getClusters().get("cluster");
Database database = cluster.getDatabases().get("database");
cluster.setSecurityenabled(security.isEnabled());
database.setSecurityprovider(security.getProvider().value());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class SnapshotSiteProcessor method populateSequenceNumbersForExecutionSite.
/*
* Synchronization is handled by SnapshotSaveAPI.startSnapshotting
* Store the export sequence numbers for every table and partition. This will
* be called by every execution site before the snapshot starts. Then the execution
* site that gets the setup permit will use getExportSequenceNumbers to retrieve the full
* set and reset the contents.
*/
public static void populateSequenceNumbersForExecutionSite(SystemProcedureExecutionContext context) {
Database database = context.getDatabase();
for (Table t : database.getTables()) {
if (!CatalogUtil.isTableExportOnly(database, t))
continue;
Map<Integer, Pair<Long, Long>> sequenceNumbers = m_exportSequenceNumbers.get(t.getTypeName());
if (sequenceNumbers == null) {
sequenceNumbers = new HashMap<Integer, Pair<Long, Long>>();
m_exportSequenceNumbers.put(t.getTypeName(), sequenceNumbers);
}
long[] ackOffSetAndSequenceNumber = context.getSiteProcedureConnection().getUSOForExportTable(t.getSignature());
sequenceNumbers.put(context.getPartitionId(), Pair.of(ackOffSetAndSequenceNumber[0], ackOffSetAndSequenceNumber[1]));
}
TupleStreamStateInfo drStateInfo = context.getSiteProcedureConnection().getDRTupleStreamStateInfo();
m_drTupleStreamInfo.put(context.getPartitionId(), drStateInfo);
if (drStateInfo.containsReplicatedStreamInfo) {
m_drTupleStreamInfo.put(MpInitiator.MP_INIT_PID, drStateInfo);
}
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class AdHocNTBase method processExplainDefaultProc.
/**
* Explain Proc for a default proc is routed through the regular Explain
* path using ad hoc planning and all. Take the result from that async
* process and format it like other explains for procedures.
*/
static CompletableFuture<ClientResponse> processExplainDefaultProc(AdHocPlannedStmtBatch planBatch) {
Database db = VoltDB.instance().getCatalogContext().database;
// from a default procedure
assert (planBatch.getPlannedStatementCount() == 1);
AdHocPlannedStatement ahps = planBatch.getPlannedStatement(0);
String sql = new String(ahps.sql, StandardCharsets.UTF_8);
String explain = planBatch.explainStatement(0, db);
VoltTable vt = new VoltTable(new VoltTable.ColumnInfo("SQL_STATEMENT", VoltType.STRING), new VoltTable.ColumnInfo("EXECUTION_PLAN", VoltType.STRING));
vt.addRow(sql, explain);
ClientResponseImpl response = new ClientResponseImpl(ClientResponseImpl.SUCCESS, ClientResponse.UNINITIALIZED_APP_STATUS_CODE, null, new VoltTable[] { vt }, null);
CompletableFuture<ClientResponse> fut = new CompletableFuture<>();
fut.complete(response);
return fut;
}
Aggregations