public List<String> split( String script ) {
    if ( script == null ) {
      return Collections.emptyList();
    }
    List<String> result = new ArrayList<String>();

    MODE mode = MODE.SQL;

    char currentStringChar = 0;
    int statementStart = 0;

    for ( int i = 0; i < script.length(); i++ ) {
      char ch = script.charAt( i );
      char nextCh = i < script.length() - 1 ? script.charAt( i + 1 ) : 0;
      switch ( mode ) {
        case SQL:
          switch ( ch ) {
            case '/':
              if ( nextCh == '*' ) {
                mode = MODE.BLOCK_COMMENT;
                i++;
              }
              break;
            case '-':
              if ( nextCh == '-' ) {
                mode = MODE.LINE_COMMENT;
                i++;
              }
              break;
            case '\'':
            case '"':
              mode = MODE.STRING;
              currentStringChar = ch;
              break;
            case ';':
              String st = script.substring( statementStart, i );
              if ( StringUtils.isNotBlank( st ) ) {
                result.add( st );
              }
              statementStart = i + 1;
              break;
          }
          break;
        case BLOCK_COMMENT:
          if ( ch == '*' ) {
            if ( nextCh == '/' ) {
              mode = MODE.SQL;
              i++;
            }
          }
          break;
        case LINE_COMMENT:
          if ( ch == '\n' || ch == '\r' ) {
            mode = MODE.SQL;
          }
          break;
        case STRING:
          if ( ch == '\\' && nextCh == '\\' ) {
            /*
             * The user is hard-coding a backslash into the string.
             * Pass the hard-coded backslash through, and skip over the real backslash on the next loop
             */
            i++;
          } else if ( ch == '\\' && nextCh == currentStringChar && usingBackslashAsEscapeCharForQuotation ) {
            /*
             * The user is hard-coding a quote character into the string.
             * Pass the hard-coded quote character through, and skip over the quote on next loop
             */

            /*
             * usingBackslashAsEscapeCharForQuotation
             * PDI-16224.
             *
             * ANSI standards specify that using the backslash character (\) to escape single (' ') or double (" ")
             * quotation marks is invalid. For example, the following attempt to find a quotation mark does not conform to ANSI standards:
             * where col1 = '\'';"
             * In any way a construction '\'|| is correct for Oracle but for others DBs (ex. MySQl) isn't correct.
             *
             */
            i++;
          } else if ( ch == currentStringChar ) {
            mode = MODE.SQL;
          }
          break;
      }
    }
    if ( statementStart < script.length() ) {
      String st = script.substring( statementStart );
      if ( StringUtils.isNotBlank( st ) ) {
        result.add( st );
      }
    }
    return result;
  }
@Test
  public void testSplit() {
    assertEquals( Arrays.asList( new String[0] ), sqlScriptParser.split( null ) );
    assertEquals( Arrays.asList( new String[0] ), sqlScriptParser.split( "" ) );
    assertEquals( Arrays.asList( new String[0] ), sqlScriptParser.split( " " ) );
    assertEquals( Arrays.asList( "SELECT 1", "SELECT 2" ), sqlScriptParser.split( "SELECT 1;SELECT 2" ) );
    assertEquals( Collections.singletonList( "SELECT '1;2'" ), sqlScriptParser.split( "SELECT '1;2'" ) );
    assertEquals( Collections.singletonList( "SELECT \"1;2\"" ), sqlScriptParser.split( "SELECT \"1;2\"" ) );
    assertEquals( Collections.singletonList( "SELECT -- 1;2" ), sqlScriptParser.split( "SELECT -- 1;2" ) );
    assertEquals( Collections.singletonList( "SELECT /*1;2*/" ), sqlScriptParser.split( "SELECT /*1;2*/" ) );
    assertEquals( Arrays.asList( "SELECT /1", "2" ), sqlScriptParser.split( "SELECT /1;2" ) );
    assertEquals( Arrays.asList( "SELECT /1", "2" ), sqlScriptParser.split( "SELECT /1;;;;2" ) );
    assertEquals( Collections.singletonList( "SELECT /1" ), sqlScriptParser.split( "SELECT /1;\n  \n" ) );
    assertEquals( Collections.singletonList( "SELECT \"hello\\\"world\" FROM dual" ),
            sqlScriptParser.split( "SELECT \"hello\\\"world\" FROM dual" ) );
    assertEquals( Collections.singletonList( "CREATE TABLE test1 (col1 STRING) TBLPROPERTIES (\"prop1\" = \"my\\\"value\")" ),
            sqlScriptParser.split( "CREATE TABLE test1 (col1 STRING) TBLPROPERTIES (\"prop1\" = \"my\\\"value\");" ) );
    assertEquals( Collections.singletonList( "CREATE TABLE test1 (col1 STRING) TBLPROPERTIES ('prop1' = 'my\\\"value')" ),
            sqlScriptParser.split( "CREATE TABLE test1 (col1 STRING) TBLPROPERTIES ('prop1' = 'my\\\"value');" ) );
    assertEquals( Collections.singletonList( "SELECT \"test\\\";SELECT 1" ), sqlScriptParser.split( "SELECT \"test\\\";SELECT 1" ) );
    assertEquals( Collections.singletonList( "SELECT 'test\\';SELECT 1" ), sqlScriptParser.split( "SELECT 'test\\';SELECT 1" ) );
    assertEquals( Arrays.asList( "create table pdi13654 (col1 string) TBLPROPERTIES (\"quoteChar\"=\"\\\"\", \"escapeChar\"=\"\\\\\")", "SELECT 1" ),
            sqlScriptParser.split( "create table pdi13654 (col1 string) TBLPROPERTIES (\"quoteChar\"=\"\\\"\", \"escapeChar\"=\"\\\\\");SELECT 1" ) );
    //PDI-16224
    assertEquals( Collections.singletonList( "SELECT 1 from test where t='\\'||t=a" ), oracleSqlScriptParser.split( "SELECT 1 from test where t='\\'||t=a;" ) );
  }