The latest entity reference patch breaks when apply it in mysql group replication environment due to not having defining primary key on taxnomy_index_tmp table.

I would like to suggest adding primary key right after taxonomy_index_tmp table is created.

existing code

function entityreference_update_7100() {
if (db_table_exists('taxonomy_index')) {
if (db_table_exists('taxonomy_index_tmp')) {
db_drop_table('taxonomy_index_tmp');

}

$tx_schema = drupal_get_schema('taxonomy_index');
db_create_table('taxonomy_index_tmp', $tx_schema);


db_add_primary_key('taxonomy_index_tmp', array('nid','tid'));

$select = db_select('taxonomy_index', 'tx');
$select->fields('tx', array('nid', 'tid'));
$select->groupBy('tx.nid');
$select->groupBy('tx.tid');
$select->addExpression('MAX(sticky)', 'sticky');
$select->addExpression('MAX(created)', 'created');
db_insert('taxonomy_index_tmp')->from($select)->execute();
db_drop_table('taxonomy_index');
db_rename_table('taxonomy_index_tmp', 'taxonomy_index');
}
}

Comments

Khorshid created an issue. See original summary.

Version: 7.56 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.