Page MenuHomePhabricator

change_tag doesn't have a primary key
Closed, ResolvedPublic

Description

It needs one.

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

TTO claimed this task.
TTO raised the priority of this task from to Medium.
TTO updated the task description. (Show Details)
TTO added subscribers: Aklapper, jcrespo, TTO, Legoktm.

Change 304165 had a related patch set uploaded (by TTO):
Add primary key to change_tag and tag_summary tables

https://gerrit.wikimedia.org/r/304165

So what I asked on the ticket is a simple, one line justification of "a new auto_increment column is the best option for a primary key because...".

I think I answered that quite extensively on the patch? Or did you want some more info?

Just reposting my comment here for posterity:

I don't think converting any of the existing keys will work, as the contents of the tables generally look like this:

$ MariaDB [enwiki_p]> (select * from change_tag where ct_log_id is null limit 1) union all (select * from change_tag where ct_rc_id is null limit 1) union all (select * from change_tag where ct_rev_id is null limit 1);
+-----------+-----------+-----------+------------------+-----------+
| ct_rc_id  | ct_log_id | ct_rev_id | ct_tag           | ct_params |
+-----------+-----------+-----------+------------------+-----------+
| 774304154 |      NULL | 690405091 | End of page text | NULL      |
|      NULL |      NULL | 591814806 | WPCleaner        | NULL      |
| 681941033 |  59010411 |      NULL | HHVM             | NULL      |
+-----------+-----------+-----------+------------------+-----------+
3 rows in set (0.01 sec) 

Note all the NULLs in various places. The tag_summary table looks similar.

It would most likely work if we had a primary key on (ct_rc_id,ct_rev_id,ct_log_id,ct_tag), but that is a very unwieldy primary key, and I think you are trying to get rid of such abominations.

Thank you @TTO, I could not find it on the gerrit comments. Too many alters to review. Copying it here (or alternatively, on the gerrit summary it would have been ok) makes it clearer to me.

Here you have my +1.

Change 304165 merged by jenkins-bot:
Add primary key to change_tag and tag_summary tables

https://gerrit.wikimedia.org/r/304165

Can this task be closed as resolved? The patch was merged.