Manual:Revision table/zh

revision表保存了wiki上所有對頁面編輯的元資料. 对页面所做的每一笔编辑会创建一个修订版本（revision）行，其中包括如进行修改的用户、提交编辑的时间，以及引用表中的新维基文本.

需注意行中的部分内容与编辑操作有关，另一部分则与新的维基文本有关. 它并不直接引用旧的维基文本.

从另一个wiki导入页面的最后修订版本会在revision表中产生两行，一行是导入的修订版本的日期和维基文本，另一行则有导入日期. 后者的维基文本即当前页面的维基文本，如果同名页面已经存在，则是两个页面中时间较晚的版本.

revision表非常类似于表. revision表被用于页面历史和的列出. 表被用于、、，且对于新创建的页面用于.

差异包括：


 * recentchanges表还记录了事件，例如页面移动和删除.
 * recentchanges表中的项目被定期清理，而revision表中的内容永久保留，除非页面被删除或网站站长运行维护脚本.
 * 如上所述，导入一个页面的修订版本不止添加一个带有导入日期的项到revision表，还添加一份带有原始日期的版本.

已删除的修订版本被转移到表.

revision表和text表于引入以取代表.

rev_id
此欄位保存每個版本的主鍵. 是指向此欄位的外鍵. 数字rev_id自该表于MediaWiki 1.5创建依赖，跨越删除/取消删除，保持不变，用rev_id和text_id取代了旧的cur_id.

rev_page
该字段引用了表示与此修订相关的页面. 此字段中的数字等于所涉页面的字段. 这永远不会无效；如果发生，则该修订版本不会出现在页面历史记录中. 如果链接到的修订版本有无效的rev_page，将导致“页面'Foo'的修订版本#0不存在”错误. (similar issue might occur when slots and content are missing for the revision)

rev_text_id
这是表中的外键. （text表是文本的实际存储桶. ） It's possible for multiple revisions to use the same text - for instance, revisions where only metadata is altered, or where a is done to a previous version.

If rows in the table with  = rev_id exist, this field should be ignored (and may be 0) in favor of the corresponding data from the slots and content tables.

该列已被取代.

rev_comment
该列存有编者在修订版本时留下的编辑摘要. 该文本显示于历史记录和贡献记录. ( The table contains a copy used for, ,  , and, in the case of page creation, for the . ) 呈现时以能安全表现的wiki标记格式子集处理.

应使用revision_comment_temp表的和表代替！

此列已被取代，其引用了.

rev_comment_id
这是表中的外键.

If this field contains zero in each record, the comment id must be retrieved from the table. Supposedly, this table will be merged with the table revision again in the future.

rev_user
This is equal to the of the user who made this edit. The value for this field is 0 for anonymous edits, initializations scripts, and for some mass imports.

注意，存在缺陷：T112384.

While actor migration is being done, and depending on the configuration setting, this field may be empty and the actor performing the edit can be stored in the rev_actor field or the table instead.

此列已随移除. 此列已被取代，其引用了.

rev_user_text
This field holds the text of the editor's, or the IP address of the editor if the revision was done by an unregistered user.

In anonymous revisions imported from UseModWiki or early incarnations of the Phase II software, this field may contain an IP address with the final octet obscured (i.e.  such as 24.150.61.xxx; see bug 3631). Some edits imported from UseModWiki may contain a Reverse DNS lookup hostname like  or.

While actor migration is being done, and depending on the configuration setting, this field may be empty and the actor performing the edit can be stored in the rev_actor field or the table instead.

此列已随移除. 此列已被取代，其引用了.

rev_actor
这是表中的外键. If this field contains zero in each record, the actor id must be retrieved from the table. Supposedly, this table will be merged with the table revision again in the future. 参见.

rev_timestamp
存有编辑的.

rev_minor_edit
记录用户是否标记为小修改. 标记为小修改则该值为1，否则该值为0. 许多自动化编辑被标记为小修改.

rev_deleted
此字段为系统保留. 这是一个位元字段（bitfield），值表示方法是：DELETED_TEXT = 1（删除文本）；DELETED_COMMENT = 2（删除编辑摘要）；DELETED_USER = 4（删除用户名）；DELETED_RESTRICTED = 8. 因此，如果该修订版本没有任何删除，则该值为0；如果编辑摘要和用户名被删除，该值为6.

rev_len
该字段包含此修订后页面的长度，字节为单位. 用于历史记录页面. 对应.

rev_parent_id
此页面的上一个修订版本的rev_id. 对应. 对于创建页面的编辑，rev_parent_id = 0.

用法
This field is used to add support for a tree structure. This field is e.g. used to calculate the size difference of a certain revision with the previous revision in the page history view. If a parent ID points to a revision that's associated with a different page, MediaWiki will still use that parent revision as a basis of comparison for purposes of calculating size difference. If a revision is deleted from the database, and another revision's parent ID still points to it, then MediaWiki will behave the same as if there were no parent revision; i.e. it will assume the previous size was 0.

转移修订版本
When revisions are imported from another wiki, the imported revisions' parent ID tree structure from the source wiki is retained (this is implemented by each revision's, other than the tail revision, having a XML element that is used to populate rev_parent_id), and the destination wiki's revisions' parent IDs are not updated. Likewise, when page histories are merged, the parent IDs of the revisions from the source and destination pages are not updated. can be used to populate rev_parent_id based on revision timestamps and revision IDs. In the case of an edit conflict, the revision ID of the edit that is saved first (causing the conflict) will be used as the parent ID of the edit that is saved second (after resolving the conflict).

rev_sha1
This field is used to add the SHA-1 text content hash in base-36 (generated by .) Since 1.32, it's a nested hash of hashes of across all slots of the revision. If the revision only has one slot, the values of the rev_sha1 and content_sha1 fields are identical. The nested hash algorithm is implemented in. 可以概括为：

rev_sha1 = hash_n; hash_n = sha1( hash_n-1, content_sha1_n ); hash_1 = content_sha1_1;

rev_content_model
内容模型见中的CONTENT_MODEL_XXX常量. 这些ID会在API和XML转储中披露. 定义自用的内容模型ID的扩展应注意避免冲突. Using the extension name as a prefix is recommended, for example 'myextension-somecontent'. Possible values are, e.g.: 'wikitext', 'javascript', 'css', 'text', and 'json'

If rows in the slots table with slot_revision_id = rev_id this field should be ignored (and may be NULL) in favor of the corresponding data from the slots and content tables.

This column was replaced by, which references.

rev_content_format
Content format, see CONTENT_FORMAT_XXX constants in. These should be MIME types, and will be exposed in the API and XML dumps. Extensions are free to use the below formats, or define their own. It is recommended to stick with the conventions for MIME types. Possible values are, e.g.: 'text/x-wiki', 'text/javascript', 'text/css', 'text/plain', 'text/html', 'application/vnd.php.serialized', 'application/json', 'application/xml'

If rows in the slots table with slot_revision_id = rev_id exist, this field should be ignored (and may be NULL).

This column was removed. The ContentHandler class is able to automatically detect the content format, and replaces this column.

架构摘要
++-+--+-+++ ++-+--+-+++ ++-+--+-+++
 * Field         | Type                | Null | Key | Default        | Extra          |
 * rev_id        | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
 * rev_page      | int(10) unsigned    | NO   | MUL | NULL           |                |
 * rev_comment_id | bigint(20) unsigned | NO  |     | 0              |                |
 * rev_actor     | bigint(20) unsigned | NO   | MUL | 0              |                |
 * rev_timestamp | binary(14)          | NO   | MUL |                |                |
 * rev_minor_edit | tinyint(3) unsigned | NO  |     | 0              |                |
 * rev_deleted   | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_len       | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_parent_id | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_sha1      | varbinary(32)       | NO   |     |                |                |

++-+--+-+++ ++-+--+-+++ ++-+--+-+++
 * Field             | Type                | Null | Key | Default        | Extra          |
 * rev_id            | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
 * rev_page          | int(10) unsigned    | NO   | MUL | NULL           |                |
 * rev_text_id       | int(10) unsigned    | NO   |     | 0              |                |
 * rev_comment       | varbinary(767)      | NO   |     |                |                |
 * rev_user          | int(10) unsigned    | NO   | MUL | 0              |                |
 * rev_user_text     | varbinary(255)      | NO   | MUL |                |                |
 * rev_timestamp     | binary(14)          | NO   | MUL |                |                |
 * rev_minor_edit    | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_deleted       | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_len           | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_parent_id     | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_sha1          | varbinary(32)       | NO   |     |                |                |
 * rev_content_model | varbinary(32)       | YES  |     | NULL           |                |
 * rev_content_format | varbinary(64)      | YES  |     | NULL           |                |

++-+--+-+++ ++-+--+-+++ ++-+--+-+++
 * Field             | Type                | Null | Key | Default        | Extra          |
 * rev_id            | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
 * rev_page          | int(10) unsigned    | NO   | MUL | NULL           |                |
 * rev_text_id       | int(10) unsigned    | NO   |     | NULL           |                |
 * rev_comment       | varbinary(767)      | NO   |     |                |                |
 * rev_user          | int(10) unsigned    | NO   | MUL | 0              |                |
 * rev_user_text     | varbinary(255)      | NO   | MUL |                |                |
 * rev_timestamp     | binary(14)          | NO   | MUL |                |                |
 * rev_minor_edit    | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_deleted       | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_len           | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_parent_id     | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_sha1          | varbinary(32)       | NO   |     |                |                |
 * rev_content_model | varbinary(32)       | YES  |     | NULL           |                |
 * rev_content_format | varbinary(64)      | YES  |     | NULL           |                |

++-+--+-+++ ++-+--+-+++ ++-+--+-+++
 * Field             | Type                | Null | Key | Default        | Extra          |
 * rev_id            | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
 * rev_page          | int(10) unsigned    | NO   | MUL | NULL           |                |
 * rev_text_id       | int(10) unsigned    | NO   |     | NULL           |                |
 * rev_comment       | varbinary(767)      | NO   |     | NULL           |                |
 * rev_user          | int(10) unsigned    | NO   | MUL | 0              |                |
 * rev_user_text     | varbinary(255)      | NO   | MUL |                |                |
 * rev_timestamp     | binary(14)          | NO   | MUL |                |                |
 * rev_minor_edit    | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_deleted       | tinyint(3) unsigned | NO   |     | 0              |                |
 * rev_len           | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_parent_id     | int(10) unsigned    | YES  |     | NULL           |                |
 * rev_sha1          | varbinary(32)       | NO   |     |                |                |
 * rev_content_model | varbinary(32)       | YES  |     | NULL           |                |
 * rev_content_format | varbinary(64)      | YES  |     | NULL           |                |

++-+--+-+-++ ++-+--+-+-++ ++-+--+-+-++
 * Field             | Type                | Null | Key | Default | Extra          |
 * rev_id            | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
 * rev_page          | int(10) unsigned    | NO   | PRI | NULL    |                |
 * rev_text_id       | int(10) unsigned    | NO   |     | NULL    |                |
 * rev_comment       | tinyblob            | NO   |     | NULL    |                |
 * rev_user          | int(10) unsigned    | NO   | MUL | 0       |                |
 * rev_user_text     | varchar(255) binary | NO   | MUL | NULL    |                |
 * rev_timestamp     | binary(14)          | NO   | MUL | NULL    |                |
 * rev_minor_edit    | tinyint(3) unsigned | NO   |     | 0       |                |
 * rev_deleted       | tinyint(3) unsigned | NO   |     | 0       |                |
 * rev_len           | int(10) unsigned    | YES  |     | NULL    |                |
 * rev_parent_id     | int(10) unsigned    | YES  |     | NULL    |                |
 * rev_sha1          | varbinary(32)       | NO   |     | NULL    |                |
 * rev_content_model | varbinary(32)       | YES  |     | NULL    |                |
 * rev_content_format | varbinary(64)      | YES  |     | NULL    |                |

++-+--+-+-++ ++-+--+-+-++ ++-+--+-+-++
 * Field         | Type                | Null | Key | Default | Extra          |
 * rev_id        | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
 * rev_page      | int(10) unsigned    | NO   | PRI | NULL    |                |
 * rev_text_id   | int(10) unsigned    | NO   |     | NULL    |                |
 * rev_comment   | tinyblob            | NO   |     | NULL    |                |
 * rev_user      | int(10) unsigned    | NO   | MUL | 0       |                |
 * rev_user_text | varchar(255) binary | NO   | MUL | NULL    |                |
 * rev_timestamp | binary(14)          | NO   | MUL | NULL    |                |
 * rev_minor_edit | tinyint(3) unsigned | NO  |     | 0       |                |
 * rev_deleted   | tinyint(3) unsigned | NO   |     | 0       |                |
 * rev_len       | int(10) unsigned    | YES  |     | NULL    |                |
 * rev_parent_id | int(10) unsigned    | YES  |     | NULL    |                |
 * rev_sha1      | varbinary(32)       | NO   |     | NULL    |                |

++-+--+-+-++ ++-+--+-+-++ ++-+--+-+-++
 * Field         | Type                | Null | Key | Default | Extra          |
 * rev_id        | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
 * rev_page      | int(10) unsigned    | NO   | PRI | NULL    |                |
 * rev_text_id   | int(10) unsigned    | NO   |     | NULL    |                |
 * rev_comment   | tinyblob            | NO   |     | NULL    |                |
 * rev_user      | int(10) unsigned    | NO   | MUL | 0       |                |
 * rev_user_text | varchar(255) binary | NO   | MUL | NULL    |                |
 * rev_timestamp | binary(14)          | NO   | MUL | NULL    |                |
 * rev_minor_edit | tinyint(3) unsigned | NO  |     | 0       |                |
 * rev_deleted   | tinyint(3) unsigned | NO   |     | 0       |                |
 * rev_len       | int(10) unsigned    | YES  |     | NULL    |                |
 * rev_parent_id | int(10) unsigned    | YES  |     | NULL    |                |

++-+--+-+-++ ++-+--+-+-++ ++-+--+-+-++
 * Field         | Type                | Null | Key | Default | Extra          |
 * rev_id        | int(8) unsigned     | NO   | PRI | NULL    | AUTO_INCREMENT |
 * rev_page      | int(8) unsigned     | NO   | PRI | NULL    |                |
 * rev_text_id   | int(8) unsigned     | NO   |     | NULL    |                |
 * rev_comment   | tinyblob            | NO   |     | NULL    |                |
 * rev_user      | int(5) unsigned     | NO   | MUL | 0       |                |
 * rev_user_text | varchar(255) binary | NO   | MUL | NULL    |                |
 * rev_timestamp | char(14) binary     | NO   | MUL | NULL    |                |
 * rev_minor_edit | tinyint(1) unsigned | NO  |     | 0       |                |
 * rev_deleted   | tinyint(1) unsigned | NO   |     | 0       |                |

索引
 +--++--+--+---+---+-+--++--++-+---+ +--++--+--+---+---+-+--++--++-+---+ +--++--+--+---+---+-+--++--++-+---+
 * Table   | Non_unique | Key_name                 | Seq_in_index | Column_name   | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
 * revision |         0 | PRIMARY                  |            1 | rev_id        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_page_id              |            1 | rev_page      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_page_id              |            2 | rev_id        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_timestamp            |            1 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | page_timestamp           |            1 | rev_page      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | page_timestamp           |            2 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_actor_timestamp      |            1 | rev_actor     | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_actor_timestamp      |            2 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_actor_timestamp      |            3 | rev_id        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_page_actor_timestamp |            1 | rev_page      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_page_actor_timestamp |            2 | rev_actor     | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
 * revision |         1 | rev_page_actor_timestamp |            3 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |