private Replace parseReplace(){
  Replace command=new Replace(session);
  currentPrepared=command;
  read("INTO");
  Table table=readTableOrView();
  command.setTable(table);
  if (readIf("(")) {
    if (isSelect()) {
      command.setQuery(parseSelect());
      read(")");
      return command;
    }
    Column[] columns=parseColumnList(table);
    command.setColumns(columns);
  }
  if (readIf("VALUES")) {
    do {
      ArrayList<Expression> values=New.arrayList();
      read("(");
      if (!readIf(")")) {
        do {
          if (readIf("DEFAULT")) {
            values.add(null);
          }
 else {
            values.add(readExpression());
          }
        }
 while (readIfMore());
      }
      command.addRow(values.toArray(new Expression[values.size()]));
    }
 while (readIf(","));
  }
 else {
    command.setQuery(parseSelect());
  }
  return command;
}

private Replace parseReplace ( ) { Replace command = new Replace ( session ) ; currentPrepared = command ; read ( "INTO" ) ; Table table = readTableOrView ( ) ; command . setTable ( table ) ; if ( readIf ( "(" ) ) { if ( isSelect ( ) ) { command . setQuery ( parseSelect ( ) ) ; read ( ")" ) ; return command ; } Column [ ] columns = parseColumnList ( table ) ; command . setColumns ( columns ) ; } if ( readIf ( "VALUES" ) ) { do { ArrayList < Expression > values = New . arrayList ( ) ; read ( "(" ) ; if ( ! readIf ( ")" ) ) { do { if ( readIf ( "DEFAULT" ) ) { values . add ( null ) ; } else { values . add ( readExpression ( ) ) ; } } while ( readIfMore ( ) ) ; } command . addRow ( values . toArray ( new Expression [ values . size ( ) ] ) ) ; } while ( readIf ( "," ) ) ; } else { command . setQuery ( parseSelect ( ) ) ; } return command ; }
mysql compatibility . replace is similar to merge .
