Naive filtering for stuff we haven't implemented yet.
Hopefully this gets whittled away and eventually disappears.

@param sql  statement to check
@return     rejection explanation string or null if accepted
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;
    }
127503
public static String checkCompatibilityIssues( String sql ) {
        sql = sql.replaceAll("LONG PRIMARY KEY AUTOINCREMENT", "INTEGER PRIMARY KEY AUTOINCREMENT");
        sql = sql.replaceAll("AUTO_INCREMENT", "AUTOINCREMENT");
        return sql;
    }
561940
public ServerSidePreparedStatement serverPrepareStatement(final String sql)
      throws SQLException {
    return new ServerSidePreparedStatement(this,
        sql,
        ResultSet.TYPE_FORWARD_ONLY,
        ResultSet.CONCUR_READ_ONLY,
        Statement.RETURN_GENERATED_KEYS);
  }
665739
public void setSql(String sql) {
		if (StringUtils.isNotEmpty(sql)) {
			this.sql = sql.trim();
			this.comment = parseComment(sql);
			this.digest = MessageDigestUtils.MD5(sql);
			
			String sqlStatement = this.sql.toLowerCase();
			if (sqlStatement != null) {
				this.select = sqlStatement.startsWith("select");
				this.procedure = sqlStatement.startsWith("call");
			}
		}
	}
1018019
private void executeStatement(String statement) throws SQLException {

        Statement stmt = null;

        try {
            stmt = m_con.createStatement();
            stmt.execute(statement);
        } finally {
            if (stmt != null) {
                stmt.close();
            }
        }
    }
1194707
public PreparedStatement prepareStatement(final String sql) throws SQLException {
    return internalPrepareStatement(sql,
        ResultSet.TYPE_FORWARD_ONLY,
        ResultSet.CONCUR_READ_ONLY,
        Statement.NO_GENERATED_KEYS);
  }
510122
private void executeStatement(String statement) throws SQLException {
		logger.entering(CLASSNAME, "executeStatement", statement);

		Connection conn = getConnection();
		PreparedStatement ps = null;

		ps = conn.prepareStatement(statement);
		ps.executeUpdate();

		cleanupConnection(conn, ps);
		logger.exiting(CLASSNAME, "executeStatement");
	}
1070109
public static int count(Connection connection, String sql,
			String[] selectionArgs) {

		if (!sql.toLowerCase().contains(" count(*) ")) {
			int index = sql.toLowerCase().indexOf(" from ");
			if (index == -1) {
				return -1;
			}
			sql = "select count(*)" + sql.substring(index);
		}

		int count = querySingleInteger(connection, sql, selectionArgs, true);

		return count;
	}
235187
public boolean submitUpdate(String statement) {
		terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_WILL_EXECUTE).toAnsi());
		terminal.writer().println(new AttributedString(statement).toString());
		terminal.flush();

		final Optional<SqlCommandCall> parsedStatement = parseCommand(statement);
		// only support INSERT INTO
		return parsedStatement.map(cmdCall -> {
			switch (cmdCall.command) {
				case INSERT_INTO:
					return callInsertInto(cmdCall);
				default:
					printError(CliStrings.MESSAGE_UNSUPPORTED_SQL);
					return false;
			}
		}).orElse(false);
	}
905896
@Override
    public SQLException attempt() {
        try {
            Connection con = this.connectionSpec.getOrCreate();
            con.setReadOnly(true);
            try {
                Statement stmt = con.createStatement(
                        ResultSet.TYPE_FORWARD_ONLY,
                        ResultSet.CONCUR_READ_ONLY);
                stmt.setFetchSize(AbstractSQLGenerator.FETCH_SIZE);
                if (this.queryTimeout != null) {
                    stmt.setQueryTimeout(this.queryTimeout);
                }
                try {
                    SQLExecutor.executeSQL(con, stmt, this.query,
                            this.resultProcessor);
                    stmt.close();
                    stmt = null;
                } finally {
                    if (stmt != null) {
                        try {
                            stmt.close();
                        } catch (SQLException e) {
                        }
                    }
                }
                con.close();
                con = null;
            } finally {
                if (con != null) {
                    try {
                        con.close();
                    } catch (SQLException e) {
                    }
                }
            }
            return null;
        } catch (SQLException ex) {
            return ex;
        }
    }
755788
function (sql) {
            var values = this.__opts.values;
            if (isArray(values) && !values.length) {
                return " ()";
            } else {
                return this._super(arguments);
            }
        }
21250
private void sanityCheckQuery(String sql) throws SQLException
  {
    if (sql == null || sql.isEmpty())
    {
      throw new SnowflakeSQLException(SqlState.SQL_STATEMENT_NOT_YET_COMPLETE,
                                      ErrorCode.INVALID_SQL.getMessageCode(), sql);

    }
  }
209138
public static void checkSQLRestriction(DatasourceConnection dc, SQL sql) throws PageException {
	Array sqlparts = ListUtil.listToArrayRemoveEmpty(SQLUtil.removeLiterals(sql.getSQLString()), " \t" + System.getProperty("line.separator"));

	// print.ln(List.toStringArray(sqlparts));
	DataSource ds = dc.getDatasource();
	if (!ds.hasAllow(DataSource.ALLOW_ALTER)) checkSQLRestriction(dc, "alter", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_CREATE)) checkSQLRestriction(dc, "create", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_DELETE)) checkSQLRestriction(dc, "delete", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_DROP)) checkSQLRestriction(dc, "drop", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_GRANT)) checkSQLRestriction(dc, "grant", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_INSERT)) checkSQLRestriction(dc, "insert", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_REVOKE)) checkSQLRestriction(dc, "revoke", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_SELECT)) checkSQLRestriction(dc, "select", sqlparts, sql);
	if (!ds.hasAllow(DataSource.ALLOW_UPDATE)) checkSQLRestriction(dc, "update", sqlparts, sql);
    }
5818
public static Set<String> getSqlParams(final String sql) {
		SqlParser parser = new SqlParserImpl(sql);
		ContextTransformer transformer = parser.parse();
		Node rootNode = transformer.getRoot();

		Set<String> params = new LinkedHashSet<>();
		traverseNode(rootNode, params);
		params.removeIf(s -> CONSTANT_PAT.matcher(s).matches());
		return params;
	}
650434
private void execute(String sql) throws SQLException {
        Statement statement = connection.createStatement();
        try {
            statement.executeUpdate(substitute(sql));
        } finally {
            DbUtils.closeQuietly(statement);
        }
    }
244719
public void execute(String statement) throws SQLException {
		if (logger.isDebugEnabled()) {
			logger.debug("Executing SQL statement [" + statement + "]");
		}
		
		Connection connection = null;
		Statement stm = null;
		
		try{
			connection = ds.getConnection();
			stm = connection.createStatement();			
			stm.execute(statement);
		} catch (SQLException e) {
			throw e;
		}finally{
			if(stm!=null) stm.close();
			if(connection!=null) connection.close();			
		}
				
	}
485851
public static boolean isComment(String sql)
    {
        Matcher commentMatcher = PAT_SINGLE_LINE_COMMENT.matcher(sql);
        return commentMatcher.matches();
    }