Important: This is a development wiki, so things might be a little unstable. If something doesn't work properly, try refreshing the page. If that fails, come back later!
Debugging tools/describe table
From TestWiki
The WikiDebug extension adds a new tag that allows you to display a live description of a DB table within a wiki page.
Contents |
[edit]
Syntax
<describe_table table="{TableName}" display="{DisplayType}" showindexes="{bool}"></describe_table>
- {TableName} is the name of a table in the wiki's database. Do not include the prefix specified by $wgPrefix.
- {DisplayType} is the output format for the table data and currently has two possible values. "table" outputs the table definition in tabular form and "sql" outputs it as an SQL "CREATE TABLE" statement. The display attribute is optional, and if omitted (or present but the value is invalid) then "sql" will be used.
- showindexes is an optional argument, which defaults to true if omitted. Set to false to disable index display when outputting in tabular form (ignored for SQL output).
As a security measure this extension will only allow display of tables added to the $wgWikiDebug_ViewableTables array. Any other tables are blocked.
For example, to view the table 'page', you would need to add the following to LocalSettings.php:
$wgWikiDebug_ViewableTables[] = "page";
[edit]
Example 1: SQL output
Providing the table 'page' is in the viewable tables array, then you can show its description by using the following syntax:
<describe_table table="page"></describe_table>
Live Table Definition: page
CREATE TABLE IF NOT EXISTS `page` ( `page_id` int(8) unsigned NOT NULL auto_increment, `page_namespace` int(11) NOT NULL default '0', `page_title` varchar(255) NOT NULL default '', `page_restrictions` tinyblob NOT NULL, `page_counter` bigint(20) unsigned NOT NULL default '0', `page_is_redirect` tinyint(1) unsigned NOT NULL default '0', `page_is_new` tinyint(1) unsigned NOT NULL default '0', `page_random` double unsigned NOT NULL default '0', `page_touched` varchar(14) NOT NULL default '', `page_latest` int(8) unsigned NOT NULL default '0', `page_len` int(8) unsigned NOT NULL default '0', PRIMARY KEY (`page_id`), UNIQUE KEY `name_title` (`page_namespace`,`page_title`), KEY `page_random` (`page_random`), KEY `page_len` (`page_len`) ) TYPE=MyISAM;
[edit]
Example 2: Tabular description with indexes
<describe_table table="page" display="table"></describe_table>
Live Table Definition: page
| Field | Type | Null | Key | Default | Extra |
|---|---|---|---|---|---|
| page_id | int(8) unsigned | PRI | auto_increment | ||
| page_namespace | int(11) | MUL | 0 | ||
| page_title | varchar(255) | ||||
| page_restrictions | tinyblob | ||||
| page_counter | bigint(20) unsigned | 0 | |||
| page_is_redirect | tinyint(1) unsigned | 0 | |||
| page_is_new | tinyint(1) unsigned | 0 | |||
| page_random | double unsigned | MUL | 0 | ||
| page_touched | varchar(14) | ||||
| page_latest | int(8) unsigned | 0 | |||
| page_len | int(8) unsigned | MUL | 0 |
Indexes
| Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | PRIMARY | 1 | page_id | A | 1518 | BTREE | ||||
| 0 | name_title | 1 | page_namespace | A | 11 | BTREE | ||||
| 0 | name_title | 2 | page_title | A | 1518 | BTREE | ||||
| 1 | page_random | 1 | page_random | A | 1518 | BTREE | ||||
| 1 | page_len | 1 | page_len | A | 253 | BTREE |
[edit]
Example 2: Tabular Description without indexes
<describe_table table="page" display="table" showindexes="false"></describe_table>
Live Table Definition: page
| Field | Type | Null | Key | Default | Extra |
|---|---|---|---|---|---|
| page_id | int(8) unsigned | PRI | auto_increment | ||
| page_namespace | int(11) | MUL | 0 | ||
| page_title | varchar(255) | ||||
| page_restrictions | tinyblob | ||||
| page_counter | bigint(20) unsigned | 0 | |||
| page_is_redirect | tinyint(1) unsigned | 0 | |||
| page_is_new | tinyint(1) unsigned | 0 | |||
| page_random | double unsigned | MUL | 0 | ||
| page_touched | varchar(14) | ||||
| page_latest | int(8) unsigned | 0 | |||
| page_len | int(8) unsigned | MUL | 0 |
[edit]
Example 3: Non-viewable table
If we try and look at a table that is not listed in the $wgWikiDebug_ViewableTables array we get the following:
