Split down patch-comment-table.sql
[lhc/web/wiklou.git] / maintenance / archives / patch-ipb_range_start.sql
1 -- Add the range handling fields
2 ALTER TABLE /*$wgDBprefix*/ipblocks
3 ADD ipb_range_start tinyblob NOT NULL default '',
4 ADD ipb_range_end tinyblob NOT NULL default '',
5 ADD INDEX ipb_range (ipb_range_start(8), ipb_range_end(8));
6
7
8 -- Initialise fields
9 -- Only range blocks match ipb_address LIKE '%/%', this fact is used in the code already
10 UPDATE /*$wgDBprefix*/ipblocks
11 SET
12 ipb_range_start = LPAD(HEX(
13 (SUBSTRING_INDEX(ipb_address, '.', 1) << 24)
14 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 2), '.', -1) << 16)
15 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 3), '.', -1) << 24)
16 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '/', 1), '.', -1)) ), 8, '0' ),
17
18 ipb_range_end = LPAD(HEX(
19 (SUBSTRING_INDEX(ipb_address, '.', 1) << 24)
20 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 2), '.', -1) << 16)
21 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 3), '.', -1) << 24)
22 + (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '/', 1), '.', -1))
23 + ((1 << (32 - SUBSTRING_INDEX(ipb_address, '/', -1))) - 1) ), 8, '0' )
24
25 WHERE ipb_address LIKE '%/%';