API: Make more continuations unique
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 24 Dec 2013 20:26:47 +0000 (15:26 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 11 Apr 2014 14:50:16 +0000 (10:50 -0400)
commitd9534a5d5685c05589639d43cdc1e1195bb7cbba
treebab0e734b9ba8352ca9076483495d52d30f28088
parent9d2aa207a09e2f4a8c1134e5764236cdd798e25a
API: Make more continuations unique

API queries must be completely ordered for proper behavior; otherwise
you may get into a situation where a query returns the same continuation
value that was provided. Various modules that have been using timestamps
in/as their continuation parameter can easily run into this problem.

Normally we'd have to add additional fields to the relevant indexes to
be able to make this work without having filesorting queries (which
MySQL really doesn't do well, it fetches all matching rows and only
applies the limit after[1]). But InnoDB has a "feature" where it
effectively appends the table's primary key to all other indexes,[2]
which makes these queries be properly indexed in that situation.
Apparently we're ok with this, since Icc43b62f was merged depending on
this feature.

Also, this change fixes some MySQLisms and other oddities done to
ApiQueryRecentChanges in Icc43b62f.

 [1]: https://dev.mysql.com/doc/refman/5.5/en/limit-optimization.html
 [2]: https://dev.mysql.com/doc/refman/5.5/en/innodb-table-and-index.html

Bug: 24782
Change-Id: I4c9f8c0c2bfd831755d4fa20a18f93fef1effd28
RELEASE-NOTES-1.23
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryWatchlist.php