Announcement

Announcement Module
Collapse
No announcement yet.

--bidirectional help. Choosing the correct right-column with greatest date.

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • --bidirectional help. Choosing the correct right-column with greatest date.

    Running the following command:

    pt-table-sync --print --bidirectional --databases db1 --tables test --conflict-column update_in --conflict-comparison greatest h=h1 h=h2


    Left:

    +----+---------------------+-----------+----------+
    | id | date_in | update_in | pet_name
    +----+---------------------+-----------+----------+
    | 1 | 2013-09-13 13:41:52 | NULL | kitty
    | 3 | 2013-09-13 13:41:52 | NULL | dog
    | 5 | 2013-09-13 13:41:52 | NULL | tiger
    +----+---------------------+-----------+----------+


    Right:

    +----+---------------------+---------------------+-------------+
    | id | date_in | update_in | pet_name
    +----+---------------------+---------------------+-------------+
    | 1 | 2013-09-13 13:41:52 | NULL | kitty
    | 3 | 2013-09-13 13:41:52 | 2013-09-15 00:00:00 | dog_changed
    | 5 | 2013-09-13 13:41:52 | NULL | tiger
    +----+---------------------+---------------------+-------------+

    I do not get any results. The goal is to bring row 3 over from the right server because the update_in field is the greatest.

    Running:

    pt-table-sync --print --sync-to-master h=h1,D=db1,t=test

    Gives me the correct REPLACE INTO

    REPLACE INTO `db1`.`test`(`id`, `date_in`, `update_in`, `pet_name`) VALUES ('3', '2013-09-13 13:41:52', '2013-09-15 00:00:00', 'dog_changed')


    What is the best approach to explicitly choosing the greatest specified date record using bidirectional?

    Thank you,

    -Matt

  • #2
    I got it so it returns a result, but its the opposite from the newest 0_o

    pt-table-sync --print --bidirectional --databases db1--tables test--columns update_in --conflict-column update_in --conflict-comparison newest h=h1 h=h2

    /*h1*/ UPDATE `db1`.`test` SET `date_in`='2013-09-13 13:41:52', `update_in`='2013-09-01 00:00:00', `pet_name`='dog' WHERE `id`='3' LIMIT 1;

    It is attempting to use the "oldest" when I specify the newest. What exactly am I missing?
    Last edited by mwild8; 09-13-2013, 04:25 PM.

    Comment


    • #3
      I have solved this issue. It was a mistake on my part.

      Comment

      Working...
      X