Manual:Cur table/en

The cur table was used in older versions of MediaWiki wikis to store the current revision of a page.

In MediaWiki 1.5 the contents of the cur table and of the ' table were merged together and moved to the ' table, the ' table and the ' table.

After running the updater when updating from MediaWiki 1.4 or older to a newer version, this table is not needed anymore and can be safely deleted.

One way of uniquely accessing the current version of an article was via cur_id, another is through the combination of cur_title and cur_namespace. Note that there may be several entries with the same cur_title in the cur table, for example, Stuff and Talk:Stuff; these will differ in the cur_namespace field, though; the integer values and their corresponding names (e.g., 1="Talk") are set in the appropriate LanguageXX.php file and are also shown using variables.

Some information in the cur table relates to the last change of the article (which might well be its creation, which is indicated by cur_is_new). cur_text holds the wikitext. cur_comment is the edit summary of the last change; cur_user and cur_user_text identify the user that made that change, where cur_user holds the ID of that user, if they were logged in. cur_timestamp notes the time and date of the change, cur_minor_edit carries the state of that checkbox upon saving.

The other fields mainly serve decorative purposes:


 * cur_restrictions - says who can edit that page. Given the nature of Wikipedia, this field will be empty for all articles, except the protected ones.
 * cur_counter - was once supposed to count the views of each page. That function was turned off due to heavy database traffic and some bugs.
 * cur_is_redirect - is a fast and easy way of checking if the cur_text starts with "#REDIRECT".
 * cur_random - is used by the "random page" function. It stores a randomly selected floating-point number between 0 and 1. When someone visits Special:Random the wiki picks another random number and grabs the page with the closest cur_random value. This seems to be much, much faster than 'ORDER BY RAND LIMIT 1' with large numbers of pages, as it's a simple column index lookup.
 * inverse_timestamp - inverse of the cur_timestamp field for reverse sorting on mysql 3.x; this isn't necessary on mysql 4.x and at some point should be removed.
 * cur_touched - timestamp for cache invalidation; updated on page save and the creation/deletion of linked pages

Schema summary
+---+-+--+-+-++ +---+-+--+-+-++ +---+-+--+-+-++
 * Field            | Type                | Null | Key | Default | Extra          |
 * cur_id           | int(8) unsigned     |      | PRI | 0       | auto_increment |
 * cur_namespace    | tinyint(2) unsigned |      | MUL |         |                |
 * cur_title        | varchar(255) binary |      | MUL |         |                |
 * cur_text         | mediumtext          |      |     |         |                |
 * cur_comment      | tinyblob            |      |     |         |                |
 * cur_user         | int(5) unsigned     |      | MUL | 0       |                |
 * cur_user_text    | varchar(255) binary |      | MUL |         |                |
 * cur_timestamp    | varchar(14) binary  |      | MUL |         |                |
 * cur_restrictions | tinyblob            |      |     |         |                |
 * cur_counter      | bigint(20) unsigned |      |     | 0       |                |
 * cur_is_redirect  | tinyint(1) unsigned |      |     | 0       |                |
 * cur_minor_edit   | tinyint(1) unsigned |      |     | 0       |                |
 * cur_is_new       | tinyint(1) unsigned |      |     | 0       |                |
 * cur_random       | double unsigned     |      | MUL | 0       |                |
 * inverse_timestamp | varchar(14) binary |      |     |         |                |
 * cur_touched      | varchar(14) binary  |      |     |         |                |