/** * Optimize a query. This will remember the subquery info, clear it, prepare * the query, and reset the subquery info. * * @param query the query to prepare */ public void optimizeQueryExpression(Query query) { // we have to hide current subQueryInfo if we are going to optimize // query expression SubQueryInfo tmp = subQueryInfo; subQueryInfo = null; preparingQueryExpression++; try { query.prepare(); } finally { subQueryInfo = tmp; preparingQueryExpression--; } }
Query theQuery, String[] querySQLOutput) { List<Column> columnTemplateList = new ArrayList<>(); theQuery.prepare();
query.prepare(); if (query.getColumnCount() != columns.length) { throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
query.prepare(); if (query.getColumnCount() != columns.length) { throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
query.prepare(); if (query.getColumnCount() != columns.length) { throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
query.prepare(); if (query.getColumnCount() != columns.length) { throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
try { query = parseSelect(); query.prepare(); } finally { session.setParsingCreateView(false, viewName);
asQuery.prepare(); if (data.columns.isEmpty()) { generateColumnsFromQuery();
public Expression optimize(Session session) throws SQLException { query.prepare(); return this; }
public Expression optimize(Session session) throws SQLException { query.prepare(); return this; }
/** * Optimize a query. This will remember the subquery info, clear it, prepare * the query, and reset the subquery info. * * @param query the query to prepare */ public void optimizeQueryExpression(Query query) { // we have to hide current subQueryInfo if we are going to optimize // query expression SubQueryInfo tmp = subQueryInfo; subQueryInfo = null; preparingQueryExpression++; try { query.prepare(); } finally { subQueryInfo = tmp; preparingQueryExpression--; } }
/** * Optimize a query. This will remember the subquery info, clear it, prepare * the query, and reset the subquery info. * * @param query the query to prepare */ public void optimizeQueryExpression(Query query) { // we have to hide current subQueryInfo if we are going to optimize // query expression SubQueryInfo tmp = subQueryInfo; subQueryInfo = null; preparingQueryExpression++; try { query.prepare(); } finally { subQueryInfo = tmp; preparingQueryExpression--; } }
public Expression optimize(Session session) throws SQLException { left = left.optimize(session); if (left == ValueExpression.NULL) { return left; } query.prepare(); if (query.getColumnCount() != 1) { throw Message.getSQLException(ErrorCode.SUBQUERY_IS_NOT_SINGLE_COLUMN); } // Can not optimize IN(SELECT...): the data may change // However, could transform to an inner join return this; }
query.prepare(); if (query.getColumnCount() != columns.length) { throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
private Query parserWith() throws SQLException { String tempViewName = readIdentifierWithSchema(); Schema schema = getSchema(); TableData recursiveTable; read("("); String[] cols = parseColumnList(); ObjectArray columns = new ObjectArray(); for (int i = 0; i < cols.length; i++) { columns.add(new Column(cols[i], Value.STRING)); } int id = database.allocateObjectId(true, true); recursiveTable = schema.createTable(tempViewName, id, columns, false, false); recursiveTable.setTemporary(true); session.addLocalTempTable(recursiveTable); String querySQL = StringCache.getNew(sqlCommand.substring(parseIndex)); read("AS"); Query withQuery = parseSelect(); withQuery.prepare(); session.removeLocalTempTable(recursiveTable); id = database.allocateObjectId(true, true); TableView view = new TableView(schema, id, tempViewName, querySQL, null, cols, session, true); view.setTemporary(true); // view.setOnCommitDrop(true); session.addLocalTempTable(view); Query query = parseSelect(); query.prepare(); query.setPrepareAlways(true); // session.removeLocalTempTable(view); return query; }
public void prepare() throws SQLException { if (columns == null) { if (list.size() > 0 && ((Expression[]) list.get(0)).length == 0) { // special case where table is used as a sequence columns = new Column[0]; } else { columns = table.getColumns(); } } if (list.size() > 0) { for (int x = 0; x < list.size(); x++) { Expression[] expr = (Expression[]) list.get(x); if (expr.length != columns.length) { throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH); } for (int i = 0; i < expr.length; i++) { Expression e = expr[i]; if (e != null) { expr[i] = e.optimize(session); } } } } else { query.prepare(); if (query.getColumnCount() != columns.length) { throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH); } } }
public void prepare() throws SQLException { if (columns == null) { if (list.size() > 0 && ((Expression[]) list.get(0)).length == 0) { // special case where table is used as a sequence columns = new Column[0]; } else { columns = table.getColumns(); } } if (list.size() > 0) { for (int x = 0; x < list.size(); x++) { Expression[] expr = (Expression[]) list.get(x); if (expr.length != columns.length) { throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH); } for (int i = 0; i < expr.length; i++) { Expression e = expr[i]; if (e != null) { expr[i] = e.optimize(session); } } } } else { query.prepare(); if (query.getColumnCount() != columns.length) { throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH); } } }
private CreateView parseCreateView(boolean force) throws SQLException { boolean ifNotExists = readIfNoExists(); String viewName = readIdentifierWithSchema(); CreateView command = new CreateView(session, getSchema()); this.prepared = command; command.setViewName(viewName); command.setIfNotExists(ifNotExists); command.setComment(readCommentIf()); if (readIf("(")) { String[] cols = parseColumnList(); command.setColumnNames(cols); } String select = StringCache.getNew(sqlCommand.substring(parseIndex)); read("AS"); try { Query query = parseSelect(); query.prepare(); command.setSelect(query); } catch (SQLException e) { if (force) { command.setSelectSQL(select); } else { throw e; } } return command; }