use of com.wplatform.ddal.dbobject.table.Table in project jdbc-shards by wplatform.
the class Aggregate method getColumnIndex.
private Index getColumnIndex() {
if (on instanceof ExpressionColumn) {
ExpressionColumn col = (ExpressionColumn) on;
Column column = col.getColumn();
TableFilter filter = col.getTableFilter();
if (filter != null) {
Table table = filter.getTable();
Index index = table.getIndexForColumn(column);
return index;
}
}
return null;
}
use of com.wplatform.ddal.dbobject.table.Table in project jdbc-shards by wplatform.
the class SelectExecutor method scanLevelValidation.
private void scanLevelValidation(TableFilter filter) {
Table test = filter.getTable();
if (!(test instanceof Table)) {
return;
}
TableMate table = castTableMate(test);
table.check();
Index index = filter.getIndex();
int scanLevel = table.getScanLevel();
switch(scanLevel) {
case TableConfig.SCANLEVEL_UNLIMITED:
break;
case TableConfig.SCANLEVEL_FILTER:
if (filter.getFilterCondition() == null) {
throw DbException.get(ErrorCode.NOT_ALLOWED_TO_SCAN_TABLE, table.getSQL(), "filter", "filter");
}
break;
case TableConfig.SCANLEVEL_ANYINDEX:
if (index.getIndexType().isScan()) {
throw DbException.get(ErrorCode.NOT_ALLOWED_TO_SCAN_TABLE, table.getSQL(), "anyIndex", "index");
}
break;
case TableConfig.SCANLEVEL_UNIQUEINDEX:
if (!index.getIndexType().isUnique()) {
throw DbException.get(ErrorCode.NOT_ALLOWED_TO_SCAN_TABLE, table.getSQL(), "uniqueIndex", "unique index");
}
break;
case TableConfig.SCANLEVEL_SHARDINGKEY:
if (!index.getIndexType().isShardingKey()) {
throw DbException.get(ErrorCode.NOT_ALLOWED_TO_SCAN_TABLE, table.getSQL(), "shardingKey", "sharding key");
}
break;
default:
throw DbException.throwInternalError("error table scan level " + scanLevel);
}
}
use of com.wplatform.ddal.dbobject.table.Table in project jdbc-shards by wplatform.
the class Database method getDependentTable.
/**
* Get the first table that depends on this object.
*
* @param obj the object to find
* @param except the table to exclude (or null)
* @return the first dependent table, or null
*/
public Table getDependentTable(SchemaObject obj, Table except) {
switch(obj.getType()) {
case DbObject.COMMENT:
case DbObject.CONSTRAINT:
case DbObject.INDEX:
case DbObject.RIGHT:
case DbObject.TRIGGER:
case DbObject.USER:
return null;
default:
}
HashSet<DbObject> set = New.hashSet();
for (Table t : getAllTablesAndViews()) {
if (except == t) {
continue;
} else if (Table.VIEW.equals(t.getTableType())) {
continue;
}
set.clear();
t.addDependencies(set);
if (set.contains(obj)) {
return t;
}
}
return null;
}
use of com.wplatform.ddal.dbobject.table.Table in project jdbc-shards by wplatform.
the class Session method cleanTempTables.
private void cleanTempTables(boolean closeSession) {
if (localTempTables != null && localTempTables.size() > 0) {
synchronized (database) {
for (Table table : New.arrayList(localTempTables.values())) {
modificationId++;
localTempTables.remove(table.getName());
table.removeChildrenAndResources(this);
if (closeSession) {
// need to commit, otherwise recovery might
// ignore the table removal
database.commit(this);
}
}
}
}
}
use of com.wplatform.ddal.dbobject.table.Table in project jdbc-shards by wplatform.
the class CommonPreparedExecutor method findTableMate.
/**
* @param tableName
*/
public TableMate findTableMate(String tableName) {
Table table = database.getSchema(session.getCurrentSchemaName()).findTableOrView(session, tableName);
if (table == null) {
String[] schemaNames = session.getSchemaSearchPath();
if (schemaNames != null) {
for (String name : schemaNames) {
Schema s = database.getSchema(name);
table = s.findTableOrView(session, tableName);
if (table != null) {
break;
}
}
}
}
if (table != null && table instanceof TableMate) {
return (TableMate) table;
}
return null;
}
Aggregations