Removes blocks - such as comments and other possible blocks

@param originalSql original SQL
@return SQL string with removed(they will be filled with {@link #FILL_SYMBOL} blocks
17437
private String removeBlocks(String originalSql) {
        StringBuilder cleanedSql = new StringBuilder(originalSql.length());

        Pattern regexPattern = null;
        Matcher regexMatcher = null;

        regexPattern = Pattern.compile(getRegexSkipBlockSearch(), Pattern.CASE_INSENSITIVE);
        regexMatcher = regexPattern.matcher(originalSql + "\n");

        int prevBlockEnd = 0;
        int blockStart = 0;
        int blockEnd = 0;
        String block = null;

        while (regexMatcher.find() == true) {
            blockStart = regexMatcher.start();
            blockEnd = Math.min(originalSql.length(), regexMatcher.end());

            block = originalSql.substring(blockStart, blockEnd);

            cleanedSql.append(originalSql.substring(prevBlockEnd, blockStart));

            prevBlockEnd = blockEnd;

            cleanedSql.append(fill(FILL_SYMBOL, block.length()));
        }

        cleanedSql.append(originalSql.substring(prevBlockEnd, originalSql.length()));

        return cleanedSql.toString();
    }
693886
public String getDefaultSQL() {

        String ddl = null;

        ddl = defaultExpression == null ? null
                                        : defaultExpression.getSQL();

        return ddl;
    }
546744
public static String checkPermitted(String sql)
    {
        /*
         *  IMPORTANT: Black-lists are checked first because they know more about
         * what they don't like about a statement and can provide a better message.
         * It requires that black-lists patterns be very selective and that they
         * don't mind seeing statements that wouldn't pass the white-lists.
         */

        //=== Check against blacklists, must not be rejected by any.

        for (CheckedPattern cp : BLACKLISTS) {
            CheckedPattern.Result result = cp.check(sql);
            if (result.matcher != null) {
                return String.format("%s, in statement: %s", result.explanation, sql);
            }
        }

        //=== Check against whitelists, must be accepted by at least one.

        boolean hadWLMatch = false;
        for (CheckedPattern cp : WHITELISTS) {
            if (cp.matches(sql)) {
                hadWLMatch = true;
                break;
            }
        }
        if (!hadWLMatch) {
            return String.format("AdHoc DDL contains an unsupported statement: %s", sql);
        }

        // The statement is permitted.
        return null;
    }
1178202
public String removeAfter(String original, String marker) {
        int index = original.indexOf(marker);
        if (index != -1) {
            return original.substring(0, index);
        }
        return original;
    }
1271034
public static <T extends StatementTree> Matcher<T> previousStatement(
      Matcher<StatementTree> matcher) {
    return (T statement, VisitorState state) -> {
      BlockTree block = state.findEnclosing(BlockTree.class);
      if (block == null) {
        return false;
      }
      List<? extends StatementTree> statements = block.getStatements();
      int idx = statements.indexOf(statement);
      if (idx <= 0) {
        // The block wrapping us doesn't contain this statement, or doesn't contain a previous
        // statement.
        return false;
      }
      return matcher.matches(statements.get(idx - 1), state);
    };
  }
1172167
@Override
	public int delete(Extensions extensions) throws SQLException {

		DeleteBuilder<Extensions, Void> db = deleteBuilder();

		setUniqueWhere(db.where(), extensions.getExtensionName(), true,
				extensions.getTableName(), true, extensions.getColumnName());

		int deleted = db.delete();

		return deleted;
	}
894609
String createInsertPreparedSQLStatement() {
        final D6Inex includeExcludeColumnNames = null;
        boolean ignoreDuplicate=false;
        return createInsertPreparedSQLStatement(includeExcludeColumnNames,ignoreDuplicate);

    }
1131468
public static List<Block> removeEmptyBlocks(final Collection<Block> blocks) {
      List<Block> cleanBlocks = Lists.newArrayListWithExpectedSize(blocks.size());
      for(Block block : blocks) {
         if(block.content.isEmpty()) {
            continue;
         }

         if(isWhitespace(block.content)) {
            continue;
         }

         cleanBlocks.add(block);
      }
      return cleanBlocks;
   }
1228859
def remove(*objects, &block)
      if block
        types = objects
        conjunction = Query::Connective::Conjunction.new
        if types.length == 1
          conjunction.add_positive_restriction(TypeField.instance, Query::Restriction::EqualTo, types.first)
        else
          conjunction.add_positive_restriction(TypeField.instance, Query::Restriction::AnyOf, types)
        end
        dsl = DSL::Scope.new(conjunction, setup_for_types(types))
        Util.instance_eval_or_call(dsl, &block)
        indexer.remove_by_scope(conjunction)
      else
        objects.flatten!
        @deletes += objects.length
        objects.each do |object|
          indexer.remove(object)
        end
      end
    end
499023
public static String toSingleColumnSql(String sql) {
		String tempSql = sql.trim();
		String regex = "(?i)^select(.*?)from";
		Matcher m = Pattern.compile(regex).matcher(tempSql);
		String columnAlias = SqlTemplate.SINGLE_COLUMN_ALIAS;
		if (m.find()) {
			columnAlias = m.group(1).trim().replaceAll("\\(\\s+", "(").replaceAll("\\s+\\)", ")").split("\\s+")[0]+ " AS " + columnAlias;
		}
		return tempSql.replaceFirst(regex, "select " + columnAlias + " from ");
	}
147064
@SneakyThrows
    public SQLStatement fill(final Collection<SQLSegment> sqlSegments, final SQLStatementRule rule) {
        SQLStatement result = rule.getSqlStatementClass().newInstance();
        result.setLogicSQL(sql);
        for (SQLSegment each : sqlSegments) {
            Optional<SQLSegmentFiller> filler = parsingRuleRegistry.findSQLSegmentFiller(databaseType, each.getClass());
            if (filler.isPresent()) {
                doFill(each, result, filler.get());
            }
        }
        return result;
    }
1164160
public static <S, L> Collection<S> getStatesInBlock(Block<S, L> block) {
        return new OriginalStateCollection<>(block.getStates());
    }
1148107
protected String nullify(String sql) {
        /*
         * Some drivers (Oracle classes12.zip) have difficulty resolving data
         * type if setObject(null). We will modify the query to pass 'null', 'is
         * null', and 'is not null'
         */
        //could be more efficient by compiling expressions in advance.
        int firstWhere = findWhereKeyword(sql);
        if (firstWhere >= 0) {
            Pattern[] patterns = {Pattern.compile("(?is)^(.{" + firstWhere + "}.*?)!=\\s{0,1}(\\s*)\\?'\"\\?(.*)"),
                    Pattern.compile("(?is)^(.{" + firstWhere + "}.*?)<>\\s{0,1}(\\s*)\\?'\"\\?(.*)"),
                    Pattern.compile("(?is)^(.{" + firstWhere + "}.*?[^<>])=\\s{0,1}(\\s*)\\?'\"\\?(.*)"),};
            String[] replacements = {"$1 is not $2null$3", "$1 is not $2null$3", "$1 is $2null$3",};
            for (int i = 0; i < patterns.length; i++) {
                Matcher matcher = patterns[i].matcher(sql);
                while (matcher.matches()) {
                    sql = matcher.replaceAll(replacements[i]);
                    matcher = patterns[i].matcher(sql);
                }
            }
        }
        return sql.replaceAll("\\?'\"\\?", "null");
    }
562744
public Block getBlock(String sqlquery, Collection queryParams, int startIndex, int count) {
		return blockStrategy.getBlock(sqlquery, queryParams, startIndex, count);
	}
1172302
public static String unescapeSQLString(String b)
    {
        if (b.charAt(0) == '\'' && b.charAt(b.length()-1) == '\'')
            b = b.substring(1, b.length()-1);
        return StringEscapeUtils.unescapeJava(b);
    }
493029
protected int remove(Connection connection, RecordStream recordStream)
            throws SQLException, IOException {
        int count = 0;
        PreparedStatement ps = statement(connection, Query.DELETE_RECORD_HASH);
        while (recordStream.hasNext()) {
            VictimsRecord vr = recordStream.getNext();
            setObjects(ps, vr.hash);
            ps.addBatch();
            count++;
        }
        executeBatchAndClose(ps);
        return count;
    }
773523
public SQLBuilder rewrite(final boolean isSingleRouting) {
        SQLBuilder result = new SQLBuilder(parameters);
        if (sqlTokens.isEmpty()) {
            return appendOriginalLiterals(result);
        }
        appendInitialLiterals(!isSingleRouting, result);
        appendTokensAndPlaceholders(!isSingleRouting, result);
        reviseParameters();
        return result;
    }