From: jenkins-bot Date: Thu, 10 Aug 2017 21:45:54 +0000 (+0000) Subject: Merge "Create new table to be used for querying IP ranges." X-Git-Tag: 1.31.0-rc.0~2418 X-Git-Url: https://git.heureux-cyclage.org/w/index.php?a=commitdiff_plain;h=6a077079d66ac41e9c8d499d4c3e8da1b24313db;hp=f23bed6315d4037898fb5035995ba45239c82ee2;p=lhc%2Fweb%2Fwiklou.git Merge "Create new table to be used for querying IP ranges." --- diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index b4ae1dd940..58728a3755 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -304,6 +304,7 @@ class MysqlUpdater extends DatabaseUpdater { // 1.30 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ], + [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ], ]; } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 46e3e7e2fa..1e43d3e7a1 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -168,6 +168,7 @@ class SqliteUpdater extends DatabaseUpdater { // 1.30 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ], + [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ], ]; } diff --git a/maintenance/archives/patch-ip_changes.sql b/maintenance/archives/patch-ip_changes.sql new file mode 100644 index 0000000000..5f05672e84 --- /dev/null +++ b/maintenance/archives/patch-ip_changes.sql @@ -0,0 +1,23 @@ +-- +-- Every time an edit by a logged out user is saved, +-- a row is created in ip_changes. This stores +-- the IP as a hex representation so that we can more +-- easily find edits within an IP range. +-- +CREATE TABLE /*_*/ip_changes ( + -- Foreign key to the revision table, also serves as the unique primary key + ipc_rev_id int unsigned NOT NULL PRIMARY KEY DEFAULT '0', + + -- The timestamp of the revision + ipc_rev_timestamp binary(14) NOT NULL DEFAULT '', + + -- Hex representation of the IP address, as returned by IP::toHex() + -- For IPv4 it will resemble: ABCD1234 + -- For IPv6: v6-ABCD1234000000000000000000000000 + -- BETWEEN is then used to identify revisions within a given range + ipc_hex varbinary(35) NOT NULL DEFAULT '' + +) /*$wgDBTableOptions*/; + +CREATE INDEX /*i*/ipc_rev_timestamp ON /*_*/ip_changes (ipc_rev_timestamp); +CREATE INDEX /*i*/ipc_hex_time ON /*_*/ip_changes (ipc_hex,ipc_rev_timestamp); diff --git a/maintenance/sqlite/archives/patch-ip_changes.sql b/maintenance/sqlite/archives/patch-ip_changes.sql new file mode 100644 index 0000000000..5f05672e84 --- /dev/null +++ b/maintenance/sqlite/archives/patch-ip_changes.sql @@ -0,0 +1,23 @@ +-- +-- Every time an edit by a logged out user is saved, +-- a row is created in ip_changes. This stores +-- the IP as a hex representation so that we can more +-- easily find edits within an IP range. +-- +CREATE TABLE /*_*/ip_changes ( + -- Foreign key to the revision table, also serves as the unique primary key + ipc_rev_id int unsigned NOT NULL PRIMARY KEY DEFAULT '0', + + -- The timestamp of the revision + ipc_rev_timestamp binary(14) NOT NULL DEFAULT '', + + -- Hex representation of the IP address, as returned by IP::toHex() + -- For IPv4 it will resemble: ABCD1234 + -- For IPv6: v6-ABCD1234000000000000000000000000 + -- BETWEEN is then used to identify revisions within a given range + ipc_hex varbinary(35) NOT NULL DEFAULT '' + +) /*$wgDBTableOptions*/; + +CREATE INDEX /*i*/ipc_rev_timestamp ON /*_*/ip_changes (ipc_rev_timestamp); +CREATE INDEX /*i*/ipc_hex_time ON /*_*/ip_changes (ipc_hex,ipc_rev_timestamp); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 14f69324f7..1497d6fc23 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -410,6 +410,30 @@ CREATE INDEX /*i*/usertext_timestamp ON /*_*/revision (rev_user_text,rev_timesta -- and is a logged-in user. CREATE INDEX /*i*/page_user_timestamp ON /*_*/revision (rev_page,rev_user,rev_timestamp); +-- +-- Every time an edit by a logged out user is saved, +-- a row is created in ip_changes. This stores +-- the IP as a hex representation so that we can more +-- easily find edits within an IP range. +-- +CREATE TABLE /*_*/ip_changes ( + -- Foreign key to the revision table, also serves as the unique primary key + ipc_rev_id int unsigned NOT NULL PRIMARY KEY DEFAULT '0', + + -- The timestamp of the revision + ipc_rev_timestamp binary(14) NOT NULL DEFAULT '', + + -- Hex representation of the IP address, as returned by IP::toHex() + -- For IPv4 it will resemble: ABCD1234 + -- For IPv6: v6-ABCD1234000000000000000000000000 + -- BETWEEN is then used to identify revisions within a given range + ipc_hex varbinary(35) NOT NULL DEFAULT '' + +) /*$wgDBTableOptions*/; + +CREATE INDEX /*i*/ipc_rev_timestamp ON /*_*/ip_changes (ipc_rev_timestamp); +CREATE INDEX /*i*/ipc_hex_time ON /*_*/ip_changes (ipc_hex,ipc_rev_timestamp); + -- -- Holds text of individual page revisions. --