/** * Add a sequence to this table. * * @param sequence the sequence to add */ public void addSequence(Sequence sequence) { sequences = add(sequences, sequence); }
@Override public void addDependencies(HashSet<DbObject> dependencies) { super.addDependencies(dependencies); if (tables != null) { for (Table t : tables) { if (!Table.VIEW.equals(t.getTableType())) { t.addDependencies(dependencies); } } } }
public Index getPrimaryKey() { Index index = findPrimaryKey(); if (index != null) { return index; } throw DbException.get(ErrorCode.INDEX_NOT_FOUND_1, Constants.PREFIX_PRIMARY_KEY); }
private Column parseColumn(Table table) { String id = readColumnIdentifier(); if (database.getSettings().rowId && Column.ROWID.equals(id)) { return table.getRowIdColumn(); } return table.getColumn(id); }
case TABLES: { for (Table table : getAllTables(session)) { String tableName = identifier(table.getName()); if (!checkIndex(session, tableName, indexFrom, indexTo)) { continue; String storageType = table.getTableType(); if(table instanceof TableMate) { int type2 = ((TableMate) table).getTableRule().getType(); identifier(table.getSchema().getName()), table.getTableType(), "" + table.getId(), "" + table.getRowCountApproximation() ); String tableName = identifier(table.getName()); if (!checkIndex(session, tableName, indexFrom, indexTo)) { continue; Column[] cols = table.getColumns(); String collation = database.getCompareMode().getName(); for (int j = 0; j < cols.length; j++) { identifier(table.getSchema().getName()),
private Prepared parseAlterTable() { Table table = readTableOrView(); if (readIf("ADD")) { Prepared command = parseAlterTableAddConstraintIf(table.getName(), table.getSchema()); if (command != null) { return command; boolean value = readBooleanSetting(); AlterTableSet command = new AlterTableSet(session, table.getSchema(), type, value); command.setTableName(table.getName()); if (readIf("CHECK")) { command.setCheckExisting(true); } else if (readIf("RENAME")) { read("TO"); String newName = readIdentifierWithSchema(table.getSchema() .getName()); checkSchema(table.getSchema()); AlterTableRename command = new AlterTableRename(session, getSchema()); boolean ifExists = readIfExists(false); String constraintName = readIdentifierWithSchema(table .getSchema().getName()); ifExists = readIfExists(ifExists); checkSchema(table.getSchema()); AlterTableDropConstraint command = new AlterTableDropConstraint( session, getSchema(), ifExists);
columns = table.getColumns(); Index idx = table.getPrimaryKey(); if (idx == null) { throw DbException.get(ErrorCode.CONSTRAINT_NOT_FOUND_1, "PRIMARY KEY"); buff.append(table.getSQL()).append(" SET "); for (Column c : columns) { buff.appendExceptFirst(", ");
@Override public Row get() { Row searchRow = cursor.get(); if (searchColumns == table.getColumns()) { return searchRow; } current = table.getTemplateRow(); for (int i = 0; i < searchColumns.length; i++) { int idx = searchColumns[i].getColumnId(); current.setValue(idx, searchRow.getValue(i)); } return current; }
/** * Remove the given index from the list. * * @param index the index to remove */ public void removeIndex(Index index) { ArrayList<Index> indexes = getIndexes(); if (indexes != null) { remove(indexes, index); if (index.getIndexType().isPrimaryKey()) { for (Column col : index.getColumns()) { col.setPrimaryKey(false); } } } }
if (!f.getTable().isDeterministic()) { return false; Table table = f.getTable(); visitor.addDependency(table); table.addDependencies(visitor.getDependencies());
int len = table.getColumns().length; int[] masks = new int[len]; for (IndexCondition condition : indexConditions) { PlanItem item = table.getBestPlanItem(s, masks, this); if (nestedJoin != null) { setEvaluatable(nestedJoin);
joined = true; TableFilter join = readTableFilter(fromOuter); Column[] tableCols = last.getTable().getColumns(); Column[] joinCols = join.getTable().getColumns(); String tableSchema = last.getTable().getSchema().getName(); String joinSchema = join.getTable().getSchema().getName(); Expression on = null; for (Column tc : tableCols) {
@Override public Column[] getColumns() { return table.getColumns(); }
/** * Get the index that has the given column as the first element. This method * returns null if no matching index is found. * * @param column the column * @return the index or null */ public Index getIndexForColumn(Column column) { ArrayList<Index> indexes = getIndexes(); if (indexes != null) { for (int i = 1, size = indexes.size(); i < size; i++) { Index index = indexes.get(i); int idx = index.getColumnIndex(column); if (idx == 0) { return index; } } } return null; }
/** * Map the columns using the column names and the specified table. * * @param indexColumns the column list with column names set * @param table the table from where to map the column names to columns */ public static void mapColumns(IndexColumn[] indexColumns, Table table) { for (IndexColumn col : indexColumns) { col.column = table.getColumn(col.columnName); } }
@Override public int hashCode() { if (table == null || name == null) { return 0; } return table.getId() ^ name.hashCode(); }
private Value getMax(Value a, Value b, boolean bigger) { if (a == null) { return b; } else if (b == null) { return a; } if (session.getDatabase().getSettings().optimizeIsNull) { // IS NULL must be checked later if (a == ValueNull.INSTANCE) { return b; } else if (b == ValueNull.INSTANCE) { return a; } } int comp = a.compareTo(b, table.getDatabase().getCompareMode()); if (comp == 0) { return a; } if (a == ValueNull.INSTANCE || b == ValueNull.INSTANCE) { if (session.getDatabase().getSettings().optimizeIsNull) { // column IS NULL AND column <op> <not null> is always false return null; } } if (!bigger) { comp = -comp; } return comp > 0 ? a : b; }
columns = table.getColumns(); Index idx = table.getPrimaryKey(); if (idx == null) { throw DbException.get(ErrorCode.CONSTRAINT_NOT_FOUND_1, "PRIMARY KEY"); buff.append(table.getSQL()).append(" SET "); for (Column c : columns) { buff.appendExceptFirst(", ");
private int expandColumnList(TableFilter filter, int index) { Table t = filter.getTable(); String alias = filter.getTableAlias(); Column[] columns = t.getColumns(); for (Column c : columns) { if (filter.isNaturalJoinColumn(c)) { continue; } ExpressionColumn ec = new ExpressionColumn(session.getDatabase(), null, alias, c.getName()); expressions.add(index++, ec); } return index; }