/** * Does exception indicate query recursion? */ private boolean isRecursiveQueryExceptionDetected(DbException exception) { if (exception == null) { return false; } if (exception.getErrorCode() != ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1) { return false; } return exception.getMessage().contains("\"" + this.getName() + "\""); }
@Override public void stop() { super.stop(); // Clean up after the command was run in the session. // Must restart query (and dependency construction) to reuse. if (prepared.getCteCleanups() != null) { for (TableView view : prepared.getCteCleanups()) { // check if view was previously deleted as their name is set to // null if (view.getName() != null) { session.removeLocalTempTable(view); } } } }
boolean clearIndexCache) { try { compileViewQuery(session, querySQL, false, getName()); } catch (DbException e) { if (!force) {
if (TableType.VIEW == childTable.getTableType()) { TableView childTableView = (TableView) childTable; if (childTableView.isTableExpression() && childTableView.getName() != null) { session.getDatabase().removeSchemaObject(session, childTableView);
setTableExpression(isTableExpression); try { Query compiledQuery = compileViewQuery(session, querySQL, literalsChecked, getName()); this.querySQL = compiledQuery.getPlanSQL(); tables = new ArrayList<>(compiledQuery.getTables());
for (TableView v : dependentViews) { buff.appendExceptFirst(", "); buff.append(v.getName());
public Expression optimizeInJoin(Session session, Select select) throws SQLException { if (all || compareType != Comparison.EQUAL) { return this; } if (!query.isEverything(ExpressionVisitor.EVALUATABLE)) { return this; } String alias = query.getFirstColumnAlias(session); query.setDistinct(true); if (alias == null) { return this; } TableView view = TableView.createTempView(session, session.getUser(), query); TableFilter filter = new TableFilter(session, view, view.getName(), false, select); select.addTableFilter(filter, true); ExpressionColumn column = new ExpressionColumn(session.getDatabase(), null, view.getName(), alias); Expression on = new Comparison(session, Comparison.EQUAL, left, column); on.mapColumns(filter, 0); on.createIndexConditions(session, filter); filter.addFilterCondition(on, true); return ValueExpression.get(ValueBoolean.get(true)); }
private void prepareDrop() { table = getSchema().findTableOrView(session, tableName); if (table == null) { if (!ifExists) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); } } else { session.getUser().checkRight(table, Right.ALL); if (!table.canDrop()) { throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName); } if (dropAction == ConstraintReferential.RESTRICT) { ArrayList<TableView> views = table.getViews(); if (views != null && views.size() > 0) { StatementBuilder buff = new StatementBuilder(); for (TableView v : views) { buff.appendExceptFirst(", "); buff.append(v.getName()); } throw DbException.get(ErrorCode.CANNOT_DROP_2, tableName, buff.toString()); } } table.lock(session, true, true); } if (next != null) { next.prepareDrop(); } }
private void prepareDrop() { table = getSchema().findTableOrView(session, tableName); if (table == null) { if (!ifExists) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); } } else { session.getUser().checkRight(table, Right.ALL); if (!table.canDrop()) { throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName); } if (dropAction == ConstraintReferential.RESTRICT) { ArrayList<TableView> views = table.getViews(); if (views != null && views.size() > 0) { StatementBuilder buff = new StatementBuilder(); for (TableView v : views) { buff.appendExceptFirst(", "); buff.append(v.getName()); } throw DbException.get(ErrorCode.CANNOT_DROP_2, tableName, buff.toString()); } } table.lock(session, true, true); } if (next != null) { next.prepareDrop(); } }