Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1353,29 +1353,29 @@ |
1354 | 1354 | $typechanges = array( |
1355 | 1355 | array("archive", "ar_deleted", "smallint", ""), |
1356 | 1356 | array("filearchive", "fa_deleted", "smallint", ""), |
1357 | | - array("filearchive", "fa_metadata", "bytea", "decode(fa_metadata,'escape')"), |
1358 | | - array("filearchive", "fa_size", "int4", ""), |
1359 | | - array("filearchive", "fa_storage_group","text", ""), |
1360 | | - array("filearchive", "fa_storage_key", "text", ""), |
1361 | | - array("image", "img_metadata", "bytea", "decode(img_metadata,'escape')"), |
1362 | | - array("image", "img_size", "int4", ""), |
1363 | | - array("image", "img_width", "int4", ""), |
1364 | | - array("image", "img_height", "int4", ""), |
1365 | | - array("ipblocks", "ipb_address", "text", "ipb_address::text"), |
1366 | | - array("ipblocks", "ipb_deleted", "char", ""), |
1367 | | - array("math", "math_inputhash", "bytea", "decode(math_inputhash,'escape')"), |
1368 | | - array("math", "math_outputhash", "bytea", "decode(math_outputhash,'escape')"), |
1369 | | - array("mwuser", "user_token", "text", ""), |
1370 | | - array("mwuser", "user_email_token","text", ""), |
1371 | | - array("objectcache", "keyname", "text", ""), |
1372 | | - array("oldimage", "oi_height", "int4", ""), |
1373 | | - array("oldimage", "oi_size", "int4", ""), |
1374 | | - array("oldimage", "oi_width", "int4", ""), |
1375 | | - array("querycache", "qc_value", "int4", ""), |
1376 | | - array("querycachetwo","qcc_value", "int4", ""), |
| 1357 | + array("filearchive", "fa_metadata", "bytea", "decode(fa_metadata,'escape')"), |
| 1358 | + array("filearchive", "fa_size", "integer", ""), |
| 1359 | + array("filearchive", "fa_storage_group","text", ""), |
| 1360 | + array("filearchive", "fa_storage_key", "text", ""), |
| 1361 | + array("image", "img_metadata", "bytea", "decode(img_metadata,'escape')"), |
| 1362 | + array("image", "img_size", "integer", ""), |
| 1363 | + array("image", "img_width", "integer", ""), |
| 1364 | + array("image", "img_height", "integer", ""), |
| 1365 | + array("ipblocks", "ipb_address", "text", "ipb_address::text"), |
| 1366 | + array("ipblocks", "ipb_deleted", "char", ""), |
| 1367 | + array("math", "math_inputhash", "bytea", "decode(math_inputhash,'escape')"), |
| 1368 | + array("math", "math_outputhash", "bytea", "decode(math_outputhash,'escape')"), |
| 1369 | + array("mwuser", "user_token", "text", ""), |
| 1370 | + array("mwuser", "user_email_token","text", ""), |
| 1371 | + array("objectcache", "keyname", "text", ""), |
| 1372 | + array("oldimage", "oi_height", "integer", ""), |
| 1373 | + array("oldimage", "oi_size", "integer", ""), |
| 1374 | + array("oldimage", "oi_width", "integer", ""), |
| 1375 | + array("querycache", "qc_value", "integer", ""), |
| 1376 | + array("querycachetwo","qcc_value", "integer", ""), |
1377 | 1377 | array("recentchanges","rc_deleted", "smallint", ""), |
1378 | 1378 | array("templatelinks","tl_namespace", "smallint", "tl_namespace::smallint"), |
1379 | | - array("user_newtalk", "user_ip", "text", "host(user_ip)"), |
| 1379 | + array("user_newtalk", "user_ip", "text", "host(user_ip)"), |
1380 | 1380 | ); |
1381 | 1381 | |
1382 | 1382 | $newindexes = array( |
— | — | @@ -1435,6 +1435,13 @@ |
1436 | 1436 | $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]"); |
1437 | 1437 | } |
1438 | 1438 | |
| 1439 | + ## Needed before column changes |
| 1440 | + if (is_null($wgDatabase->fieldInfo("archive", "ar_deleted"))) { |
| 1441 | + echo "... add archive.ar_deleted\n"; |
| 1442 | + dbsource(archive("patch-archive-ar_deleted.sql")); |
| 1443 | + } else |
| 1444 | + echo "... archive.ar_deleted already exists\n"; |
| 1445 | + |
1439 | 1446 | foreach ($typechanges as $tc) { |
1440 | 1447 | $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]); |
1441 | 1448 | if (is_null($fi)) { |
— | — | @@ -1455,7 +1462,7 @@ |
1456 | 1463 | } |
1457 | 1464 | } |
1458 | 1465 | |
1459 | | - if ($wgDatabase->fieldInfo('oldimage','oi_deleted') !== 'smallint') { |
| 1466 | + if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') { |
1460 | 1467 | echo "... change oldimage.oi_deleted to smallint"; |
1461 | 1468 | $wgDatabase->query("ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT"); |
1462 | 1469 | $wgDatabase->query("ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)"); |
— | — | @@ -1518,12 +1525,6 @@ |
1519 | 1526 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1520 | 1527 | } |
1521 | 1528 | |
1522 | | - if (is_null($wgDatabase->fieldInfo("archive", "ar_deleted"))) { |
1523 | | - echo "... add archive.ar_deleted\n"; |
1524 | | - dbsource(archive("patch-archive-ar_deleted.sql")); |
1525 | | - } else |
1526 | | - echo "... archive.ar_deleted already exists\n"; |
1527 | | - |
1528 | 1529 | global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes; |
1529 | 1530 | # Add missing extension tables |
1530 | 1531 | foreach ( $wgExtNewTables as $nt ) { |
Index: trunk/phase3/includes/DatabasePostgres.php |
— | — | @@ -16,7 +16,12 @@ |
17 | 17 | global $wgDBmwschema; |
18 | 18 | |
19 | 19 | $q = <<<END |
20 | | -SELECT typname, attnotnull, attlen |
| 20 | +SELECT |
| 21 | +CASE WHEN typname = 'int2' THEN 'smallint' |
| 22 | +WHEN typname = 'int4' THEN 'integer' |
| 23 | +WHEN typname = 'int8' THEN 'bigint' |
| 24 | +ELSE typname END AS typname, |
| 25 | +attnotnull, attlen |
21 | 26 | FROM pg_class, pg_namespace, pg_attribute, pg_type |
22 | 27 | WHERE relnamespace=pg_namespace.oid |
23 | 28 | AND relkind='r' |