Facebook的OnlineSchemaChange.php备注

Standard
...
define('OSC_FLAGS_ACCEPT_VERSION',  0x0400); // bypasses version check
...
public function __construct($input_sock = '', $input_user, $input_password,
  $input_dbname, $input_tablename,
  $input_altercmd, $input_outfile_folder = null,
  $input_flags = 0,
  $input_batchsize_load = 500000,
  $input_batchsize_replay = 500,
  $input_long_xact_time = 30,
  $input_logfile_folder = "/var/tmp/") {
  ...
}
 
...
 
  private function validateVersion() {
    ...
    if ((!($this->flags & OSC_FLAGS_ACCEPT_VERSION)) &&
        ($this->version !== "5.0.84") &&
        ($this->version !== "5.1.47")) {
      $error = "OSC has only been tested on versions 5.0.84 and 5.1.47. ".
               "Running on ".$this->version." is not allowed unless ".
               "OSC_FLAGS_ACCEPT_VERSION flag is set.";
      $this->raiseException($error, false);
    }
    return $this->version;
  }
 
...
 
$user='root';
$pwd='';
$db = 'test';
$table = 't1';
$sock = '/var/lib/mysql/mysql.sock';
 
$alter = "ALTER TABLE `t1` ADD INDEX ( `intcol1` )";
 
$osc = new OnlineSchemaChange($sock, $user, $pwd, $db, $table, $alter, NULL, 0x0400);
$osc->execute();